Ubuntu系统安装growpart相关工具:
sudo apt install cloud-guest-utils sudo apt install xfsprogs
我的分区如下:
(base) root@uni-dzkf-gpu:/bin# df -Th Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 32G 0 32G 0% /dev tmpfs tmpfs 6.3G 1.4M 6.3G 1% /run /dev/vda2 ext4 99G 93G 1.3G 99% /
(base) root@uni-dzkf-gpu:/bin# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 386K 0 rom /media/root/config-2 vda 252:0 0 200G 0 disk ├─vda1 252:1 0 1M 0 part └─vda2 252:2 0 100G 0 part /
说明:
我将vda磁盘从100G扩容至200G,现在需要做的是扩展vda2分区
执行下面的命令:
(base) root@uni-dzkf-gpu:/bin# growpart /dev/vda 2 CHANGED: partition=2 start=4096 old: size=209711071 end=209715167 new: size=419426271 end=419430367 (base) root@uni-dzkf-gpu:/bin#
注意:
/dev/vda 2 之间是有空格的,不是vda2
这里的2就是指的,对/dev/vda这个磁盘的第2个分区进行growpart操作。
如果你有多个分区,要特别注意这里不要弄错。
如果出现报错:
unexpected output in sfdisk --version [sfdisk,来自 util-linux 2.23.2]
则执行下面的命令修改字符编码:
LANG=en_US.UTF-8 或者 export LC_ALL=en_US.UTF-8 localectl set-locale LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8
然后再执行resize2fs:
(base) root@uni-dzkf-gpu:/bin# resize2fs /dev/vda2 resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/vda2 is mounted on /; on-line resizing required old_desc_blocks = 13, new_desc_blocks = 25 The filesystem on /dev/vda2 is now 52428283 (4k) blocks long. (base) root@uni-dzkf-gpu:/bin#
全过程如下:
(base) root@uni-dzkf-gpu:/bin# ll growpart -rwxr-xr-x 1 root root 24522 Feb 26 2020 growpart* (base) root@uni-dzkf-gpu:/bin# pwd /bin (base) root@uni-dzkf-gpu:/bin# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 386K 0 rom /media/root/config-2 vda 252:0 0 200G 0 disk ├─vda1 252:1 0 1M 0 part └─vda2 252:2 0 100G 0 part / (base) root@uni-dzkf-gpu:/bin# (base) root@uni-dzkf-gpu:/bin# growpart /dev/vda 2 CHANGED: partition=2 start=4096 old: size=209711071 end=209715167 new: size=419426271 end=419430367 (base) root@uni-dzkf-gpu:/bin# (base) root@uni-dzkf-gpu:/bin# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 386K 0 rom /media/root/config-2 vda 252:0 0 200G 0 disk ├─vda1 252:1 0 1M 0 part └─vda2 252:2 0 200G 0 part / (base) root@uni-dzkf-gpu:/bin# df -Th Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 32G 0 32G 0% /dev tmpfs tmpfs 6.3G 1.4M 6.3G 1% /run /dev/vda2 ext4 99G 93G 1.3G 99% / tmpfs tmpfs 32G 8.0K 32G 1% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup tmpfs tmpfs 6.3G 52K 6.3G 1% /run/user/0 /dev/sr0 iso9660 386K 386K 0 100% /media/root/config-2 (base) root@uni-dzkf-gpu:/bin# resize2fs /dev/vda2 resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/vda2 is mounted on /; on-line resizing required old_desc_blocks = 13, new_desc_blocks = 25 The filesystem on /dev/vda2 is now 52428283 (4k) blocks long. (base) root@uni-dzkf-gpu:/bin# df -Th Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 32G 0 32G 0% /dev tmpfs tmpfs 6.3G 1.4M 6.3G 1% /run /dev/vda2 ext4 197G 93G 96G 50% / tmpfs tmpfs 32G 8.0K 32G 1% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup tmpfs tmpfs 6.3G 52K 6.3G 1% /run/user/0 /dev/sr0 iso9660 386K 386K 0 100% /media/root/config-2 (base) root@uni-dzkf-gpu:/bin#
标签:bin,分区,dev,base,ubuntu,LVM,dzkf,tmpfs,root From: https://www.cnblogs.com/yizhipanghu/p/17602596.html