ext4
Is ext4 unsafe?
Thursday, March 19th, 2009 | english | 1 Comment
There has been a lot of hype about ext4 lately, following an Ubuntu bug which rose a lot of concerns about ext4 security. I know these are no news, and I know also that I am not a kernel guru, but let’s resume some important concepts.
Ext4 implements something called allocate-on-flush. This means that kernel will decide how to write to disk in an efficient way by batching allocations together in larger runs. It increases performance and reduces fragmentation. But if a system crash happens between metadata and data is actually written to disk a 0-size length file can be found in the filesystem. With ext3 journal had a default timeout of 5 seconds and then was flushed to disk. With ext4 this time is unknown, so appplications that want to ensure everything is on disk have to call fsync() on file and directory after every operation. To avoid this, a series of patches have been queued for 2.6.30 so when a file is going to be replaced, it is written to disk with no delay.
Another concern raised is the need for atomicity and durability of files. For achieving this applications have first to write a temporary file and then rename() it over the old file. This will ensure that new or old file will be found in the filesystem after a crash, instead of a corrupted file that can be found when it is opened with O_TRUNC.
Anyway, my opinion is that when choosing a filesystem, one have to know what the computer is going to be used for. Using binary propietary drivers is an option, which can lead your Linux installation to behave most like Vista and filesystem cannot be blamed for losing files if it is making its job as designed. Perhaps, it’s better to use ext3 in this situation, but at the cost of missing performance.
If you want to learn more about this issues I recommend you to read both articles by Theodore Tso, “Delayed allocation and the zero-length file problem” and “Don’t fear the fsync!” and also AlessanderAlexander Larsson’s one “ext4 vs fsync, my take” as well as comment in all of them.
Upgrading my laptop to ext4
Sunday, March 15th, 2009 | debian, english, howto | 3 Comments
Warning: Don’t upgrade root partition (/) or the partition in which /boot is placed unless you know what you are doing. More on this later.
Warning2: Make backups of your data.
Last Friday I went on upgrading to ext4 my laptop. I decided to go first with /home partition, as / has also /boot and can give some problems if not handled with care. Upgrading it is quite easy, and fast, as the old data is not upgraded, only new files will be added using new features.
First, I installed latest linux-image package to start using kernel version 2.6.28, which includes production ready ext4 support. After rebooting, I logged in as root so I could umount /home. The steps to upgrade are as follows:
# uname -a
Linux gimli 2.6.28-1-686 #1 SMP Mon Feb 23 03:13:24 UTC 2009 i686 GNU/Linux
# umount /home
# tune2fs -O extents,uninit_bg,dir_index /dev/home_partition
# fsck -pfD /dev/home_partition
# mount /home
You MUST run fsck. If not, ext4 won’t mount your filesystem, so don’t forgive this step if you’re upgrading your / partition. You will see some checksums errors appear. Don’t be afraid, that’s expected, and that’s why -p is added to fsck command, you it is not asking which action to perform in every error.
Upgrading partition containing /boot
For upgrading your / partition you have to take into account what grub and klibc version you have installed. The former is need so grub can read your kernel image from filesystem, and the second is needed due a bug that made initramfs detect ext4 filesystems as ext3, and passing incorrect option to mount, which failed. Versions in Debian known to work are libklibc >=1.5.15-1 and grub2 (packaged as grub-pc). Make sure you have these versions installed before trying to go to ext4.
Also, as you have to upgrade having your partition unmounted, you will have to get a console before root partition is mounted. You can do that by passing mount=break break=mount to your boot options in grub.
ENJOY!

