Difference between revisions of "Adding and extending disks/volumes in LVM"
From Tech-Wiki
(4 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
In order to use LVM, the partition must be '''type 8e''' instead of 83 when created by fdisk. | In order to use LVM, the partition must be '''type 8e''' instead of 83 when created by fdisk. | ||
+ | |||
+ | Expand the disk size in your Hypervisor and reboot the linux server. | ||
+ | |||
+ | Create a new partition at the end of the disk: | ||
+ | |||
+ | # fdisk /dev/sdb | ||
+ | Press p to print the partition table to identify the number of partitions. | ||
+ | Press n to create a new primary partition. | ||
+ | Press p for primary. | ||
+ | Press 1 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. | ||
Create new PV (Physical Volume) using following command: | Create new PV (Physical Volume) using following command: | ||
Line 10: | Line 25: | ||
# vgdisplay | # vgdisplay | ||
− | Extend the volume group in a new | + | Extend the volume group in a new partition: |
# vgextend vg_root /dev/sdb1 | # vgextend vg_root /dev/sdb1 | ||
− | This can be used to span this volume across a second disk | + | This can also be used to span this volume across a second disk |
Check the new size: | Check the new size: | ||
Line 18: | Line 33: | ||
# pvscan | # pvscan | ||
− | Get the current available size using: | + | Get the current available size and logical volume name using: |
− | + | ||
# vgdisplay | # vgdisplay | ||
+ | # lvdisplay | ||
Increase the size of this logical volume using: | Increase the size of this logical volume using: | ||
Line 29: | Line 44: | ||
# resize2fs /dev/vg_root/vol1 | # resize2fs /dev/vg_root/vol1 | ||
− | + | Check the new current size used again size using: | |
− | + | ||
# vgdisplay | # vgdisplay | ||
+ | # lvdisplay |
Latest revision as of 17:26, 19 August 2018
In order to use LVM, the partition must be type 8e instead of 83 when created by fdisk.
Expand the disk size in your Hypervisor and reboot the linux server.
Create a new partition at the end of the disk:
# fdisk /dev/sdb Press p to print the partition table to identify the number of partitions. Press n to create a new primary partition. Press p for primary. Press 1 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.
Create new PV (Physical Volume) using following command:
# pvcreate /dev/sdb1
Verify the volume:
# pvs # vgdisplay
Extend the volume group in a new partition:
# vgextend vg_root /dev/sdb1
This can also be used to span this volume across a second disk
Check the new size:
# vgs # pvscan
Get the current available size and logical volume name using:
# vgdisplay # lvdisplay
Increase the size of this logical volume using: (if the volume has already grown using all the space in the new disk, this is not required)
# lvextend -L +100G /dev/vg_root/vol1
In addition, it's required to increase the file system in this logical volume as well:
# resize2fs /dev/vg_root/vol1
Check the new current size used again size using:
# vgdisplay # lvdisplay