Logical Volume Management notes.
1.
Tools needed :
sudo
apt-get install lvm2 dmsetup mdadm reiserfsprogs xfsprogs
2.
Layout explanation:
LVM
consists of multiple drives, which make up a “Volume Group”.
Volume
Group, can be divided into Logical Volumes.
Simple : You join
many different disks in one and then you can cut,splice & glue it back.
3.
LVM Setup
#
List disks in system.
sudo
fdisk -l | grep GB
Disk
/dev/sda: 107.4 GB, -system
Disk
/dev/sdb: 107.4 GB, -newly added
Disk
/dev/sdc: 107.4 GB, -newly added
# Find newly added
disks without partition table.
sudo
fdisk -l | grep doesn
Disk
/dev/sdb doesn't contain a valid partition table
Disk
/dev/sdc doesn't contain a valid partition table
# Partition drives.
sudo
echo -e "n\np\n1\n\n\nt\n8e\nw" | fdisk /dev/sdb
sudo
echo -e "n\np\n1\n\n\nt\n8e\nw" | fdisk /dev/sdc
4.
Prepare partitioned
drives for Volume Group.
sudo
pvcreate /dev/sdb1 /dev/sdc1
# Display prepared partitions.
sudo
pvdisplay
5. Create Volume Group
#
nas
is used as name for Volume Group
sudo
vgcreate nas /dev/sdb1 /dev/sdc1
6.
Display newly
created Volume Group.
sudo
vgdisplay
7.
Create logical
volumes on the volume group nas.
sudo
lvcreate --name share --size 20G nas
sudo
lvcreate --name music --size 20G nas
8. Create filesystem on logical volumes.
sudo
mkfs.ext4 /dev/nas/share -q
sudo
mkfs.ext4 /dev/nas/music -q
9.
Mount logical
volumes.
#
Create mount point for logical volumes.
sudo
mkdir /var/share /var/music
#
Mount logical volumes to created mount points.
{
sudo
mount /dev/nas/share /var/share ;
sudo
mount /dev/nas/music /var/music ;
}
10.
Useful LVM commands.
#
Display logical volumes.
lvdisplay
#
Remove logical volume.
{sudo
umount /dev/nas/share ; sudo lvremove /dev/nas/share ;}
#
Extending a logical volume size.
sudo
lvextend -r --size +20G /dev/nas/share
#
Reducing a logical volume
sudo
lvreduce -r --size -10G /dev/nas/share
0 comments :
Post a Comment
Comment: