Linux 未使用LVM逻辑卷场景
1.检查虚机磁盘信息
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 120G 0 disk
├─sda1 8:1 0 300M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
├─sda3 8:3 0 17.7G 0 part /
└─sda4 8:4 0 100G 0 part /home
sr0 11:0 1 4.2G 0 rom /media
2.VM客户端上调整虚机磁盘空间
3.扩展虚机分区信息
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 130G 0 disk
├─sda1 8:1 0 300M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
├─sda3 8:3 0 17.7G 0 part /
└─sda4 8:4 0 100G 0 part /home
sr0 11:0 1 4.2G 0 rom /media
Install cloud utils
$ ubuntu
sudo apt -y install cloud-guest-utils gdisk
$ centos/redhat
sudo yum -y install cloud-utils-growpart gdisk
使用growpart 扩展分区
$ growpart /dev/sda 4
CHANGED: partition=4 start=41943040 old: size=209715200 end=251658240 new: size=230686687,end=272629727
[root@localhost tools]
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 130G 0 disk
├─sda1 8:1 0 300M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
├─sda3 8:3 0 17.7G 0 part /
└─sda4 8:4 0 110G 0 part /home
sr0 11:0 1 4.2G 0 rom /media
4.调整分区的大小以填充所有空间
$ sudo resize2fs /dev/sda4
$ xfs_growfs /home
确认大小
$ df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 xfs 18G 3.9G 14G 22% /
devtmpfs devtmpfs 975M 0 975M 0% /dev
tmpfs tmpfs 991M 0 991M 0% /dev/shm
tmpfs tmpfs 991M 11M 980M 2% /run
tmpfs tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda4 xfs 110G 79G 32G 72% /home
/dev/sda1 xfs 297M 126M 172M 43% /boot
tmpfs tmpfs 199M 4.0K 199M 1% /run/user/42
tmpfs tmpfs 199M 20K 199M 1% /run/user/1001
|