JFS Root Boot HOWTO

Paul Larson plars@austin.ibm.com
v1.0, May 22, 2001 - Copyright © International Business Machines Corp., 2001
1. Introduction
2. Assumptions/Prerequisites
3. Converting an ext2 based system to JFS
  • 3.1 Build the kernel with JFS support
  • 3.2 Create the JFS filesystem
  • 3.3 Copy the root filesystem
  • 3.4 Final setup
  • 3.5 Reboot

    1. Introduction:

    This HOWTO describes a method for converting an ext2 filesystem based Linux system to one running entirely on IBM's Journaled File System (JFS). For further information about JFS and to download the latest version of JFS, please visit the JFS for Linux web site at
    http://oss.software.ibm.com/developerworks/opensource/jfs/.

    2. Assumptions/Prerequisites:

    Before we get started, there are two assumptions that will be made in this document:
  • You must already have Linux installed and running
  • You must have an empty partition, partitioned as type 83 (Linux). It doesn't matter if this partition is formatted or not, but we'll be reformatting it as JFS so be prepared to lose anything you might already have on it.

    The examples in this document assume that you just have one big partition for your root filesystem and don't have separate mounts for /home, /usr, etc. It's ok if you do have separate partitions for those, but you'll need to have enough free space to copy those to the new jfs partition, and modify the /etc/fstab file to remove them or change the mount points as necessary. Finally, my root filesystem is on /dev/hda5 and the new partition that I'm going to format as JFS is /dev/hda6. This is system specific though, so you'll need to substitute the right partitions from your system.

    Something else to consider is that we will need to patch and recompile the kernel to add support for JFS. This isn't hard to do, but if you've never recompiled a kernel before, this probably shouldn't be your first experience with it.

    3. Converting an ext2 based system to JFS

    No commercial Linux distributions have picked up JFS yet, as it is still in beta. Hopefully soon, building a pure JFS system will be as easy as selecting to format your partitions as JFS when you install your favorite Linux distribution, but for now this procedure is the easiest way to create a system running on JFS.

    The following sections describe the steps necessary to build a JFS root filesystem and boot from it.

    3.1 Build the kernel with JFS support

    Download the latest 2.4.x kernel from ftp.kernel.org, and the latest jfs-x.y.z-patch.tar.gz from the JFS for Linux web site to /tmp. Extract them into separate subdirectories. Change directory into the base directory of the kernel source and patch the kernel.
    #cd /usr/src
    #rm linux
    #tar -xvzf /tmp/linux-2.4.3.tar.gz
    #mv linux linux-2.4.3
    #ln -s linux-2.4.3 linux
    #mkdir jfs
    #cd jfs
    #tar -xvzf /tmp/jfs-0.3.1-patch.tar.gz
    #cd /usr/src/linux
    #patch -p1 < ../jfs/jfs-2.4.0-v0.3.1-patch
    #patch -p1 < ../jfs/jfs-common-v0.3.1-patch
    
    Configure the kernel using make config, make menuconfig, or make xconfig (whichever you prefer). In the section labeled "Code maturity level options", turn on the item that says "Prompt for development and/or incomplete code/drivers." In the section labeled "File systems" turn on the option for "JFS filesystem support." Make sure to turn on JFS support so that it is compiled into the kernel, NOT as a module. Configure the rest of the kernel as needed for your system. Build the kernel with a make dep; make clean; make bzImage and if necessary, make modules; make modules_install. Then, copy the new kernel into /boot.
    #make dep
    #make clean
    #make bzImage
    #cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.0-jfs
    
    Now we need to build the JFS utilities. These are the tools for formatting a JFS filesystem, checking it for errors, extending the size, and more.
    #cd fs/jfs/utils
    #make
    #make install
    
    Next, we need to add an entry for LILO so that we can boot with our new kernel that can use a JFS filesystem. Edit /etc/lilo.conf and add an entry for the new kernel similar to this:
    image=/boot/vmlinuz-2.4.0-jfs
    	label=jfsboot
    	read-only
    	root=/dev/hda5
    
    Run /sbin/lilo to to activate the new configuration and reboot into the new kernel.

    3.2 Create the JFS filesystem

    Now that we have JFS support in the kernel, it's time to format our empty partition as JFS.
    #mkfs -t jfs /dev/hda6
    
    mkfs.jfs development version: $Name: v0_3_1 $
    
    Warning!  All data on device /dev/hda6 will be lost!
    
    Continue? (Y/N) y
       \
    
    Format completed successfully.
    
    5120608 kilobytes total disk space.
    

    3.3 Copy the root filesystem

    This is an easy step and requires very little work on your part, but it will take the most time to complete. First, unmount any NFS, SMB, or cdroms that are mounted. Create a mount point for the new JFS partition and mount it. There are a few things to remember before we start copying files. Don't copy /proc over, but do create a mount point for it after you are done. If you didn't or couldn't unmount some of your NFS mounts or cdroms, remember to skip them when you do the copy. Copy everything else using cp -a.
    #mkdir /jfsvol
    #mount -t jfs /dev/hda6 /jfsvol
    #cd /
    #cp -a bin etc lib boot dev home usr var [...] /jfsvol
    #mkdir /jfsvol/proc
    

    3.4 Final setup

    Before we reboot into our new root partition, there are a just a couple of final things that need to be done. First, we need to change the /etc/fstab entry for the root partition, but you need to be certain to change the right one. Remember that the fstab file we want to work with is the one under /jfsvol/etc. So edit this file, and look for the line describing the root partition. Mine looks like this:
    LABEL=/		/	ext2	defaults	1 1
    
    We want to change that to say:
    /dev/hda6	/	jfs	defaults	1 1
    
    You can now unmount /jfsvol. Edit /etc/lilo.conf to point to the new root partition. I'm paranoid, so I like to just copy and paste the one I already have for the jfs kernel and modify the root= line to point to the new partition. You'll also need to give it a new label. The new section on my system looks like this:
    default=jfsboot2
    ...
    image=/boot/vmlinuz-2.4.0-jfs
    	label=jfsboot2
    	read-only
    	root=/dev/hda6
    
    Make sure that you run 'lilo' again before you reboot.

    3.5 Reboot

    Congratulations! If you followed these steps, your system is now running completely on JFS. To verify this, type mount and you should see output similar to this:
    /dev/hda6 on / type jfs (rw)
    none on /proc type proc (rw)
    none on /dev/pts type devpts (rw,gid=5,mode=620)
    
    Assuming everything works well, and you don't want or need to go back to your old system, the old root partition can now be reformatted as JFS and turned into a /home mount, or anything else you want.