Difference between revisions of "Logical Volume Management (LVM)"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) |
Rafahsolis (talk | contribs) |
||
| Line 28: | Line 28: | ||
= Resize LVM Logical Volumes & Filesystems = | = Resize LVM Logical Volumes & Filesystems = | ||
| + | == Enlarge == | ||
* Unmount the Logical Volume | * Unmount the Logical Volume | ||
/umount /PilafConverter | /umount /PilafConverter | ||
| Line 35: | Line 36: | ||
e2fsck -f /dev/pilaf/pilaf_converter | e2fsck -f /dev/pilaf/pilaf_converter | ||
resize2fs /dev/pilaf/pilaf_converter | resize2fs /dev/pilaf/pilaf_converter | ||
| + | * Mount again | ||
| + | mount /dev/pilaf/pilaf_converter /PilafConverter | ||
| + | == Shrink == | ||
| + | * Unmount the Logical Volume | ||
| + | /umount /PilafConverter | ||
| + | * Shrink (Requires a number of blocks) | ||
| + | e2fsck -f /dev/pilaf/pilaf_converter # to figure out the blocks we want to keep | ||
| + | resize2fs /dev/pilaf/pilaf_converter 104857600 | ||
| + | lvreduce -L40G /dev/pilaf/pilaf_converter | ||
* Mount again | * Mount again | ||
mount /dev/pilaf/pilaf_converter /PilafConverter | mount /dev/pilaf/pilaf_converter /PilafConverter | ||
Revision as of 10:29, 7 June 2018
https://www.howtoforge.com/linux_lvm
Creating LVMs
- Partition disks as Linux LVM with fdisk
- Prepare new partitions for LVM Example:
pvcreate /dev/sdb1 /dev/sdc1 /dev/sde1 # pvremove /dev/sdb1 /dev/sdc1 /dev/sde1 to revert pvdisplay # to show Physycal volumenes
- Create a volume group example 'pilaf':
vgcreate pilaf /dev/sdg1 /dev/sdf1 # vgremove pilaf to delete
- Check existing Volume Groups
vgdisplay vgscan
- Create logical volumes in volume group
lvcreate --name pilaf_copy --size 4T pilaf lvcreate --name pilaf_converter --size 4T pilaf
- Check existing logical volumes with:
lvdisplay / lvscan
- Rename logical volumes with
lvrename {volume_group} {old_name} {new_name} | example: lvrename pilaf pilaf_copy pilaf_raw
- Enlarge/reduce Logical volume with:
lvextend -L4.5T /dev/pilaf/pilaf_raw lvreduce -L4T /dev/pilaf/pilaf_raw
- Create the filesystems
mkfs.ext4 /dev/pilaf/pilaf_raw mkfs.ext4 /dev/pilaf/pilaf_converter
- Add /etc/fstab entries
/dev/pilaf/pilaf_raw /Pilaf ext4 rw,noatime 0 0 /dev/pilaf/pilaf_converter /PilafConverter ext4 rw,noatime 0 0
Resize LVM Logical Volumes & Filesystems
Enlarge
- Unmount the Logical Volume
/umount /PilafConverter
- Extend the Logical Volume
lvextend -L 4.5T /dev/pilaf/pilaf_converter
- Extend the filesystem
e2fsck -f /dev/pilaf/pilaf_converter resize2fs /dev/pilaf/pilaf_converter
- Mount again
mount /dev/pilaf/pilaf_converter /PilafConverter
Shrink
- Unmount the Logical Volume
/umount /PilafConverter
- Shrink (Requires a number of blocks)
e2fsck -f /dev/pilaf/pilaf_converter # to figure out the blocks we want to keep resize2fs /dev/pilaf/pilaf_converter 104857600 lvreduce -L40G /dev/pilaf/pilaf_converter
- Mount again
mount /dev/pilaf/pilaf_converter /PilafConverter