CentOS虚拟机系统盘扩容修复CentOS7镜像规格支持系统盘为20G,当选择系统盘100G时,虚拟机GPT table end位置还是在20G的位置,以至于无法识别空余的空间。所以在挂载前要先修复分区,系统才能识别扩容的磁盘空间。
Using /dev/vda
Welcome to GNU Parted! Type 'help' to view a list of commands.(parted) p
Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? f
fix the GPT to use all of the space (an extra 167772160 blocks) or continuewith the current setting?
Fix/Ignore? f
修复后可以用gdisk进行分区
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): p
Disk /dev/vda: 209715200 sectors, 100.0 GiB
Disk identifier (GUID): B6FFDF47-0FC5-4B8E-8FCA-7E74BD7D2DDA
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 209715166
Total free space is 167776189 sectors (80.0 GiB)
1 2048 411647 200.0 MiB EF00 EFI System Partition
2 411648 2508799 1024.0 MiB 0700
3 2508800 41940991 18.8 GiB 8E00
Command (? for help): n
Last sector (41940992-209715166, default = 209715166) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Changed type of partition to 'Linux filesystem'Command (? for help): w
PARTITIONS!!Do you want to proceed? (Y/N): y
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
添加新的分区后更新核心分区表,可以看到vda4已经更新了
vda 252:0 0 100G 0 disk
├─vda4 252:4 0 80G 0 part
├─vda2 252:2 0 1G 0 part /boot
├─vda3 252:3 0 18.8G 0 part
│ ├─centos-swap 253:1 0 2G 0 lvm [SWAP]│ └─centos-root 253:0 0 16.8G 0 lvm /
└─vda1 252:1 0 200M 0 part /boot/efi
接下来为新的分区新建文件系统
data = bsize=4096 blocks=20971771, imaxpct=25 = sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=10240, version=2 = sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
查看分区的UUID并挂载到/home/data
devtmpfs 1.7G 0 1.7G 0% /dev
tmpfs 1.8G 0 1.8G 0% /dev/shm
tmpfs 1.8G 29M 1.7G 2% /run
tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
/dev/mapper/centos-root 17G 3.6G 14G 22% /
/dev/vda2 1014M 145M 870M 15% /boot
/dev/vda1 200M 9.9M 190M 5% /boot/efi
tmpfs 349M 0 349M 0% /run/user/0
/dev/vda4 80G 33M 80G 1% /home/data
将分区设置为开机自动挂载
|
yd_2494656532023/07/05 10:43:551楼编辑删除举报