1

I've just installed Ubuntu on a new machine and while I usually go for the classic partitioning, I decided to use (default) LVM this time as the idea of creating volume snapshots was quite appealing. (moreover, I chose whole system encryption)

However, after the default install I ended up with only 2 logical volumes (swap and root) and am unable to take snapshots. The first question therefore is:

Q1: What is the point of such default LVM setup in Ubuntu?

While the inability to take snapshots is probably easy to solve, it seems to me it would not be of much use unless I create another logical volumes (e.g. one for /home) as I don't want the snapshot to include files in /home folder. The second question then is:

Q2: What is the good way of creating another logical volume, assigning it a mount point and moving files into it?

Note #1: My user's home is encrypted as well.

Note #2: While I did find several tutorials regarding use of LVM, this topic is not covered in any of them.

1 Answer 1

1

STANDARD DISCLAIMER: I HAVE NOT TESTED THIS. USE AT YOUR OWN RISK. YOUR RESULTS MAY VARY. I AM NOT RESPONSIBLE FOR ANY DATA LOSS YOU MAY INCUR. MAKE SURE YOU HAVE BACKUPS OF ANY CRITICAL DATA BEFORE ATTEMPTING THIS PROCEDURE.

Q.1: You will need to leave some free space in your VG if you plan on snapshotting.

Q.2: You can create a new LV to use for /home in the same VG. If you already allocated the entire disk to the root LV, you will need to resize it first to generate unallocated space for your new /home LV (and space for snapshots if you plan on using that capability). You can do this from a live USB flash drive.

  • Once booted from the live USB medium, you will need to manually unlock the LUKS container to access the LVs. (See man cryptsetup.)
  • After you resize the root LV (See man lvreduce.) and create your new /home LV (See man lvcreate.), format your new /home LV and then mount the two LVs at a temporary location in your live filesystem (such as /mnt/root & /mnt/home).
  • You can then mirror your original /home filesystem to the new /home LV using rsync (from /mnt/root/home to /mnt/home).
  • Update the fstab on the root LV to mount the new LV at /home. Remove the contents of the original /home folder (*sudo rm -rf /mnt/root/home/**), making sure to leave the empty folder as the mount point for your new /home LV.
  • You should then be able to reboot from the live USB into your installed system which will now have separate root and /home LVs.

Further reading: How can I resize an LVM partition? (i.e: physical volume)

1
  • +1 for the second answer. I'll give it a try. As for your first answer, I was rather interested why by default Ubuntu creates only 2 logical volumes without ability to take snapshots. It seems to me useless after default installation so I was curious if there is some deeper reasoning for this.
    – tmt
    Aug 13, 2014 at 7:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .