centos雲上硬碟擴充紀錄

當初規劃沒做好,只好來升級硬碟空間

1.查看空間
2.umount 要增加的掛載點
3.growpart 擴大硬碟空間

1.查看空間

#lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 116.8M  0 rom
vda    253:0    0    50G  0 disk
└─vda1 253:1    0    50G  0 part /
vdb    253:16   0   300G  0 disk
└─vdb1 253:17   0   100G  0 part /disk2

可以看到雲硬碟已經升級到 300G 但實際能使用的仍然是 100G

2.umount 要增加的掛載點

#umount /disk2
umount: /disk2: target is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))

發現有process 卡住,透過lsof 把相應的process 先結束

#lsof +D /disk2

確定沒問題後 再把掛載點給umount

3.growpart 擴大硬碟空間

#growpart /dev/vdb 1 
CHANGED: partition=1 start=2048 old: size=209713152 end=209715200 new: size=629143519 end=629145567

如果是xfs系统

#xfs_growfs -d /

如果是ext4系统

#resize2fs /dev/vdb1 
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/vdb1' first.
#e2fsck -f /dev/vdb1 
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vdb1: 141400/6553600 files (0.2% non-contiguous), 4242823/26214144 blocks
#resize2fs /dev/vdb1 
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vdb1 to 78642939 (4k) blocks.
The filesystem on /dev/vdb1 is now 78642939 blocks long.
#mount /dev/vdb1 /disk2
#df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  3.8G     0  3.8G   0% /dev
tmpfs          tmpfs     3.8G   24K  3.8G   1% /dev/shm
tmpfs          tmpfs     3.8G  411M  3.4G  11% /run
tmpfs          tmpfs     3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/vda1      ext4       50G  5.5G   42G  12% /
tmpfs          tmpfs     773M     0  773M   0% /run/user/0
/dev/vdb1      ext4      296G   15G  266G   6% /disk2
Facebook Comments