Production: 14.04LTS Linux -- End-User Drive Configuration using LVM

From Free Geek Toronto
Jump to: navigation, search

Contents

Manually Creating the LVM Partitions & Volumes

Original Source: Mint 17 Xfce: Web Development Workstation -- Manually Create the LVM Partitions & Volumes

This document contains Generic Summary Notes that provides a recommendation for how to setup LVM (Logical Volume Manager) for loading a Linux Operating System that is based on Ubuntu 14.04 LTS on the hard-drive of an End-User PC.



Tip:
This document uses both the Command Shell and the Root Command Shell. That is why when Terminal Commands are given below, the command prompt that is expected (ending either in $ or #) is at the beginning of each line – so do not copy & paste that 1st character.




Warning:
Doing the below will erase all data on the physical drive that GParted is used to setup! This should be done only once, when first loading Linux – as any reload would use the existing LVM Volumes, with the option to not Format/Erase the lts14-home (/home) user home directories.



Filesystem Root Name by Desktop and CPU Architecture

Note: The Volume Group name lts14 will be used for any Ubuntu 14.04 LTS base linux Distribution.


For Ubuntu 14.04 LTS based Linux operating systems, use one the following designations for the System Volume (the filesystem root), based on the Distribution, the Desktop, and the CPU architecture:

  • In the following sections, replace [root] with the appropriate system designation name:
    • Mint17Xfce32 ⇐ Mint 17 Xfce Desktop 32bit
    • Mint17Xfce64 ⇐ Mint 17 Xfce Desktop 64bit
    • Mint17Mate32 ⇐ Mint 17 Mate Desktop 32bit
    • Mint17Mate64 ⇐ Mint 17 Mate Desktop 64bit
    • Mint17Cinn32 ⇐ Mint 17 Cinnamon Desktop 32bit
    • Mint17Cinn64 ⇐ Mint 17 Cinnamon Desktop 64bit
    • Mint17KDE32 ⇐ Mint 17 KDE Desktop 32bit
    • Mint17KDE64 ⇐ Mint 17 KDE Desktop 64bit
    • UbuntuLTS32 ⇐ Ubuntu 14.04 LTS 32bit
    • UbuntuLTS64 ⇐ Ubuntu 14.04 LTS 64bit
    • XubuntuLTS32 ⇐ Xubuntu 14.04 LTS 32bit
    • XubuntuLTS64 ⇐ Xubuntu 14.04 LTS 64bit
    • UbuntuMate32 ⇐ Ubuntu Mate 14.04 LTS 32bit
    • UbuntuMate64 ⇐ Ubuntu Mate 14.04 LTS 64bit
    • LinuxLite32 ⇐ Linux Lite 2.0 32bit
    • LinuxLite64 ⇐ Linux Lite 2.0 64bit
  • Note: The above try to be descriptive names, that are 12 characters or less in length.


Depending on the hardware configuration that is to be used, follow either the single drive or the multi-drive instructions provided below:


Single Drive LVM Instructions

The below Partition and Volume sizes are assuming that at least an 80GB hard drive is used to do this.


Partition the Drive using GParted

... to create the /boot & Physical LVM partition

  • IF Linux was already installed on a "to be re-purposed" hard drive, stop using the swap partition so the drive can be repartitioned.
    • If Linux was installed using LVM → select the lvm2 pv partition → Partition >> Deactivate
    • if Linux installed w/o LVM → select the swap partition → Partition >> Swap off
  • Device >> Create Partition Table (This is what will cause all data on the HDD to be lost.)
  • Create a 2048MiB ext2 Primary Partition (to be used by /boot ... suggested label is bootlvm)
  • Create an lvm2 pv partition using the remainder of the drive space. (pv01 is a suggested Label for this.)

Using the top of window menu, it is now necessary to Select "Edit" >> "Apply All Operations" to actually make these changes to the Hard Drive.


Either leave GParted open until finished the below size calculation, or write down the size for the lvm2 pv Partition.


Calculate Space Available for the User Files

... on an end-user system, all remaining/available Drive Space is allocated for the User Files.

  • Use the Mint Menu to open the Calculator
  • In the Calculator enter the following to calculate the size for the /home volume:
    • Input the GiB size of the Physical Volume (lvm2 pv) shown by GParted
    • Subtract (-) 20 for the 20GiB System Partition
    • Subtract (-) the Physical RAM size (min. 2GiB)
  • This will Calculate (=) the available space for the user home directories (/home)

Either leave the Calculator open until finished creating the Logical Volumes, or write down this calculated size for User Files (/home).


Terminal Commands to Create the LVM Volumes

  • create & configure the Logical Volume Group & Logical Volumes using the root command shell

$ sudo su

  • create the Logical Volume Group
# blkid     # to confirm LVM2_member is on /dev/sda2
# vgcreate lts14 /dev/sda2

  • create the Logical Volumes
    • in the below, replace [nnn.n] with the (above) calculated number for the rest of the Drive Space
    • also replace [root] with the appropriate system designation name (provided by the top of page list).

# lvcreate -L 20G -n [root] lts14    # 20GiB Volume for the Linux OS
# lvcreate -L 2G -n swap lts14    # 2GiB Swap ... use RAM Size *IF* RAM > 2GiB
# lvcreate -L [nnn.n]G -n home lts14    # use rest of lvm2 pv for the User home directories

If the Hard Drive has too little space to create the home volume using the calulated size, you should get an error message something like this:

 Rounding up size to full physical extent 206.93 GiB
 Volume group "lts14" has insufficient free space (52974 extents): 52975 required.

When that happens, simply decrease the calculated size by .1G (or .01G), and try again.

# ls /dev/mapper    # should output the below

control  lts14-home lts14-[root]  lts14-swap

  • now format the (just created) Logical Volumes
# mkfs -t ext4 /dev/mapper/lts14-[root]
# mkfs -t ext4 /dev/mapper/lts14-home
# mkswap /dev/mapper/lts14-swap
# exit
$ exit


Multi-Drive Striped LVM Instructions

the multi-drive instructions would go here