公司ubuntu server服務器因業務數據量上升,df下磁盤,使用量達97%node
root@xinju:/home/xinju# fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors Units = 扇區 of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00022eb9 設備 啓動 起點 終點 塊數 Id 系統 /dev/sda1 * 2048 39063551 19530752 83 Linux /dev/sda2 39065598 208594943 84764673 5 擴展 /dev/sda5 39065600 196093951 78514176 83 Linux /dev/sda6 196096000 208594943 6249472 82 Linux 交換 / Solaris root@xinju:/home/xinju# poweroff xinju@xinju:~$ df 文件系統 1K-塊 已用 可用 已用% 掛載點 /dev/sda1 19222656 7296252 10949868 40% / udev 3047540 4 3047536 1% /dev tmpfs 1222724 232 1222492 1% /run none 5120 0 5120 0% /run/lock none 3056800 0 3056800 0% /run/shm /dev/sda5 77277876 73350980 1188 100% /home xinju@xinju:~$ ls
準備把磁盤擴容下。shell
1,vsphere給虛擬機添加100G新硬盤;ubuntu
2, 查看硬盤狀況,獲取新硬盤邏輯分區名是/dev/sdb,服務器
sudo lshw -C disk sudo fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xee55da6f. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 命令(輸入 m 獲取幫助): m 命令操做 a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
3,輸入n,添加一個新分分區;輸入e,做爲擴展分區[extend],選擇完後,會出現原始界面,繼續選擇n,而後就能夠選擇把以前分好的Extend Partion 分區成Logical Partion.這樣的分區才能夠格式化使用。分完後,經過菜單選擇P, 能夠print the partition table.看看咱們是否分區的合理。而後,選擇w保存就能夠了。ide
4,格式化分區ui
root@xinju:/home/xinju# mkfs -t ext4 /dev/sdb mke2fs 1.42 (29-Nov-2011) /dev/sdb is entire device, not just one partition! 不管如何也要繼續? (y,n) y 文件系統標籤= OS type: Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 6553600 inodes, 26214400 blocks 1310720 blocks (5.00%) reserved for the super user 第一個數據塊=0 Maximum filesystem blocks=4294967296 800 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: 完成 正在寫入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成
5,home目錄添加新目錄,供新磁盤掛載,
this
root@xinju:/home# mkdir mount root@xinju:/home# mount /dev/sdb /home/mount
結束。後續注意新的掛載目錄權限分配。code