1

So I've had issues with Windows which forced me to install and learn Ubuntu as I'm fed up with MSFT. So now I need to know the most efficient/best way to image Ubuntu so that if I messed something up in one point in time I could always come back to the healthy point in time.

During the install I saw an option for LVM and read what it is though I don't know how to utilize it to prevent a situation where I have to reinstall everything. Help?

Note: I found on the right hand side of this Ask A Question area an area titled Similar Questions giving me Setting up LVM Snapshot as a backup/restore point in ubuntu

This is pretty in depth and a bit complex, though completely doable, is it possible to just use LVM out of the box after a complete HDD wipe and normal Ubuntu install? :Fingers crossed and rabbits foot in hand:

L2g2h
  • 52

1 Answers1

0

Yes, but you must do some CLI magic prior to launching the installer from the live cd.

Part 1:

  1. Boot the live cd/usb, and select the "Try Ubuntu" option.

    Note: unplug all USB storage devices not being used for the installation prior to booting. While not required, this precaution will help avoid disaster.

  2. Press "Super" key (Windows key), then search for and run "gparted."

  3. Once gparted is open, switch through the devices to identify which one is the USB flash drive from which you are booted (skip if booting from cd/dvd/bd and have no USB storage devices plugged in)

    For instance, I have identified /dev/sdc as my USB flash drive by the size (roughly 8GB): My usb drive in gparted

  4. Select the drive from which you wish to initiate the boot process, delete all partitions from it (you can use a right-click menu), and create a 500MB ext4 filesystem at the beginning of the partition.

    Note: I am creating these partitions on my USB drive for the sake of demonstration, but you want to create them on your primary boot storage device instead.

    Menu selection for new partition

    Note: After typing '500' into the "New size" field, I clicked the 'up arrow' next to the "Free space following" field once followed by a single click on the 'up arrow' next to the "New size" field to get a nice even 500MiB with the "Free space following" field automatically calcualted for me. It it is not really necessary to have exactly 500MiB here, though, so it won't hurt to be a few MiB off.

    enter image description here

  5. After this, use the remaining space on your primary boot drive to create a partition of type "lvm2 pv".

    enter image description here

  6. [Optional] - Select any additional disks that you would like to use for your Ubuntu installation, remove any existing partitions from it, and create a single "lvm2 pv" partition that spans the entire disk.

  7. Review your changes carefully, record the device names of the "lvm2 pv" partitions you created (i.e. '/dev/sda2' and '/dev/sdb1' in my case), then click "Apply" then "Apply" again in the popup window warning you that data loss may ensue.

I am using 2x250GB HDDs in my installation. Here is what they look like in gparted:

Note: My pictures show that I have "mount points" specified; ignore this for now, as you will decide such configuration later.

My sda: sda final

My sdb:

sdb final

Part 2:

  1. Press "Super" key, search for "Terminal" and open it.

  2. Run sudo vgcreate <vgname> <pv1> <pv2> to create a volume group using the "lvm2 pv" partitions that you created with the vgname of your choice. i.e. for me, assuming I wish to name my volume group ubuntuvg, it would be:

    sudo vgcreate ubuntuvg /dev/sda2 /dev/sdb1
    
  3. After the system reassures you that it has completed the task as requested, verify it yourself with sudo vgs. For me, this looks like this:

    [16:01:58][mgodby@mg-ws1 ~]$ sudo vgs
      VG     #PV #LV #SN Attr   VSize   VFree 
      centos   2   3   0 wz--n- 465.28g 50.00g
    

    Note: VG name says "centos" instead of "ubuntuvg" because it was created long before this tutorial was.

  4. Remaining conscious of the total size of your new volume group, you may now plot out your filesystems and sizes for them. If you have the space for it, I recommend the following methodology:

    • Create a LV for swap that is 8GB in size
    • Create a LV for / (name this one "root") that is 50GB in size
    • Create a LV for /home that is 100GB in size (or larger if you have a greater amount of personal files and folders to move onto the system after installation).

      Note: Resist the urge to use all of the space on your drives immediately because there is a beautiful command, lvextend, that will allow you to arbitrarily add unused space in the VG to any LV and extend the filesystem that it contains. i.e. if you run out of space on /home, you can simply lvextend -L +25G /dev/ubuntuvg/home -r (or something like that depending on what your vg and lv names are) to add 25GB to /home without offlining the filesystem.

      Assuming you chose "ubuntuvg" for your VG name:

      lvcreate -L 8G -n swap ubuntuvg
      lvcreate -L 50G -n root ubuntuvg
      lvcreate -L 100G -n home ubuntuvg
      
  5. Run sudo lvgs as a sanity check to see that your LVs were created successfully:

    Note: my "home" LV is actually 357GB since I have expanded it since my initial installation. This command should properly reflect a size of 150GB for "home" for you if you have followed the instructions exactly.

    [16:06:38][mgodby@mg-ws1 ~]$ sudo lvs
      LV   VG     Attr      LSize   Pool Origin Data%  Move Log Copy%  Convert
      home centos -wi-ao--- 357.39g                                           
      root centos -wi-ao---  50.00g                                           
      swap centos -wi-ao---   7.89g
    

Part 3:

  1. Click the icon for "Install Ubuntu 14.04.1 LTS" and begin the process.

  2. When you get to the screen labeled "Installation type", select "Something else" at the bottom, then click "Continue".

  3. Select the 500 MiB ext4 you created in Part 1, Step 4; click the "Change" button, then specify the following options before clicking "OK":

    • Use as: "Ext4 journaling file system"
    • 'check' the "Format the partition:" checkbox
    • Mount point: "/boot"
  4. Select each LV that you created and specify the options as follows (assumes VG name of "ubuntuvg"; substitute "ubuntuvg" with actual vg name if necessary):

    1. swap (/dev/mapper/ubuntuvg-swap)

      • Use as: "swap area"
    2. root (/dev/mapper/ubuntuvg-root)

      • Use as: "Ext4 journaling file system"
      • 'check' the "Format the partition:" checkbox
      • Mount point: "/"
    3. home (/dev/mapper/ubuntuvg-home)

      • Use as: "Ext4 journaling file system"
      • 'check' the "Format the partition:" checkbox
      • Mount point: "/home"
  5. Ensure that the "Device for boot loader installation" specifies your primary boot drive. For me, this was "/dev/sda".

  6. After reviewing your specified layout, click "Install Now" and reassure the system that you really meant what you said by clicking "Continue" on the popup window.

  7. Following the instructions for the remainder of the install, reboot, and enjoy!

MGodby
  • 1,172