Este servidor usa LVM así que:
Hemos ampliado partición (growpart)
Hemos ampliado Physical Volume (pvresize)
Hemos ampliado Logical Volume (lvresize)
Hemos ampliado el sistema de ficheros (parámetro –resizefs)
Resize kvm disk,
Ampliar disco QEMU
[root@host00 ~]# fdisk -l
Disk /dev/sda: 45.1 GB, 45097156608 bytes
64 heads, 32 sectors/track, 43008 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00048d54
Device Boot Start End Blocks Id System
/dev/sda1 * 2 501 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 502 32768 33041408 8e Linux LVM
Partition 2 does not end on cylinder boundary.
1. Detectar el cambio de tamaño
# dmesg | grep ^sd
sd 2:0:0:0: Capacity data has changed
sd 2:0:0:0: [sda] 88080384 512-byte logical blocks: (45.0 GB/42.0 GiB)
sda: detected capacity change from 39728447488 to 45097156608
2. Identificar las particiones
# fdisk -l /dev/sda | grep ^/dev
/dev/sda1 * 2 501 512000 83 Linux
/dev/sda2 502 32768 33041408 8e Linux LVM
3. Ampliar la partición
# yum install cloud-utils-growpart
# growpart /dev/sda 2
CHANGED: partition=2 start=1026048 old: size=66082816 end=67108864 new: size=87054336,end=88080384
4. Comprobar
[root@host00 ~]# fdisk -l
Disk /dev/sda: 45.1 GB, 45097156608 bytes
64 heads, 32 sectors/track, 43008 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00048d54
Device Boot Start End Blocks Id System
/dev/sda1 * 2 501 512000 83 Linux
/dev/sda2 502 43008 43527168 8e Linux LVM
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sda 8:0 0 42G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 41.5G 0 part
├─vg_host00-lv_root (dm-0) 253:0 0 28.3G 0 lvm /
└─vg_host00-lv_swap (dm-1) 253:1 0 3.2G 0 lvm [SWAP]
Si no muestra el nuevo tamaño de sda2 hay que reiniciar (depende del kernel)
5. Ampliar PV
Antes:
# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_host00
PV Size 31.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 8066
Free PE 0
Allocated PE 8066
PV UUID maTvB5-mEvj-vhlw-CfFj-RAlg-e0ME-rcANuv
Ampliar:
# pvresize -v /dev/sda2
Using physical volume(s) on command line.
Wiping cache of LVM-capable devices
Wiping internal VG cache
Archiving volume group "vg_host00" metadata (seqno 4).
Resizing volume "/dev/sda2" to 87054336 sectors.
Resizing physical volume /dev/sda2 from 0 to 10626 extents.
Updating physical volume "/dev/sda2"
Creating volume group backup "/etc/lvm/backup/vg_host00" (seqno 5).
Physical volume "/dev/sda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
Después:
# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_host00
PV Size 41.51 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 10626
Free PE 2560
Allocated PE 8066
PV UUID maTvB5-mEvj-vhlw-CfFj-RAlg-e0ME-rcANuv
6. Ampliar el LV
# lvdisplay /dev/vg_host00/lv_root
--- Logical volume ---
LV Path /dev/vg_host00/lv_root
LV Name lv_root
VG Name vg_host00
LV UUID DWRtz9-vmZt-tAXf-gaSS-Gf9b-6r8r-x3LRoX
LV Write Access read/write
LV Creation host, time host00.soluciones.si, 2022-04-01 18:05:17 +0200
LV Status available
# open 1
LV Size 28.31 GiB
Current LE 7247
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
# lvresize --verbose --extents +100%FREE --resizefs /dev/vg_host00/lv_root
Using volume group(s) on command line.
Converted 100%FREE into at most 2560 physical extents.
Executing: fsadm --verbose check /dev/vg_host00/lv_root
fsadm: "ext4" filesystem found on "/dev/mapper/vg_host00-lv_root"
fsadm: Skipping filesystem check for device "/dev/mapper/vg_host00-lv_root" as the filesystem is mounted on /
fsadm failed: 3
Archiving volume group "vg_host00" metadata (seqno 5).
Extending logical volume vg_host00/lv_root to up to 38.31 GiB
Size of logical volume vg_host00/lv_root changed from 28.31 GiB (7247 extents) to 38.31 GiB (9807 extents).
Loading vg_host00-lv_root table (253:0)
Suspending vg_host00-lv_root (253:0) with device flush
Resuming vg_host00-lv_root (253:0)
Creating volume group backup "/etc/lvm/backup/vg_host00" (seqno 6).
Logical volume lv_root successfully resized.
Executing: fsadm --verbose resize /dev/vg_host00/lv_root 40169472K
fsadm: "ext4" filesystem found on "/dev/mapper/vg_host00-lv_root"
fsadm: Device "/dev/mapper/vg_host00-lv_root" size is 41133539328 bytes
fsadm: Parsing tune2fs -l "/dev/mapper/vg_host00-lv_root"
fsadm: Resizing filesystem on device "/dev/mapper/vg_host00-lv_root" to 41133539328 bytes (7420928 -> 10042368 blocks of 4096 bytes)
fsadm: Executing resize2fs /dev/mapper/vg_host00-lv_root 10042368
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_host00-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/vg_host00-lv_root to 10042368 (4k) blocks.
The filesystem on /dev/mapper/vg_host00-lv_root is now 10042368 blocks long.
# lvdisplay /dev/vg_host00/lv_root
--- Logical volume ---
LV Path /dev/vg_host00/lv_root
LV Name lv_root
VG Name vg_host00
LV UUID DWRtz9-vmZt-tAXf-gaSS-Gf9b-6r8r-x3LRoX
LV Write Access read/write
LV Creation host, time host00.soluciones.si, 2022-04-01 18:05:17 +0200
LV Status available
# open 1
LV Size 38.31 GiB
Current LE 9807
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0