Linux分区扩容 不丢失数据

扩容vdb1

$ df -l
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       20509308 16357724   3086728  85% /
/dev/vdb1      103080224 19281512  78555888  20% /data

$ umount /dev/vdb1
$ fdisk /dev/vdb
$ p
Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5d1405c4

Device     Boot Start       End   Sectors  Size Id Type
/dev/vdb1        2048 209715199 209713152  100G 83 Linux

# 删除原有的vdb1 并创建新的
$ d
$ n
一路回车
$ w
保存完成后

$ lsblk /dev/vdb
$ partprobe 
$ umount /dev/vdb1
# 注释自动挂载
$ vim /etc/fstab

$ reboot

$ e2fsck /dev/vdb1

$ resize2fs /dev/vdb1

# 取消注释自动挂载
$ vim /etc/fstab

$ mount /dev/vdb1 /data
Show Comments