Linux - Extending a logical volume in a virtual machine running Red Hat or Cent OS whithout reboot
With the step by step below you can extend your logical volume without a reboot.
First find your device
ls
/sys/class/scsi_device/
Than find your disk
fdisk
-l
With this information you can scan the device to detect the new size:
echo 1 >
/sys/class/scsi_disk/0:0:0:0/device/rescan
echo 1 >
/sys/block/sda/device/rescan
*Change 0:0:0: acoording to your scsi device and sda acoording your disk
fdisk -l to see your new size.
Now you have to create a new partition:
fdisk -l /dev/sda (change the disk acoording your necessity)
Than create a new primary
partition:
fdisk /dev/sda
Press p to print the partition table to
identify the number of partitions. By default, there are 2: sda1 and sda2.
Press n to create a new primary partition.
Press p for primary.
Press 3 for the partition number, depending
on the output of the partition table print.
Press Enter two times.
Press t to change the system's partition
ID.
Press 3 to select the newly creation
partition.
Type 8e to change the Hex Code of the
partition for Linux LVM.
Press w to write the changes to the
partition table.
The reboot is not
needed as you can also rescan for those partitions using partprobe. Run the
following to scan for the newly created partition.
partprobe -s
Extend
your Logical Volume with the new partition
pvcreate
/dev/sda3
Type vgdisplay to get your VG.
--- Volume group ---
VG Name centos
...
Extend your VG:
vgextend
centos /dev/sda3
Get your LV
lvs
Extend your LV
lvextend /dev/centos/root /dev/sda3
Resize your disk:
resize2fs
/dev/centos/root
*If you got an error
like this, it may mean your filesystem is XFS instead of standard ext2/ext3
then use:
xfs_growfs
/dev/mapper/centos-root
Comments
Post a Comment