Converting Ext4 to JFS

Because I have an older laptop and disk I/O can really bottleneck on the motherboard, I decided to move from the ext4 filesystem to JFS. Recently, I’ve used ext4 because it was fairly fast and definitely reliable; however, with the kernel moving to 2.6.30 new data integrity features have been added that slow it fairly noticeable on an eight year old computer. Moving to JFS has made a fair difference in improving the speed of the system, it’s caveat being that it that journals only metadata (not metadata and data like ext3/4)).

Backup, Convert, Restore

The JFS filesystem utilities will be needed (for Debian/Ubuntu):

sudo apt-get install jfsutils

Reboot to a rescue CD, and backup partition(s)/disks onto another drive. For this example two partitions are used: one for root, one for home. Mount root, home, and then the backup drive:

mkdir /mnt/{,,}
mount /dev/ /mnt/
mount /dev/ /mnt/
mount /dev/ /mnt/

Create the backup directories:

mkdir -p /mnt//backup-rsync/{root,home}

Backup both partitions:

rsync -axS /mnt// /mnt//backup-rsync/root
rsync -axS /mnt// /mnt//backup-rsync/home

Check integrity of backup, then create a JFS filesystem on both partitions:

mkfs.jfs /dev/
mkfs.jfs /dev/

Restore the backup contents back to the root and home partitions; first method:

rsync -axS /mnt//backup-rsync/root/ /mnt/
rsync -axS /mnt//backup-rsync/home/ /mnt/

Or this method to be sure files are defragmented (JFS is somewhat prone to fragmentation, heavy use may require occasional defragmenting):

(cd /mnt//backup-rsync/root/ && tar -cS -b8 --one -f - .) | (cd /mnt/ && tar -xS -b8 -p -f -)
(cd /mnt//backup-rsync/home/ && tar -cS -b8 --one -f - .) | (cd /mnt/ && tar -xS -b8 -p -f -)

Updating the System

The system needs to know of the filesystem changes. Changing apparent root from the rescue CD to the current Linux install is done by:

cd /mnt/
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
chroot . /bin/bash

Update the chrooted system current mounts file:

grep -v rootfs /proc/mounts > /etc/mtab

The fstab file (the static filesystem configuration) needs to be updated. The information that will need adjusting is: the UUID (possibly), the filesystem type, and options. The UUID’s (unique disk identifiers) may have changed, they can be appended onto the fstab file (so that they can be easily moved) like this:

blkid /dev/ | cut -d "\"" -f 4 >> /etc/fstab
blkid /dev/ | cut -d "\"" -f 4 >> /etc/fstab

Edited /etc/fstab with set UUID, type, and options:

# /dev/sda2
UUID=5d9753dd-f45f-425a-85e2-25746897fdfa / jfs   noatime,errors=remount-ro 0 1
# /dev/sda4
UUID=d3f9eafd-1117-4c75-a309-b21dece655d1 /home jfs noatime                 0 2

noatime lessens disk writes by not creating a timestamp every time a file is accessed (it isn’t seen as very useful anymore since it was developed primarily for servers with statistics in mind).

JFS supposedly works very well with the Deadline Scheduler; the Grub configuration need to specify to use it. This example is for Grub2 though it is similar with original Grub; edit /etc/default/grub and append:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=deadline"

The other Grub configurations need to be updated with the new information:


Then the Grub bootloader will have to be re-installed to the MBR (I think this is because the version of Grub put on the MBR has directions on how to be able to find its configurations for a specific filesystem).

grub-install /dev/  # Disk here is more likely and not partition

Exit the chroot and unmount temporary filesystems:

umount {proc,sys,dev}


About Todd Partridge (Gently)

Good times, good people, good fun.

Posted on 2011-10-30, in Linux, Ubuntu. Bookmark the permalink. 5 Comments.

  1. Did you try ext4 with the following options enabled: mkfs.ext4 -T largefile -O extents,uninit_bg,dir_index -j -m 0 /dev/sda
    You could also try btrfs with lzo transparent compression enabled.

  2. Not ready to try btrfs yet but your ext4 creation is interesting. These all appear to be good options, will have to try. A little interested in why you choose -m as zero though. From the man page I’m reading it says:

           -m reserved-blocks-percentage
                  Specify the percentage of the filesystem blocks reserved for the
                  super-user.   This  avoids  fragmentation, and allows root-owned
                  daemons, such as syslogd(8), to continue to  function  correctly
                  after non-privileged processes are prevented from writing to the
                  filesystem.  The default percentage is 5%.

    Seems like this would be a good thing, particularly for the fragmentation bit.

  3. -m 0 because I don’t want to waste hd space,and I used tune2fs -c 0 -i 0 /dev/sda too to remove checks.
    In my (desktop) experience these options are not useful,I monitor free space with xfce applet,and fragmentation too is still low.In case of unclean shutdown fsck is performed automatically,no need for periodic checks.

    Note -T largefile : if you use default options ext will waste a lot of space (you’ll see some gigabytes as “used space” in gparted I think because of the number of inodes.

  4. factualfantasy

    Since my website takes of “complexity reduction”, I usually just save the few files onto an USB finger, and then proceed to format and start again.

  5. ” Changing apparent root from the rescue CD to the current Linux install ”

    And why is that done? Can’t we update fstab and whatever else with them mounted elsewhere, instead of in a seemingly “literal” fashion?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 58 other followers

%d bloggers like this: