Virtual machine with a Linux (a bit dated red hat distribution). There are 2 partition, one for /boot and second one for lvm. On the lv we have two lvs for root and swap (whoever came up with this…).
root (“/”) became muuuuuch, much to small and we have to get more space, fast. Called the VM admin, got more space in the vm. Usually you would now restart, boot into a LiveCD, resize everything, restart and everything’s fine. This wasn’t an option. So let’s see how we can do this while staying online:
#### rescan the disks to possibly detect new devices echo "- - -" > /sys/class/scsi_host/host0/scan #### rescan the disks to detect the changed size echo '1' > /sys/class/scsi_disk/0\:0\:0\:0//device/rescan #### add a 3rd partition and change type to Linux LVM (IMPORTANT!!) fdisk /dev/sda Command (m for help): p Disk /dev/sda: 17.1 GB, 17179869184 bytes 255 heads, 63 sectors/track, 2088 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1044 8281507+ 8e Linux LVM Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (1045-2088, default 1045): Using default value 1045 Last cylinder or +size or +sizeM or +sizeK (1045-2088, default 2088): Using default value 2088 Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): 8e Changed system type of partition 3 to 8e (Linux LVM) Command (m for help): p Disk /dev/sda: 17.1 GB, 17179869184 bytes 255 heads, 63 sectors/track, 2088 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1044 8281507+ 8e Linux LVM /dev/sda3 1045 2088 8385930 8e Linux LVM Command (m for help): w #### detect new 3rd partition partprobe -s /dev/sda: msdos partitions 1 2 3 #### create new pv on it pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created #### extend volume group by the new pv vgextend VolGroup00 /dev/sda3 Volume group "VolGroup00" successfully extended #### extend lv lvextend -l+100%FREE /dev/VolGroup00/LogVol00 Extending logical volume LogVol00 to 11.97 GB #### finally: extend filesystem resize2fs /dev/VolGroup00/LogVol00
Yeah, that’s about it. You might ask why didn’t I extended /dev/sda2 into the free space — partprobe couldn’t discover the change and I would had to restart the system in order to go on. And final remark: Don’t try this at home without first testing on a clone of the production system :-)