CentOS 7Installation Post installation tasks Join Active Directory SELinux Configuration Install Cockpit Create a Logical Volume (1) Create a Logical Volume (2) Creating an iSCSI Target (1) Creating an iSCSI Target (2) Creating an iSCSI Client Installing a Samba Server Installing an Apache Server Installing an NFS Server Installing a TFTP Server Installing KVM/QEMU Hypervisor Compiling Bacula Backup (1) Compiling Bacula Backup (2)
Debian 8Installation Post installation tasks Join Active Directory Installing an Apache Server Installing a Samba Server
Ubuntu 16Post installation tasks Join Active Directory Installing Apache/Samba Servers
Linux Commandsfdisk + LVM htop vi - line numbering
To show how it works I am using the following hard drives, 1 x 500GB + 4 x 1TB. This of course can be done with any number from 2 upwards. The eventual usage of the logical volume(s) will be for iSCSI targets.
To create logical volumes (virtual disks) we will use Logical Volume Manager (LVM2) which has three basic stages:
pv = a block device such as a partition or whole disk
vg = a pool of physical volumes from which logical volumes can be created
lv = a division (partition) of a volume group
We need to know which physical hard drives are available to create a storage pool and subsequent logical volumes by issuing the following command
/dev/centos/root [ 50.00 GiB] /dev/sda1 [ 500.00 MiB] /dev/centos/swap [ 7.88 GiB] /dev/sda2 [ 465.27 GiB] LVM physical volume /dev/centos/home [ 1.31 TiB] /dev/sdb [ 931.51 GiB] LVM physical volume /dev/sdc [ 931.51 GiB] /dev/sdd [ 931.51 GiB] /dev/sde [ 931.51 GiB] 6 disks 1 partition 1 LVM physical volume whole disks 1 LVM physical volume
The printout tells me that there are 6 disks, however there are only 5 whole hard drives, this is because /dev/sda is split into 2 partitions (/dev/sda1 and dev/sda2), the other 4 hard drives are /dev/sdb, /dev/sdc, /dev/sdd and /dev/sde.
/dev/sda2 is a logical volume created during installation which has 3 partitions /root (50GB), /swap (7.88GB) and /home (407.39GB), /home has been extended by adding /dev/sdb (931.51GB) as you can see above
There are 3 disks available /dev/sdc, /dev/sdd and /dev/sde.
We can now begin the process of creating a logical volume, firstly we must initialize the disks by creating physical volumes (pv) with the following command
just 1 command to create (initialise) 3 physical volumes (no multiple mouse actions), now we can use the following to list the new LVM2 volumes
PV /dev/sda2 VG centos lvm2 [465.27 GiB / 0 free] PV /dev/sdb VG centos lvm2 [931.51 GiB / 0 free] PV /dev/sdc lvm2 [931.51 GiB] PV /dev/sdd lvm2 [931.51 GiB] PV /dev/sde lvm2 [931.51 GiB] Total: 5 [4.09 TiB] / in use: 2 [1.36 TiB] / in no VG: 3 [2.73 TiB]
As we can see there are 3 physical disks that are in no Volume Group, so let's add them to a volume group called volume01 (or any naming convention you wish)
--- Volume group --- VG Name volume01 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 3 Act PV 3 VG Size 2.73 TiB PE Size 4.00 MiB Total PE 715401 Alloc PE / Size 0 / 0 Free PE / Size 715401 / 2.73 TiB VG UUID HvBtrf-5iMG-e1LZ-B6BK-gKqu-faki-UNTpHF
The volume group or storage pool has been created. Now we can create our logical volume (virtual disk), the following command will create a logical volume named (-n) iscsi01 using 100% of the FREE physical extents on volume01 (-l = use extents to size volume).
WARNING: xfs signature detected on /dev/volume01/iscsi01 at offset 0. Wipe it? [y/n]: y Wiping xfs signature on /dev/volume01/iscsi01. Logical volume "iscsi01" created.
The last command created a logical volume that spanned all available space on all 3 physical volumes in the volume group.
But perhaps we might want to create 2 logical volumes of 1.2TB and 800GB. To achieve this we will reuse the volume group volume01, we can remove the logical volume with the following command (as this a new creation there is no data on the the volume so it can be removed without problem).
Now we can create the two logical volumes
Use a capital -L when creating size in MB, GB etc...
Use a lowercase -l when creating extents (number or percentage).
If you use vgdisplay the printout will show that there is 794GB free, this could be used to create another logical volume or left available if either iscsi01 or iscsi02 needed to be extended. In fact let us extend iscsi01 by 200GB as follows
Use lvs or lvscan or lvdisplay to check the new size of iscsi01.
There is a good Cheat Sheet here of the common commands and attributes of Logical Volume Manager.
And of course if you want know everything about LVM you can download a PDF that I found on Red Hat