We create a volume group descriptor at the beginning of the disk.
|
1
|
pvcreate /dev/sdc
|
To create the volume group named test, use the command
|
1
|
vgcreate test /dev/sdc
|
If you want to include other disks or partitions in the volume group, then
|
1
|
vgcreate test /dev/sdc /dev/XXX
|
Your volume group test and logical volumes are in an inactive state; let's activate them.
Now for the most interesting part – creating logical volumes part1 and part2, each with a size of 10G.
|
1
2
|
lvcreate -L10000 -n part1 test
lvcreate -L10000 -n part2 test
|
Let's check:
|
1
2
3
|
lvscan
ACTIVE '/dev/test/part1' [9,77 GiB] inherit
ACTIVE '/dev/test/part2' [9,77 GiB] inherit
|
Now you can format the created partitions and mount them.
|
1
2
3
|
mkfs.ext4 /dev/test/part1
mkdir /part1
mount /dev/test/part1 /part1
|
Increasing the logical volume size to 20G
|
1
2
|
umount /dev/test/part1
lvextend -L20G /dev/test/part1
|
We have increased the logical volume; now it is necessary to increase the file system size.
|
1
|
resize2fs /dev/test/part1
|
Decreasing the logical volume size (you may lose data)
|
1
|
lvreduce -L-10G /dev/test/part1
|
Notes:
When decreasing or increasing the file system size, it must be unmounted.
When decreasing the size, the superblock or partition table may be corrupted.
The size of an XFS file system can only be increased while it is mounted.
It is not possible to decrease the size of an XFS file system.
Commands:
dd if=/dev/zero of=/dev/diskname bs=1k count=1 - to destroy the partition table.
vgcreate: Create a volume group.
vgchange -a y: Activate a volume group.
vgchange -a n: Deactivate a volume group.
vgremove: Remove a volume group.
vgextend: Add physical volumes to a volume group.
vgreduce: Remove physical volumes from a volume group.
vgdisplay: Display information about a volume group.
vgexport: Unregister a volume group from the system.
vgmerge: Merge volume groups.
vgrename: Rename a volume group.
vgs: Display information about volume groups.
vgscan: Scan for volume groups.
vgsplit: Move a physical volume to a new volume group.
vgck: Check the integrity of a volume group.
lvdisplay: Display information about created logical volumes.
lvcreate -LTTTG -nXXX: Create a logical volume XXX of size TTT.
lvchange: Change attributes of a logical volume.
lvremove: Remove logical volumes.
lvrename: Rename a logical volume.
lvextend -LXXG: Extend logical volumes.
resize2fs: Increase the size of the file system.
lvreduce -L-XXG: Reduce logical volumes.
lvresize: Change the size of a logical volume.
lvscan: List logical volumes in all volume groups.
lvs: Display information about logical volumes.
lvmdiskscan: List devices that can be used as physical volumes.
lvmsadc: Collect LVM usage activity data.
lvmsar: Generate an LVM usage activity report.
pvcreate: Create a volume group descriptor area at the beginning of a disk.
pvdisplay: Display information about physical volumes.
pvmove: Move content from one disk to another.
pvremove: Remove the LVM label from a physical volume.
pvresize: Change the size of a physical volume.
pvchange: Change attributes of a physical volume.
pvdata: Display information about a physical volume.
pvs: Display information about physical volumes.
pvscan: List all physical volumes.
