Você sempre pode usar ferramentas "onboad" para recriar. A exclusão de uma parte no fdisk não a apaga. Basta remover a peça e recriá-la no mesmo setor inicial, mas com tamanho maior. Não hesite em fazer isso na execução da partição montada. Não vai quebrar nada.
Mas, para usar esse tamanho extra depois de recriar você ainda precisará de uma maneira de dizer ao kernel para recarregar a tabela de partes do disco usado, então você precisa instalar o parted e usar o partprobe (o fdisk sugerirá que quando você gravar alterações e sair ). Está dentro do repositório, então apenas instalar o parted.
Em seguida, use resize2fs para ampliar o sistema de arquivos on-line.
O LVM dentro da VM não é necessário, pois torna as coisas mais complicadas. (Surpresa!) Deixe o host fazer o gerenciamento de layout de volume físico real.
Veja a transcrição (é do Debian na verdade, mas com o CentOS ele vai exatamente o mesmo):
root@test:/home/merlin# fdisk -l /dev/sd?
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 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: 0x3bc1a4d0
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 1048575 1046528 511M 82 Linux swap / Solaris
/dev/sda2 1048576 16777215 15728640 7.5G 83 Linux
root@test:/home/merlin# df -h
Файловая система Размер Использовано Дост Использовано% Cмонтировано в
udev 494M 0 494M 0% /dev
tmpfs 100M 1.7M 98M 2% /run
/dev/sda2 7.4G 921M 6.1G 13% /
tmpfs 499M 0 499M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 499M 0 499M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/1000
Neste ponto, adicionei 16 Gb ao sda no host de virtualização. VM vê isso:
root@test:/home/merlin# dmesg | tail
[ 3.613736] usb 1-1: SerialNumber: 42
[ 3.858801] random: crng init done
[ 3.927777] hidraw: raw HID events driver (C) Jiri Kosina
[ 3.939081] usbcore: registered new interface driver usbhid
[ 3.939082] usbhid: USB HID core driver
[ 3.963159] input: QEMU QEMU USB Tablet as /devices/pci0000:00/0000:00:01.2/usb1/1-1/1-1:1.0/0003:0627:0001.0001/input/input6
[ 3.963623] hid-generic 0003:0627:0001.0001: input,hidraw0: USB HID v0.01 Mouse [QEMU QEMU USB Tablet] on usb-0000:00:01.2-1/input0
[ 54.108990] sd 0:0:0:0: Capacity data has changed
[ 54.110036] sd 0:0:0:0: [sda] 50331648 512-byte logical blocks: (25.8 GB/24.0 GiB)
[ 54.110235] sda: detected capacity change from 8589934592 to 25769803776
Agora, todo o procedimento:
root@test:/home/merlin# fdisk -l /dev/sda
Disk /dev/sda: 24 GiB, 25769803776 bytes, 50331648 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: 0x3bc1a4d0
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 1048575 1046528 511M 82 Linux swap / Solaris
/dev/sda2 1048576 16777215 15728640 7.5G 83 Linux
root@test:/home/merlin# fdisk /dev/sda
Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (1048576-50331647, default 1048576):
Last sector, +sectors or +size{K,M,G,T,P} (1048576-50331647, default 50331647):
Created a new partition 2 of type 'Linux' and of size 23.5 GiB.
Partition #2 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: n
Command (m for help): p
Disk /dev/sda: 24 GiB, 25769803776 bytes, 50331648 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: 0x3bc1a4d0
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 1048575 1046528 511M 82 Linux swap / Solaris
/dev/sda2 1048576 50331647 49283072 23.5G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Устройство или ресурс занято
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
root@test:/home/merlin# partprobe /dev/sda
root@test:/home/merlin# df -h
Файловая система Размер Использовано Дост Использовано% Cмонтировано в
udev 494M 0 494M 0% /dev
tmpfs 100M 1.7M 98M 2% /run
/dev/sda2 7.4G 921M 6.1G 13% /
tmpfs 499M 0 499M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 499M 0 499M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/1000
root@test:/home/merlin# resize2fs /dev/sda2
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/sda2 is now 6160384 (4k) blocks long.
root@test:/home/merlin# df -h
Файловая система Размер Использовано Дост Использовано% Cмонтировано в
udev 494M 0 494M 0% /dev
tmpfs 100M 1.7M 98M 2% /run
/dev/sda2 24G 924M 22G 5% /
tmpfs 499M 0 499M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 499M 0 499M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/1000