This is the part 2 of extending a Linux LVM volume. See part 1 when the entire disk as a PV.
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 next available partition number
- n - add a new parition
- p - primary partition
- <X> - partition number, enter the next available partition number from the previous p - print the partition table command
- default - the begining of the free cylinder
- default - the last of the free cylinder
- t - change a partition’s system id
- <X> - partition number, enter the next available partition number from the previous p - print the partition table command
- 8e - Linux LVM
- w - write table to disk and exit
- fdisk -l to verify the new partition
- 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?”
- Initializ the disk partition
- pvcreate </dev/sdb3>
- Extend the VG
- use vgdispaly to determine the volume group name
- vgextend <volume_group_name> </dev/sdb3>
- 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