Ubuntu 7.04, Vista & LVM

If you remember from a previous post a few months back, I was experimenting with various Linux distributions. These were the candidates, and my personal biases:

1) Fedora Core 6 - Nice distro, but some assembly acquired
2) Ubuntu 6.10 Edgy Eft - Very polished Debian release with excellent community support, but I was concerned it was too "newbie" (Gnome default, seemingly crippled root user, etc)
3) Slackware 11 - Solid, time-tested, but I'm already using a slack-derivative on my laptop (I want to try something new)
4) SUSE 10.2 - Also solid (and previously my favorite), but there were, er, ideological issues I have to cope with... (not to mention it has just seemed "broken" after 10.0)

So, since I was already most familiar with SysV, I use RHEL extensively at work, and was heading off to training at Redhat HQ in Raleigh, NC anyway, Fedora won out. It was working fine for months, but the yum package manager was starting to annoy me; since there is no third party driver support, updating the kernel would always break my NVidia drivers, VMWare, etc. I also found myself having to actually (shock) compile things myself, because the main repos didn't offer "everything", relatively speaking. I wanted to try the legendary Apt-get system for myself. So Ubuntu 7.04 "Feisty Fawn" roles out to enormous fanfare, and I couldn't resist anymore. I also recently acquired another 400GB HDD, so updating gave me an excuse to set up a custom LVM partition scheme from scratch.

This was the plan- Vista will go on the beginning of physical drive 2 (in case I want to play some games later or something), Ubuntu goes on physical drive 1, and the remaining space on both drives gets combined into one large data partition. To prepare for this, I used fdisk to allocate about 40GB on sdb (the 2nd HDD, right?), and leave the remaining ~360GB alone for now as free space. (Optionally, you can use bootable partition managers to do this; my favorite commercial offering is Acronis Disk Director.)

Since Windows has always been so bratty about pwning the mbr, I just let it have it's way. So, I unplugged my Linux drive from the primary SATA port, plugged in my second drive to the primary, and now Vista will think it's going to be the active drive when it installs; easy peasy. I go through the motions, boot into it, ooo and ahh over the eye candy and Mac-like widgets for a few minutes, and hopefully won't have to look at it again for a while. ;)

First, some prerequisite info; I completely anticipated blowing away all the data on my drive in the next phase, so like a good little sysadmin, I have been scheduling backups for my data to an external USB drive for some time. In fact, I did a special backup the night before just to make sure I got everything. Guess what? I didn't get everything due to full-medium issues, and didn't really examine the logs generated by my custom backup script (which uses rsync; I'll post it later) well enough until it was too late, so I suffered some painful, agonizing data loss. Always, always make sure your archived data is complete before doing drastic things like this; nuff said.

Anyways, the fun part. I demote the Vista drive back to secondary SATA status (check your mobo documentation for details, check your bios, experiment), plug the Linux drive back as the primary, and boot into the live CD. (A live CD *AND* installer?!?! That's freakin awesome!!!) I tried the pretty graphical installer at first, but realized it didn't have the tools I wanted, ie. a robust Logical Volume Manager. I not only wanted to dynamically resize my partitions post-installation, but also wanted to combine space on two physical drives without using Raid stripping (btw, Raid is also not available within the graphical installer... *shrug). I opted for the tui OEM installer to ensure I was getting a desktop setup, which looked oddly familiar in a last-century kind of way.

So, I fire up the installation, select the custom partition option, nervously nuke all partition tables on sda where my data and Fedora were kept, and leave the 40GB NTFS partition on sdb1 alone. The basic work flow is: create one or more partitions of the type LVM --> create one or more Volume Groups --> go into the Volume Group Manager and create your Logical Volumes --> format them using your file system of choice (I used ext3) and set the mount point. It seems like a lot of work, but the payoff is flexibility later on.

Here is my specific work flow: created a normal 128MB ext3 partition on sda1 for /boot --> created a 40GB LVM partition on sda2 for the rest of the file system --> created a ~360GB LVM partition on sda3 to serve as HALF of my planned /data partition --> created another ~360GB LVM on sdb2 (remember, sdb1 is my Vista install...) to serve as the other half of my /data partition... saved the changes, and went on to the Volume Group Manager: created a volume group called "vg0" on sda2, then a volume group called "vg1" consisting of sda3 and sdb2. (Still with me? Good!)

Now I just have to divvy up the volume groups into logical groups (/, /home, swap, etc.), so I can format and mount them for the rest of the install. This is a summary of my final schema (notice how I used very descriptive names, either "vg*" for "volume group" or "lv.*" for "logical volume"- I highly recommend doing something similar):

---------vg0---------
| lv.root 	8GB |
| lv.home 	15G |
| lv.tmp 	1G  |
| lv.usr 	8G  |
| lv.var 	2G  |
| lv.swap 	2G  |
---------------------

---------vg1---------
| lv.data    660GB  |
---------------------

This is what it will look like afterwards (output slightly truncated):

root@Toasteroven:~# df -h
Filesystem            		Size  Used Avail Use% Mounted on
/dev/mapper/vg0-lv.root 	7.9G  407M  7.1G   6% /
/dev/sda1             		114M   23M   86M  22% /boot
/dev/mapper/vg1-lv.data 	658G  288G  337G  47% /data
/dev/mapper/vg0-lv.home 	15G  3.1G   11G  23% /home
/dev/mapper/vg0-lv.tmp 		1008M   37M  920M   4% /tmp
/dev/mapper/vg0-lv.usr 		7.9G  3.8G  3.7G  51% /usr
/dev/mapper/vg0-lv.var 		2.0G  1.3G  643M  67% /var
/dev/sdb1              		41G   11G   30G  28% /media/sdb1

Groovy. Regarding the swap space, there still seems to be some debate on exactly how much to allocate, 1x or 2x the physical memory. I just did 1x (or 2048MB) because in the past, I've rarely if ever seen the swap used at all. My rule of thumb is to use 1x on a desktop with 1GB or more, and maybe 2x for desktops with less memory and possibly servers. But the beauty of putting swap on LVM is you can always adjust this later without having to resort to creating a swap file, extra swap partition or mem upgrade, so no worries.

Once you're done deciding on how to allocate your groups, you'll save the changes and find yourself back in the advanced partitioning interface. This is where you will define which file system type to use and their respective mount points (remember, naming your logical volume "lv.swap" doesn't make it a swap space yet...) Select each new partition one by one and set them. (For example, for vg0-lv.root, make the file system type "ext3" mounted on "/", and optionally name it "root"). Also, don't forget to set your /boot partition, or you will end up booting off of your root partition! (It will still work, but I'm old-school. I like having my kernel on sda1 where I know I can access it in case of emergencies.)

So, commence with the install as usual. You will know if you did not do the root file system correctly, since Ubuntu will slap you on the hand. As far as packages go, I'd recommend the standard ones for now, since they're pretty good yet lean (and maybe the development offerings to ensure things compile later on, your choice). You can always apt-get things later, right? The only other gotcha in OEM mode is that you have a choice between LILO and GRUB, and by all that's holy please select GRUB (WHY IS LILO EVEN AN OPTION ANYMORE?!?!). Go ahead and throw it on the mbr since we're not competing with Windows for that precious 512MB anymore; it should automagically see that sdb1/NTFS partition and know it's Vista/Longhorn, and will present it under "Other Operating Systems" whilst GRUB loads. Once in Ubuntu, you will use your temporary "oem" username with the password you defined; feel free to run "oem-config-prepare" at any time, reboot, and set up your new account (unless you really are a manufacturer, then you probably wouldn't need my guide).

Anyway, I hope this was somewhat useful. Using 2 physical drives is also good for those wishing to experiment, who don't want to endanger their working Windows installation, which I have heard of many times. Next post, I'll have a plethora of tweaks and mods I've stolen from other people (along with their sources). Tah.