User Tools

Site Tools


Logical Volume Management

Date: Wed Oct 3 2018

These notes follow the steps outlined in our book (Soyinka), chapter 7, pp. 200-211:

If it helps:

  • Physical volume (the pv commands) are literally about the physical devices.
  • Volume group (the vg commands) organize the PVs and the LVs.
  • Logical volumes (the lv commands) -- here think about partitions


Login as root

$ su root

Gather information

Take a look at what you have before you start. Pay some attention to the details:

# lsblk
# fdisk -l

Create a Logical Partition

Note: parted is a program that manipulates disk partitions. Go ahead and read the man page on parted before you start.

# parted /dev/sda
(parted) print
(parted) mkpart
(parted) Partion type? primary/extended? primary
(parted) File system type? [ext2]? ext4
(parted) Start? 81.1GB
(parted) End? 100%
(parted) set 3 lvm on
(parted) print
(parted) quit 

Creating a Physical Volume

Note: read the man pages for pvdisplay and pvcreate before you start--just to bet a better idea, above and beyond what the book offers, of what the following two programs do.

# pvdisplay
# pvcreate /dev/sda3
# pvdisplay

Add a Physical Volume to a Volume Group

Usage note: vgextend VG PV. (See man page, of course :)

Therefore, below, volume group name is fedora and physical volume name is, per the last set of commands, /dev/sda3.

# vgdisplay
# vgextend fedora /dev/sda3
# vgdisplay

Creating a Logical Volume

Note: man pages!!!

# lvdisplay
# lvcreate -l 6285 --name var fedora
# lvdisplay /dev/fedora/var

Creating a File System for the LV

Formatting the disk: read the man pages, including man fstab. The restorecon command pertains to SELinux. We'll read about that later in the semester.

# mkfs.btrfs /dev/fedora/var
# mkdir /new_var
# mount /dev/fedora/var /new_var/
# cp -vrp /var/* /new_var/
# mv /var/ /old_var
# mkdir /var
# mount --bind /new_var/ /var/
# restorecon -R /var
# nano /etc/fstab

/dev/mapper/fedora-var /var btrfs defaults 1 2

# reboot
linux/logical-volume-management-set-up.txt · Last modified: 2019/01/21 11:16 by seanburns