PDA

View Full Version : Installing Ubuntu Netbook Remix on LVM (EEE901)



Bracken
30-11-2009, 09:24 PM
You may have a desktop, laptop or netbook with more than one storage volume, and wish that it was actually one big volume. For example, my EEE901 has a 4GiB and 16GiB SSD. You may have a netbook with an internal SSD and an SD card, or you might want to use LVM in some other funky way.



You should read the whole guide before attempting this. If you don’t understand what each line is doing by reading this guide, then LVM is probably a bit advanced for now.


NB: This guide will not work on ubuntu prior to 9.10 due do it not using grub2 and not having dm-mod built in to the kernel. If you understand the guide fully, then it should be a trivial matter of spotting where to install and insert dm-mod. Plus using a separate /boot.


What is LVM?
Logical Volume Management is a small local implementation of “storage virtualization”. In essence, you plug any number of different physical volumes into the back, and out of the front you can use logical volumes. These logical volumes can be of any number, size is not dictated by the back end disk sizes. You can also do mirroring, striping and snapshots (seemingly instantaneous copies of logical volumes). If you add physical volumes to the back, creating unused space in the storage pool, you can then grow logical volumes live. You often hear storage virtualization dismissed in the storage industry, but it’s actually the best thing since sliced bread.


This article will demonstrate an installation of ubuntu (UNR actually) 9.10 onto LVM, where 2 small physical volumes are used to create 1 big logical volume.

But wait, can’t we just use the alternate install disk with the Debian installer? Yes, but not if you’re installing the Netbook Remix. I personally prefer this method anyway.



Make a bootable ubuntu USB.
Download your chosen ISO (in theory this works with xubuntu and kubuntu too).


Make a bootable USB stick using a memory of 1GiB capacity or larger. This can be done in ubuntu using the Make Startup Disk (http://manpages.ubuntu.com/manpages/karmic/en/man8/usb-creator.8.html) tool, or in other distros and windows using UNetbootin (http://unetbootin.sourceforge.net/).


Partitioning.
Boot from the USB stick, choose to “use ubuntu without changing your PC”.


Once you are at the live desktop, fire up GParted and make an unformatted partition on each of your disks. Being careful not to edit the USB stick. There is also no need for /boot, as grub2 used in 9.10 supports /boot inside LVM. You may still need a swap partition, it can be a logical volume if you like, I’m not going to use one since I have a netbook with an SSD.



http://blog.iamtheb.org/wp-content/uploads/2009/11/gparted.jpg

(In case you are wondering, on an EEE, the 2 partitions at the end of sda are for the fast BIOS post feature. If you got rid of them and now wish you hadn’t, 2 unformatted 8MB partitions will work).


Creating the LVM Setup.
Before you create the LVM setup, we need to install some packages into the live session. In Software Sources, add the remaining repos:
http://blog.iamtheb.org/wp-content/uploads/2009/11/softsource.jpg

Now install some packages:

sudo apt-get install lvm2 system-config-lvm
This will need to be repeated if you re-boot, unless you used the ubuntu tool to make the USB disk and you assigned space on the USB stick for files and settings.



If you don’t like the command line, you can do this in synaptic, you want the packages called “lvm2” and “system-config-lvm“.


Now we need to remove a safeguard in LVM, which will allow us to work with block devices which are not CD-drives. As root, edit /etc/lvm/lvm.conf so that line 52 onward looks like this (comment one line, uncomment the other):

# By default we accept every block device:
# filter = [ "a/.*/" ]

# Exclude the cdrom drive
filter = [ "r|/dev/cdrom|" ]

Don’t be fooled by the comments, there is actually a bug in the default filter, where it won’t let you initialise any SCSI block devices.



Now initialise each of the unformatted partitions you created:

sudo -s
pvcreate /dev/sda1
pvcreate /dev/sdb1
Now the partitions are LVM2 formatted, and ready for use by LVM.



Next we need to create a Logical Volume Group, this group will be made of physical volumes, and will contain the logical volumes, we’ll start by making one containing sda1, then add sdb1 to it:

sudo -s
vgcreate lvm_grp0 /dev/sda1
vgextend lvm_grp0 /dev/sdb1
We now have a logical volume group, the size of the physical disks it is made of, next we make a logical volume in this:

sudo lvcreate -l 100%FREE -n root lvm_grp0
“-l 100%FREE” means “use 100% of the free space in the volume group”. We now have a new block device, presented as /dev/mapper/lvm_grp0-root. Its function is like a partition, such as /dev/sda1.



If you don’t like the command line you can do this with the system-config-lvm tool:

http://blog.iamtheb.org/wp-content/uploads/2009/11/sysconlvm.jpg

Installing.
You are now ready to install, fire up the installer from the desktop. Continue as usual, until you get to the partitioning page. Choose manual partitioning:

http://blog.iamtheb.org/wp-content/uploads/2009/11/part1.jpg

http://blog.iamtheb.org/wp-content/uploads/2009/11/part2.jpg
You will see all the physical device’s partitions, but more importantly, the LVM block device. Ignore all the physical devices and use /dev/mapper/lvm_grp0-root as whatever format you like, and with a mount point of /. Format it if you like, it makes no difference.

Do the same for the swap logical volume or physical volume if you are using one. Ext3 for now has some advantages with it being compatible with the system-config-lvm gui.

Just before you start the install, click Advanced… and have it install the boot-loader on /dev/sda, it’s no good installing a boat-loader to the beginning of a logical volume:

http://blog.iamtheb.org/wp-content/uploads/2009/11/adv.jpg

Now click install and go make a mug of ubuntu, I mean coffee.



STOP; this installation is not ready yet!


Post Install.
What we have now is a system which:


is installed to an LVM logical volume.
has a usable /boot directory in this logical volume.
has a usable grub 2 stage 1 installed to the boot disk.
has a correct /boot/grub/grub.cfg for /boot and the kernels being inside lvm.
has a correct /etc/fstab file.
does not have lvm2 installed!

This clearly won’t work. We need to install lvm2 on the new system, here comes the clever bit, chroot into the new system:

sudo -i
mount /dev/mapper/lvm_grp0-root /target
mount -t sysfs sysfs /target/sys
mount -t proc proc /target/proc
chroot /target
We are now effectively using the new system’s console. Go ahead and get the package lists, there should be no need to add the extra software sources this time (if you do, don’t use the GUI), then install lvm2:

apt-get update
apt-get install lvm2 system-config-lvm
Control+d out of any terminals you now have open, it’s time to reboot into the installed system. Switch off, remove the USB stick, and boot from your internal disk.

Congratulations, you’re now free to experience the magic of LVM. If you find any bugs, comment and I’ll fix the article.

mrgoose
30-11-2009, 10:37 PM
Really good article. Many thanks. You make it sound so cool, I'm almost tempted to give it a whirl. My present dataset now resides on 3 x 2 TB WD Greens, partitioned @ 1TB for ease of backup, plus 6 x 1TB Samsungs on the backup server. So no need for LVM there.

However, I am a long-term data junkie and I have lots of redundant IDE disks in the 70-110GiB range. And several more SATA 400GB kickin' about - all left over from previous data storage solutions. It would be good to use them for something, rather than leave them gathering dust.

However one thing worries me slightly. Forgive my ignorance, but what happens if one hard disk in the set fails? I had this with several LaCie boxes. Basically these were Firewire-connected disk arrays in pretty aluminium cases, consisting of 4 disks in some sort of a striped raid. Problem was that if one hard disk failed, then basically the whole set was screwed.

Also, sorry for being the department for daft questions, is there an upper limit regarding number of disks & maximum total volume size?

Best wishes, G.

Bracken
30-11-2009, 11:05 PM
Don't think of this as as concatenation of disks.

You can have a mirrored logical volume, which will make sure each 4MiB extent is mapped to physical storage on more than one disk. A bit like RAID1.

You can have striping, where each 4MiB extent is striped across a specified number of physical disks. Like RAID 0, you choose the strip size, right down to waaay too small for a software raid setup.

You can have both, like RAID 10.

You can do snapshots, which will blow your mind: It's a read/write copy of a logical volume, it is almost instantly created, and is immediately ready for read/write operations. They also take up less room than their physical size, nothing at 1st.
"Wut! How?"
It's fake, it's a logical volume which presents all the data from the source, at the exact time it was created. If you change the source, the old data is 1st copied to the snapshot. If you change the snapshot, it gets changed and the bitmap instructed that that block is now copied. It's a difference volume.
How's that for easy backups? Snapshot, copy snapshot to backup medium, loose the snapshot. A slice in time, a lot like what ZFS can do.

LVM is intended for servers with large amounts of heterogeneous storage. But because it's actually storage virtualization, it kicks butt, and is so versatile it even has a place on a netbook with 20GiB of storage.




If I had your system, I'd tier the storage.
I'd have one volume group called "silver" for your 3 2TB drives, and one called "rust" for your random collection of smaller drives.
I'd then make 1TB mirrored logical volumes on silver as and when I need to. Maybe expand one as it gets full. Maybe add more 2TB drives as I need more back end.
Just make sure you notice and replace failed drives (you need to re-mirror the Logical Volumes if this failed drive affected them, as they become normal LVs).


Edit:
Nearly forgot; in LVM2, you can have 255 physical volumes, and 255 logical volumes per volume group.

mrgoose
30-11-2009, 11:31 PM
Don't think of this as as concatenation of disks.

You can have a mirrored logical volume, which will make sure each 4MiB extent is mapped to physical storage on more than one disk. A bit like RAID1.

You can have striping, where each 4MiB extent is striped across a specified number of physical disks. Like RAID 0, you choose the strip size, right down to waaay too small for a software raid setup.

You can have both, like RAID 10.

You can do snapshots, which will blow your mind: It's a read/write copy of a logical volume, it is almost instantly created, and is immediately ready for read/write operations. They also take up less room than their physical size, nothing at 1st.
"Wut! How?"
It's fake, it's a logical volume which presents all the data from the source, at the exact time it was created. If you change the source, the old data is 1st copied to the snapshot. If you change the snapshot, it gets changed and the bitmap instructed that that block is now copied. It's a difference volume.
How's that for easy backups? Snapshot, copy snapshot to backup medium, loose the snapshot. A slice in time, a lot like what ZFS can do.

LVM is intended for servers with large amounts of heterogeneous storage. But because it's actually storage virtualization, it kicks butt, and is so versatile it even has a place on a netbook with 20GiB of storage.




If I had your system, I'd tier the storage.
I'd have one volume group called "silver" for your 3 2TB drives, and one called "rust" for your random collection of smaller drives.
I'd then make 1TB mirrored logical volumes on silver as and when I need to. Maybe expand one as it gets full. Maybe add more 2TB drives as I need more back end.
Just make sure you notice and replace failed drives (you need to re-mirror the Logical Volumes if this failed drive affected them, as they become normal LVs).


Edit:
Nearly forgot; in LVM2, you can have 255 physical volumes, and 255 logical volumes per volume group.

So you're quite keen on LVM's then? :)

Seriously, clearly I have a lot of reading to do. LVM is not something I had considered before. But I certainly will now.

Just one more daft question. I'm a bit of a Truecrypt fan. Basically nothing important leaves the building unless its encrypted. So how do you Truecrypt an LVM? Presumably TC sees an LVM as if it were an ordinary disk?

Best wishes, G

Bracken
01-12-2009, 12:01 AM
So you're quite keen on LVM's then? :)

I did my degree's placement working as a tester on the team developing IBM SVC. Which is an enterprise storage virtualization engine. If you read about LVM and like it, then SVC takes it a million miles further. Can you say 100% of the storage hardware (including your SAN and the SVC itself) replaced with zero downtime of the servers? Might want to read a few redbooks.


Just one more daft question. I'm a bit of a Truecrypt fan. Basically nothing important leaves the building unless its encrypted. So how do you Truecrypt an LVM? Presumably TC sees an LVM as if it were an ordinary disk? TC may see the logical volume (/dev/mapper/volumegroup-volume), as an encryptable device. Crypto LVM is certainly achievable: http://jager.no/news/ubuntu-netbook-remix-with-encrypted-root

Mr Grapes
03-12-2009, 10:10 AM
V nice writeup :thumbs:

+1 for:

STOP; this installation is not ready yet!

-1 for not writing SHTOPP :)

danceswithferrets
05-12-2009, 12:22 PM
So you're quite keen on LVM's then? :)

Seriously, clearly I have a lot of reading to do. LVM is not something I had considered before. But I certainly will now.


+1 I've often wondered about it !