Installing Ubuntu 8.04 on LVM2

[ Wednesday, 7 May 2008, MAcks ]

Ubuntu 8.04 in desktop edition does not handle installation on LVM2 partitions. In this article we are going to show how to achieve this with just a little bit of command line hacking.

LVM is a logical volume manager for Linux which features a few important benefits compared to standard BIOS partitions (after Wikipedia):

  • Resize volume groups online by absorbing new physical volumes (PV) or ejecting existing ones.
  • Resize logical volumes online by concatenating extents onto them or truncating extents from them.
  • Create read-only snapshots of logical volumes (LVM1).
  • Create read-write snapshots of logical volumes (LVM2).
  • Stripe whole or parts of logical volumes across multiple PVs, in a fashion similar to RAID0.
  • Mirror whole or parts of logical volumes, in a fashion similar to RAID1.
  • Move online logical volumes between PVs.
  • Split or merge volume groups in situ (as long as no logical volumes span the split). This can be useful when migrating whole logical volumes to or from offline storage.

The article assumes that you have some basic knowledge of GNU/Linux, are not afraid of using command line and you have already created a volume group called lvUBUNTU. More information about LVM for ambitious beginners can be found in a comprehensive LVM HOWTO.

Let’s assume the following configuration:

  1. /boot (primary BIOS partition, about 500-600 MB),
  2. volume group lvUBUNTU with the following volumes: ubuntu-home, ubuntu-root, ubuntu-swap.

The installation is started by booting from an Ubuntu 8.04 Desktop LiveCD and installing the LVM2 support:

$ sudo -i
# modprobe dm-mod
# apt-get install lvm2

Now let’s activate the previously created volumes:

 # lvs

LV          VG       Attr   LSize  Origin Snap%  Move Log Copy%
ubuntu-home lvUBUNTU -wi--o 84,34G
ubuntu-root lvUBUNTU -wi--o  6,00G
ubuntu-swap lvUBUNTU -wi--o  1,67G

# lvchange -a y lvUBUNTU

# lvs
LV          VG       Attr   LSize  Origin Snap%  Move Log Copy%
ubuntu-home lvUBUNTU -wi-ao 84,34G
ubuntu-root lvUBUNTU -wi-ao  6,00G
ubuntu-swap lvUBUNTU -wi-ao  1,67G

Logical volumes are now made accessible to the installer.

You can now install Ubuntu normally. This is particularly easy so we’ll skip this step. After the successful installation, you need to make the system bootable, as the installed initrd provides no LVM support.

Reboot your computer and boot from the Live CD again. Repeat the first couple of steps (but do not install Ubuntu again :P) and then let’s eventually install the LVM on your hard drive for good:

# sudo -i
# modprobe dm-mod
# apt-get install lvm2
# lvchange -a -y lvUBUNTU
# cd /mnt
# mkdir ubuntu-root
# mount /dev/lvUBUNTU/ubuntu-root ubuntu-root
# mount /dev/XXX ubuntu-root/boot
# ## warning: replace XXX with the actual name of your boot partition!
# mount -o bind /proc ubuntu-root/proc
# mount -o bind /dev ubuntu-root/dev
# cp /etc/resolv.conf ubuntu-root/etc
# chroot ubuntu-root

# ## let's check the contents of /boot just to be sure we're in the correct root
# ls /boot
abi-2.6.24-16-generic
config-2.6.24-16-generic
grub
initrd.img-2.6.24-16-generic
memtest86+.bin
System.map-2.6.24-16-generic
vmlinuz-2.6.24-16-generic

# apt-get install lvm2
# exit
# umount ubuntu-root/boot
# umount ubuntu-root/proc
# umount ubuntu-root/dev
# umount ubuntu-root
# exit

The system should now be bootable from your LVM. You can easily check that out after rebooting :)

Hope this article helped you set up your Ubuntu on LVM. In case of questions — there is a comment form just below. Please ask for LVM-specific things, questions regarding Ubuntu itself will be ignored by default.

Translated by michuk

Subscribe to RSS feed for this article!

14 Comments

fold this thread yungchin  Tuesday, 13 May 2008 o godz. 11:15 pm #  Add karma Subtract karma  +0

This is a cool solution, but if you want to get away with a little less work: the alternate-installer has built-in LVM2 support.

fold this thread michuk  Wednesday, 14 May 2008 o godz. 12:29 am #  Add karma Subtract karma  +0

Sure it is. It’s just a bit slower and this article is specifically targetted at people who just have the Live CD but still want to have Ubuntu installed on LVM2.

 
fold this thread Anonymous  Wednesday, 20 May 2009 o godz. 8:49 am #  Add karma Subtract karma  +0

Another reason why this info is useful:

I installed Jaunty, but had problems with various hardware drivers, so I wanted to revert to my hardy install (which I had previously backed up using rsync)…

I reduced the ext3 partition and then the logical volume that jaunty was installed on (both were created by the jaunty installer), made a new LV and ext3 fs on it, using the newly freed space, rsynced my hardy install back to that, edited the fstab and grub menu, then followed the above instructions to ensure hardy would boot….

And it does! Thanks Macks!! Now I can continue to use my hardy install while jaunty is waiting on fixes :)

 
 
fold this thread Chango  Tuesday, 20 May 2008 o godz. 10:23 am #  Add karma Subtract karma  +1

2nd lvmchange says “-a -y”, it should say “-a y” like the first one.

Great guide!

 
fold this thread Jeff Wilson  Thursday, 26 June 2008 o godz. 7:06 pm #  Add karma Subtract karma  +1

Wow, this article saved me. I’d previously install Hardy with the alternate installer using the guided method to create an encrypted LVM. Well I decided the other day to resize my root partition in my lvm to make room to install ubuntu studio along side vanilla ubuntu. I managed to resize the volume but couldn’t figure out how to get my ubuntu studio installer (which is identical to the alternate installer) to recocognize my LVM logical volumes. After googling around I found this article. The thing I had missed was “lvchange -a y lvUBUNTU” (or in my case the lvm is JewJitsu).

A note in case anyone else runs across this, if you want to install to an existing ENCRYPTED LVM, you can follow this same process, all you have to do is run “cryptsetup luksOpen /dev/sdaX sdaX_crypt” and enter your encryption password. From there your LVM physical volume will be located at /dev/mapper/sdaX_crypt.

Thanks a lot for the article, it was very simple and helpful!

fold this thread Anonymous  Wednesday, 20 May 2009 o godz. 2:42 am #  Add karma Subtract karma  +0

Thanks for the info, but…

“all you have to do is run “cryptsetup luksOpen /dev/sdaX sdaX_crypt””

I guess I run that at the end when everything else is done?

So…When *should* you run that command, then?

 
 
fold this thread Andy Todd  Saturday, 6 September 2008 o godz. 5:57 pm #  Add karma Subtract karma  +1

Great stuff, just what I needed! Just one thing: when I went through this i needed to run ‘apt-get update’ before I could install lvm2

 
fold this thread Rashief Yusaf  Sunday, 19 October 2008 o godz. 6:55 am #  Add karma Subtract karma  +0

Great guide. I just tried installing given the steps above, I get an error message saying “The attempt to mount a file system /dev/mapper/lvUBUNTU-ubuntu–swap with type swap at none failed.”. Am I missing something?

fold this thread noquierouser  Monday, 27 October 2008 o godz. 10:28 pm #  Add karma Subtract karma  +0

I’m having this same problem too. I tried with making the partition and the partition table again but it keeps giving me that problem. What’s going on?

 
fold this thread Brad  Monday, 3 November 2008 o godz. 10:08 am #  Add karma Subtract karma  +0

Guide doesn’t mention manually mounting swap but did you try
/dev/mapper/lvUBUNTU/ubuntu–swap
instead of
/dev/mapper/lvUBUNTU-ubuntu–swap ?

 
 
fold this thread Oded  Saturday, 1 November 2008 o godz. 5:47 pm #  Add karma Subtract karma  +0

I just reinstalled Hardy using this method on my system which had an LVM2 from previous hardy alternate-installer. I botched my system by upgrading to Intrepid and I forgot about the LVM2 problem so I just got a Hardy LiveCD and tried to install from that. But it works with this method here, so thanks!

 
fold this thread justavisiotr  Saturday, 1 November 2008 o godz. 9:03 pm #  Add karma Subtract karma  +0

Thanks for the excellent guide!

One addition:

I got for quite some time stuck after chrooting and trying to give “apt-get install lvm2″, and it complained such package was not found. Just do “apt-get update”, and then do “apt-get install lvm2″ and it should work. At least that did it for me!

 
fold this thread Xanderphillips  Thursday, 11 December 2008 o godz. 5:23 am #  Add karma Subtract karma  +0

Thanks! Now if only I could find a good guide for upgrading an existing 8.10 install from regular partitions to LVM2 I would be all set. I have a mythtv backend server that I would love to upgrade it’s / partition to LVM2.

 
fold this thread Greg Corrigan  Thursday, 8 January 2009 o godz. 8:36 pm #  Add karma Subtract karma  +0

Nice post - just got my rebuild sys straight after manual LVM creation… well done!

 
Name (required)
E-mail (required - never shown publicly)
URI

Adjust field size: shrink | enlarge)

You can use simple HTML in your comments. Some examples are as follows:
  • A hyperlink: <a href="polishlinux.org">GNU/Linux for everyone!</a>,
  • Strong text: <strong>Strong text</strong>,
  • Italic text: <em>italic text</em>,
  • Strike: <strike>strike</strike>,
  • Code: <code>printf("hello world");</code>,
  • Block quote: <blockquote>Block quote</blockquote>

About the Author

MAcks

System administrator and programmer (Python, Common LISP). Main interests: distributed systems, virtualization, intelligent computations. Linux user since 2000.

Advertise on PolishLinux!

Partners

RSS: Comments

You can follow the comments to this article through a special channel RSS 2.0 .

Related articles: Ubuntu

 more »

PolishLinux Top Content

Select distros:

vs

Google Ads