Friday, April 03rd, 2009 | Author: pluc | Views: 3,107

I’ve upgraded to Ubuntu 9.04 (“Jaunty Jackalope”) from 8.10 (“Intrepid Ibex”) about a week ago and was surprised how smooth it went. Jaunty’s still in its alpha stage (Alpha 3 as of now) yet it’s surprisingly stable. One thing that Jaunty, once officially released, will add to the regular Ubuntu is ext4 support. Ext4 is an upgrade from (wait for it…. you’ll never guess!) ext3, which is starting to show its age in the filesystem world. Ext4 provides better performance than ext3, mostly due to its delayed allocation and more file support (like you’ll ever have files bigger than 2 or 16 Terabytes?). Anyway, I felt like risking an in-place conversion of my two ext3 partitions for the sake of performance… and it went relatively smooth. I’ll explain how I’ve done it so you can give it a whirl as well. One thing worth noting though is that once a filesystem is converted to ext4, there’s no going back. You can’t convert it in-place to ext3, you must format the whole thing and start over. So obviously, back your shit up.

Before you start, you’ll need the following:

Converting extra partitions

What I mean by “extra” is simply any partition or devices that do not contain your Ubuntu system. The process is extremely simple and extremely fast. It’ll take you about 30 seconds for every partition you wish to convert to ext4. Make sure you’re not using any files on the partition we’ll work with (torrents, music, system resources, etc). If your command line-fu is good, just unmount the partition you want to convert (umount /dev/XXX where XXX is your device and partition (sda2, sdb1, hdc3)). Otherwise, fire up the GNOME Partition Editor (gparted) that’s in System > Administration > Partition Editor. Select the device containing the partition you want to convert, right click on the partition and select “Unmount”. Take note of the “Partition” label (such as /dev/sda2 or /dev/sdb1 or /dev/hdc3).

Now that your partition is unmounted, we can convert it to ext4. Fire up a terminal (run -> gnome-terminal) and run this command as root, replacing XXX with your device and partition name/identification (that you should’ve noted or should know by now):

tune2fs -O extents,uninit_bg,dir_index /dev/XXX

I’ll take a few seconds, and you’ll have an ext4 filesystem. Easy enough, right? For added security, we’ll run a filesystem check after each conversion using fsck:

fsck -pf /dev/XXX

The last thing we need to do is let your system know about the change we just did. We can do that by editing /etc/fstab as root (using whatever editor you’re comfortable with) and changing the filesystem of the partition. Once /etc/fstab is open, look for a line starting with your device and partition (/dev/XXX) or your device’s UUID (you can get your device’s UUID by typing sudo vol_id –uuid /dev/XXX). Change the “ext3″ to “ext4″, and you’re done. Repeat this process for every other partition you want to convert, except for your boot partition (the one containing /boot). Once all your partitions are converted and updated in fstab, run sudo mount -a to remount them all, or you can also do them manually by performing the inverse of the process you went through to unmount them.

Converting the main system partition (the one with /boot)

Here’s where it gets tricky a bit. A lot of people in the Ubuntu community and some of the sources used in this article advise against doing this since there’s no real gain, except boot speed increase and the GRUB boot loader doesn’t officially support booting from ext4 filesystems. It’s still a fun thing to do, and well you’ve already got a theoretically unstable system anyway, so why the hell not give it a shot?

Obsolete (but tested & working) method:[1] Apply the patch you downloaded from grub4ext4 [1] (some instructions are in the grub4ext4/grub-0.97/INSTALL file). That’ll add some basic ext4 support to your boot loader. After that, edit GRUB’s configuration file (/boot/grub/menu.lst) as root to include the ext4 change. Append the “rootfstype=ext4″ directive to the boot line [1], as follows, run update-grub as root and proceed with the rest of the tutorial below.

title        Ubuntu jaunty (development branch), kernel 2.6.28-10-generic
uuid        2134efa6-d23f-4aeb-8157-5ac06f95634b
kernel        /boot/vmlinuz-2.6.28-10-generic root=UUID=2134efa6-d23f-4aeb-8157-5ac06f95634b ro splash vga=792 quiet rootfstype=ext4
initrd        /boot/initrd.img-2.6.28-10-generic
quiet

Then run update-grub as root to generate a new menu.lst (not sure why, but apparently it’s needed. Kind of redundant if you ask me). Since you can’t unmount the main system’s partition while working on the system, you’ll have to reboot onto the Jaunty LiveCD you downloaded earlier in order to do it. Make sure to boot from the LiveCD, because at this stage, GRUB is configured to boot on a ext4 filesystem that we haven’t yet created, and it won’t boot until we do so. From the LiveCD, make sure your device isn’t mounted (you can use gparted here too) then run the two commands we discussed above (tune2fs and fsck) on the device. Reboot and voila! You’re booting with a full ext4 system.

New (but untested) method: With this new method, you won’t need to patch your GRUB or edit your menu.lst. It’s unconfirmed and I haven’t personally done this specific procedure, so if you’re feeling adventurous, go ahead and let me know if it does work. If you do try it though, be prepared for a possible boot fail. It would be wise to put the grub4ext code on a USB key or save the URL or files somewhere you can access from a LiveCD. Should that happen, restore (and continuation of the procedure) is easily doable from the LiveCD. Simply mount your original system’s partition from the LiveCD, create a chroot, patch GRUB and continue with this tutorial from that chroot. Jaunty’s version of GRUB is apparently [1] already supporting ext4 boot , so all you’d have to do is run the conversion and check commands mentioned above on your partition, then run update-grub as root.

Notes

  1. Apparently, patching GRUB using grub4ext4 and adding rootfstype=ext4 within /boot/grub/menu.lst would be obsolete. FuturePilot reports on Ubuntu Forums that simply reinstalling GRUB to your machine’s master boot record (MBR) will do the trick. More information within bug #353071 on Launchpad. I have not tested this method, but it would make sense to work. If you successfully do, give me a holler and I’ll update accordingly.

Sources


Category: Linux
You can leave a response, or trackback from your own site.

11 Comments

Pages: « 1 [2] Show All

  1. [...] source Author: WladyX on 21 April, 2010 Category: General Older: Top 5 most useful commands or tools for Linux administrators [...]

Pages: « 1 [2] Show All

Leave a Reply