This is the part 3 of extending a Linux LVM volume. see part 1 and part 2.
This part 3 is similar to part 2 when the partition as a PV. Instead of creating a new partition on the free disk space (like in part 2), delete the last partition on the disk and recreate it. This is useful when all the primary partitions (1 - 4) are already in use.
Extend a LVM when the partition as a PV
-
Increase the VM’s hard disk size in vSphere Client
- If there is a VM snapshot on the disk, its size cannot be changed. Remove all the snapshots first
- After increasing the disk size, take a snapshot as the backup
- Rescan the SCSI bus to verify the OS see the new space on the disk
- ls /sys/class/scsi_host/
- echo “- - -“ > /sys/class/scsci_host/<host_name>/scan
- tail -f /var/log/message
- or
- ls /sys/class/scsi_disk/
- each ‘1’ > /sys/class/scsi_disk/<0\:0\:0\:0>/device/rescan
- tail -f /var/log/message
- fdisk -l
- Prepare the disk partition
- fdisk -l
- fdisk </dev/sdb>
- p - print the partition table, note the last partition number in use
- d - delete parition
- p - primary partition
- <X> - partition number, enter the last partition number from the previous p - print the partition table command
- n - add a new partition
- p - primary partition
- <X> - partition number, enter the partition number was deleted in the previous step
- default - the begining of the cylinder in the original partition
- default - the last of the free cylinder
- t - change a partition’s system id
- <X> - partition number, enter the partition number was recreated in the previous step
- 8e - Linux LVM
- w - write table to disk and exit
- fdisk -l to verify the new partition size
- Update partition table changes to kernel
- reboot
- or partprobe </dev/sdb>
- Update (04/18/2016): In RHEL 6, partprobe will only trigger the OS to update the partitions on a disk that none of its partitions are in use (e.g. mounted). If any partition on a disk is in use, partprobe will not trigger the OS to update partition in the system because it it considered unsafe in some situations. So a reboot is required. see “How to use a new partition in RHEL6 without reboot?”
- Resize the PV
- pvresize </dev/sdb3>
- Verifty the VG automatically sees the new space
- vgs
- Extend the LV
- lvextend -l +100%FREE</dev/volume_group_name>/<logical_volume_name>
- or lvextend -L+<size> /dev/<volume_group_name>/<logical_volume_name>
- lvs
- Resize the file system
- resize2fs /dev/<volume_group_name>/<logical_volume_name>
- df -h
- Remove the VM snapshot once confirming the data intact
No comments:
Post a Comment