Setup LVM On Linux Install

2 minute read

Description:

Setup LVM with LUKS Multi-Disk. For this lab I used 2 127 GB vhd’s using Hyper-V and Fedora 25 Gnome.

To Resolve:

1. Launch installer via Live USB image

  1. Select all your disks and choose the option to “encrypt my data” as well as “I will configure partitioning”.

  1. Click “done” and then enter the passphrase for your setup.

  2. Now on the next screen, we configure our disks:

 

NOTE: Rules

boot partition = /boot needs to be at least 250MB.

swap needs to be 1024 MB+ (for a 4GB VM). For best results, follow:

 

Amount of RAM in the System Recommended Amount of Swap Space
4GB of RAM or less a minimum of 2GB of swap space
4GB to 16GB of RAM a minimum of 4GB of swap space
16GB to 64GB of RAM a minimum of 8GB of swap space
64GB to 256GB of RAM a minimum of 16GB of swap space
256GB to 512GB of RAM a minimum of 32GB of swap space

 

Source: https://docs.fedoraproject.org/en-US/Fedora/13/html/Installation_Guide/s2-diskpartrecommend-x86.html

 

Paths reference:

root partition = /

/home = lvm ext4

/boot/efi standard – efi system partition 260mb

/ ext4 volumb group

/swap

 

Now we just create them:

  1. Create boot

 

  1. Create vg

 

 

  1. Create root

 

 

  1. Create swap

 

 

  1. Create home

 

 

And then we are done! Finish the installer.

 

Here is how to do it from command line although I haven’t actually done this:

# Steps to complete = Create physical volume, then volume groups, then logical volumes.

  1. First we want to see our current disk setup:
# Identify free disks
lsblk
pydf
blkid
fdisk -l
  1. Now we create a logical volume. Note that the disk should be blank.
fdisk /dev/sdb

n - new part
p - primary part
1 - first part on disk
t - change type
8e - lvm
p - preview
w - write changes

# Do same thing for each disk
  1. Now we create the disk:
pvcreate /dev/sdb1

#could also do pvcreate /dev/sdb1, /dev/sdb2 …

  1. Now create the Volume Group
vgcreate vgpool /dev/sdb1

# Could also do pvcreate /dev/sdb1, /dev/sdb2 …

lvcreate -L 3G -n lvstuff vgpool

# -L is size, -n is name, and vgpool is mentioned so that lvcreate knows where to get the space from
  1. Create a filesystem
mkfs -t ext3 /dev/vgpool/lvstuff - creates a file system
  1. Mount it
mkdir /mnt/stuff

mount -t ext3 /dev/vgpool/lvstuff /mnt/stuff

# Adding a new hard drive:

vgextend vgpool /dev/sdc1

# Tell it how much to extend by, should be 3+8 but really extends to 8.
lvextend -L +8G /dev/vgpool/lvstuff

# Actually expands to 11 GB instead of 8.
# lvextend -L+3G /dev/vgpool/lvstuff

# Now we extend our filesystem:

resize2fs /dev/vgpool/lvstuff