Lets consider we have 2 disks /dev/sdb1 and /dev/sdb2 of 10G each.
Creating Physical Volumes
pvcreate /dev/sdb1 /dev/sdb2
Creating Volume Manager
vgcreate myvol /dev/sdb1 /dev/sdb2
Creating Logical Volume
lvcreate -L 5G -n tools myvol
Applying File System
mkfs -t ext4 /dev/myvol/tools
Mounting the file system
mkdir /tools
mount -t ext4 /dev/myvol/tools /tools
To make the mount persistent over boot.
vi /etc/fstab
/dev/myvol/tools /tools ext4 defaults 0 0
To check the mounted partition
df -h
To check the physical volumes
pvs
To check the volume managers
vgs
To check the logical volumes
lvs
To view the details of a physical volume
pvdisplay /dev/sdb1
To view the details of a volume group
vgdisplay myvol
To view the details of a logical volume
lvdisplay tools
To extend the logical volume on the fly
lvextend -L +8G /dev/myvol/tools
resize2fs /dev/myvol/tools
To check the change
lvs
df -h
To reduce the logical volume
umount -v /tools
e2fsck -ff /dev/myvol/tools
resize2fs /dev/myvol/tools 10G
lvchange -an /dev/myvol/tools
lvreduce -L 10G /dev/myvol/tools
lvchange -ay /dev/myvol/tools
mount -a
To check the change
lvs
df -h
To remove a physical volume from volume manager
vgreduce myvol /dev/sdb2
To remove the complete logical volume
umount /tools
rm -f /tools
vi /etc/fstab (Remove the below entry)
/dev/myvol/tools /tools ext4 defaults 0 0
lvchange -an /dev/myvol/tools
lvremove /dev/myvol/tools
To remove the Volume Manager
vgremove myvol
To remove the Physical Volumes
pvremove /dev/sdb1 /dev/sdb2
To add a physical volume to the volume manager
vgextend myvol /dev/sdc1
Creating Physical Volumes
pvcreate /dev/sdb1 /dev/sdb2
Creating Volume Manager
vgcreate myvol /dev/sdb1 /dev/sdb2
Creating Logical Volume
lvcreate -L 5G -n tools myvol
Applying File System
mkfs -t ext4 /dev/myvol/tools
Mounting the file system
mkdir /tools
mount -t ext4 /dev/myvol/tools /tools
To make the mount persistent over boot.
vi /etc/fstab
/dev/myvol/tools /tools ext4 defaults 0 0
To check the mounted partition
df -h
To check the physical volumes
pvs
To check the volume managers
vgs
To check the logical volumes
lvs
To view the details of a physical volume
pvdisplay /dev/sdb1
To view the details of a volume group
vgdisplay myvol
To view the details of a logical volume
lvdisplay tools
To extend the logical volume on the fly
lvextend -L +8G /dev/myvol/tools
resize2fs /dev/myvol/tools
To check the change
lvs
df -h
To reduce the logical volume
umount -v /tools
e2fsck -ff /dev/myvol/tools
resize2fs /dev/myvol/tools 10G
lvchange -an /dev/myvol/tools
lvreduce -L 10G /dev/myvol/tools
lvchange -ay /dev/myvol/tools
mount -a
To check the change
lvs
df -h
To remove a physical volume from volume manager
vgreduce myvol /dev/sdb2
To remove the complete logical volume
umount /tools
rm -f /tools
vi /etc/fstab (Remove the below entry)
/dev/myvol/tools /tools ext4 defaults 0 0
lvchange -an /dev/myvol/tools
lvremove /dev/myvol/tools
To remove the Volume Manager
vgremove myvol
To remove the Physical Volumes
pvremove /dev/sdb1 /dev/sdb2
To add a physical volume to the volume manager
vgextend myvol /dev/sdc1
No comments:
Post a Comment