Archive for April 22nd, 2011
With recent Linux distributions (based on the 2.6.28 kernel) the Ext4 file system is considered stable and provides many improvements over Ext3.
Ubuntu systems running 9.04 (Jaunty Jackalope) had the option to format Ext4 during install time, but Ext3 was the default until 10.04 (Lucid Lynx). However, it’s possible (and fairly easy) to upgrade Ext3 to Ext4 in-place and without reformatting or reinstalling. Nice, huh?
The following guide is based heavily off the Ubuntu documentation, which some added steps and clarification. If you’re going to do this, use your head and make sure you have backups of your important data before you start, just in case. Also, don’t skip any steps, and double-check yourself along the way. A typo could ruin your day.
Zero – Before you start
Verify your kernel version by running
uname -r. Make sure it is 2.6.28 or higher. If it is not, STOP. Upgrade your kernel before attempting to proceed.
Also, check that you’re currently using Ext3 — this would be pointless if you’re already running ext4 — by using the mount command. You should see something like the following:
/dev/sda1 on / type ext3
This shows ext3 as the current filesystem type.
One – Turn off any automatic updating
Go to System > Administration > Update Manager. Click Settings and set Automatic Updates to Only notify about available updates. You want to make sure that the system doesn’t start applying an update halfway through this and give you the potential worst-case of an unbootable system.
Two – Prepare to load the Ext4 driver
Ext4 is backwards compatible with Ext3, which makes this update process as easy as it is. We’ll start by telling the system to load the Ext4 driver instead of the Ext3 driver at boot. This will allow the system to boot and run normally for the steps that follow.
Edit the file /etc/fstab in your favorite text editor.
gksu gedit /etc/fstab will do fine. Change any references for disks that you plan to convert from Ext3 to Ext4. Take a look at the example:
# /etc/fstab: static file system information. # # proc /proc proc defaults 0 0 # /dev/sda1 UUID=327c1819-14e1-4b96-b9d2-d5e55e50f1ae / ext3 defaults,errors=remount-ro,relatime 0 1 # /dev/sda5 UUID=900e39f2-ad49-42ee-a7f5-8e6807d6b35b none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
The above example shows an Ext3 filesystem on
/dev/sda1. I’ll use
/dev/sda1 as the file system for the rest of the guide for clarity. So, change
ext4 in the above file and save it.
shutdown -r now )
Three – Update the filesystem options
After rebooting, the kernel will be using the Ext4 filesystem driver, even though your filesystem on disk is still natively ext3. That’s what you want, you’ll be making the actual changes to the filesystem soon.
Now, run the following command to make the changes to your filesystem that adds the Ext4 features:
sudo tune2fs -O extents,uninit_bg,dir_index /dev/sda1
Note: There’s no spaces after the comma-separated options. Copy/paste if you’re not sure.
/dev/sda1, like I stated above. Change it if it’s not correct for you, or if you’re doing multiple filesystems, run it for each one.
Reboot again (
shutdown -r now )
Four – Take a deep breath
Due to the changes that tune2fs made on your filesystem, when you reboot you’re going to get the message
“Errors were detected on your filesystem, press ‘F’ to fix…” or something similiar. Press F and let it do it’s thing.
You may get the following error as well (I did):
The disk drive for for /tmp is not ready yet or not present. Continue to wait or ...
Just wait patiently. You’re waiting for the changes to finish on the currently-processing filesystem, and it’s just telling you that it’s trying to mount or access /tmp and it’s having trouble, due to the currently-running process.
After a few minutes (depending on the size of your partitions and the amount of data on them), everything will go back to normal and you’ll be able to log in again.
There’s just a few more steps.
Five – Reinstall grub
Run the following command to reinstall grub. Note that the partition number is omitted from the device path — this is intentional and correct.
sudo grub-install /dev/sda
You should get a message indicating the operation was successful.
If you are upgrading from 8.04 LTS to 10.04 LTS, you will need to install grub2 as soon as possible, as grub1 is not Ext4-aware. (Users running 9.04 are not affected by this.)
sudo apt-get install grub2
Once it’s done, no more reboots are really necessary, though you can always reboot to make sure grub actually reinstalled correctly. Files written from now on will be written with full Ext4 structures. You can also turn automatic updates back on at this point.
You can verify all the filesystem features are set by running:
sudo tune2fs -l /dev/sda | grep features
This is the list of ext4 features you should have set:
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent sparse_super large_file uninit_bg
If you’re missing one or more features, go back to step three above and check that you entered the command correctly.
Questions, comments, and feedback are welcome, as always.