1

To add some context to my question, the majority of my experience is with Mac OS X. The default installation process in modern versions of Mac OS X, for volumes on which Mac OS X is already installed, is an "archive and install." Booting from installation media preserves data on the target volume while simply "over-installing" the operating system.

I am hoping to fully understand how Ubuntu 12.04 will handles re-installations under certain conditions: particularly where /var resides on a separate volume.

In my case, I have a 2 physical disks in a software RAID 1. On top of the RAID are 3 LVM partitions mounted at /, swap, and /var. My logic for placing /var on a separate volume is that this server will run libvert/KVM and the most critical data will be my VM's stored in /var. I wanted the ability to easily reinstall the OS without destroying my most critical data.

In the event that I damage my OS installation and need to recover, if I boot to the Ubuntu 12.04 live USB and simply run the installer without repartitioning or erasing any volumes, will /var be overwritten? Are only /boot overwritten? How does the re-installation process work?

1

/var is only a directory, as is /boot or /home. If you want to reinstall your OS, the installation routine will ask you on which device it should be installed. While your disk is already set up as a software RAID with LVM on top now, the installation routine know nothing of this setup - yet. There are some guides available on help.ubuntu.com on how to deal with both RAID and LVM during installation.

If you don't want your current /var (or any other directory) overwritten, you have to make sure NOT to install onto a device backing those directories. I.e. if /var is currently backed by /dev/vg0/lv3 - don't install to this device during installation. However, when you setup LVM during installation, these names might change so it's advisable to work with UUIDs. As your (old) system is still running and let's say /var is backed by /dev/vg0/lv3:

$ sudo blkid
[...]
/dev/vg0/lv3: UUID="2fb55128-1105-4a07-a93c-bbab8fbd8066" TYPE="xfs"

If you managed to reanimate your LVM setup during the install routine, this UUID should show up when you run blkid during installation - with the device name in front of it. Now you know not to install to that device, as this contained your /var partition.

In any case and whatever tricks you attempt to recover your old setup: please do a backup before doing anything! And verify if the backup is working.

  • Understood, a follow up question: Assume that the / is backed by /dev/vg0/lv1 and /var is backed by /dev/vg0/lv2, I tell the installer to install onto /dev/vg0/lv1 which is mounted at /. If one was installing onto one monolithic volume, top level directories such as /boot, /home, /etc, /var, and so on would be created beneath / and would contain default files and directories for the fresh install. If /var exists already when I point the installer to install to / which is backed by /dev/vg0/lv1 - is /var left alone or does the installer want to create a fresh dir? – sardean Jan 29 '14 at 3:43
  • 1
    Again, just to make sure this is understood: during install, /dev/vg0/lv1 will most likely not be mounted at /.And yes, if the new OS is installed to e.g. /dev/vg0/lv1, then it will contain everything a Unix OS usually has, including a new /var - your old "/var" will hopefully be still untouched in /dev/vg0/lv3 (to stick with that example) and once your new OS is running you should be able to mount /dev/vg0/lv3 to e.g. /var_old or whereever you like. You could also mount it to e.g. /vm and put a symlink to /vm in /var. Hope that wasn't too confusing. – ckujau Jan 29 '14 at 4:00
  • that provided a lot of clarification. I guess the point of greatest confusion for me is the way LVM configuration is presented during the install. When a LVM partition is created it gives you the option to "mount at..." there are several predefined options including /var. So, if I understand this correctly, it would simply take the device, such as /dev/vg0/lv2, and mount it to the specified path? How does it do this? Does it just inject a mount instruction into fstab? I appreciate your explanation. – sardean Jan 29 '14 at 4:24
  • 1
    The tricky part will be not to create but to re-create your LVM setup during the installation routine. As Ubuntu offers to install on LVM devices, I'd assume that all necessary LVM tools are installed so that one can ALT+Fn during install to try to get the original LVM config back online. If the LVM device is set up, the installer will "see" the device and will offer to install and should take care of /etc/fstab and bootloader configuration. I don't see why the installer would require you to "mount" anything manually, as that's the installer's job. – ckujau Jan 29 '14 at 5:10
  • 1
    I was curious enough myself and tried this myself: installed Ubuntu, / and /var as LVM. Then I booted the install CD again and the Ubuntu installer would find the LVM volumes all by itself. Now I answered the installer only to install to vg0/root (and sda1 for /boot) and left vg0/var alone: imgur.com/K7f3sEB - later on when ubuntu is installed (again), I'll be able to mount vg0/var to wherever I want. – ckujau Jan 29 '14 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.