User Tools

Site Tools


linux:logical-volume-management-set-up

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux:logical-volume-management-set-up [2019/01/21 11:16] (current)
seanburns created
Line 1: Line 1:
 +<​markdown>​
 +# Logical Volume Management
 +## Date: Wed Oct 3 2018
  
 +These notes follow the steps outlined in our book ([Soyinka][1]),​ 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
 +
 +## Procedure:
 +
 +### Login as root
 +
 +```bash
 +$ su root
 +```
 +
 +### Gather information
 +
 +Take a look at what you have before you start. Pay some attention to the
 +details:
 +
 +```bash
 +# 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.
 +
 +```bash
 +# 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.
 +
 +```bash
 +# 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**.
 +
 +```bash
 +# vgdisplay
 +# vgextend fedora /dev/sda3
 +# vgdisplay
 +```
 +
 +### Creating a Logical Volume
 +
 +Note: man pages!!! ​
 +
 +```bash
 +# 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.
 +
 +```bash
 +# 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
 +
 +```bash
 +# reboot
 +```
 +
 +[1]:​https://​www.amazon.com/​Linux-Administration-Beginners-Guide-Seventh/​dp/​0071845364
 +</​markdown>​
linux/logical-volume-management-set-up.txt ยท Last modified: 2019/01/21 11:16 by seanburns