Tuesday, September 23, 2014

How to convert from a JFS to a JFS2 filesystem?

How to convert from a JFS to a JFS2 filesystem?

Is it possible to convert from a JFS to a JFS2 filesystem?

No, a JFS filesystem cannot be converted to become a JFS2 filesystem.
The two types of filesystems have completely different structures and inode allocation methods. There are three recognized methods to move data from a JFS to a JFS2 filesystem.

1. Copy With Parallel Filesystems


If you have the space, creating a second filesystem and simply copying the data is the easiest way.
# crfs -v jfs2 -g myvg -a size=20G -A yes -m /newfilesystem
This will create a 20GB filesystem in volume group "myvg" with mount point "/newfilesystem".

Mount the filesystem:
# mount /newfilesystem

Copy the data from your existing filesystem to it, with a command similar to:
# cd /mydata; pax -w * | (cd /newfilesystem; pax -v -r )

Unmount the current filesystem and rename it:# unmount /mydata
# chfs -m /oldfilesystem /mydata

Rename the mount point of the new filesystem and mount it::# chfs -m /mydata /newfilesystem
# mount /mydata

At this point test your application or check over your data. If all is well remove the old filesystem:# rmfs /oldfilesystem


2. Backup and Recreate


Back up your data on the original filesystem, remove it and recreate as JFS2. Use this when you do not have enough disk space to have the same filesystem existing in parallel.
Back up the data using whatever command you usually use to back up the files.

Unmount and remove the old filesystem:
# umount /mydata
# rmfs /mydata

Create the filesystem again:# crfs -v jfs2 -g myvg -a size=20G -A yes -m /mydata
# mount /mydata

Restore your data to /mydata

3. Alternate Disk Copy for Rootvg


If your filesystems are rootvg ones, neither of these methods will work. However you can use alt-disk copy to create a new rootvg. Using the -T flag will recreate the filesystems as JFS2:

Indicates that you want to convert JFS file systems to JFS2 file systems during the process of recreating the rootvg volume group on target disks.

# alt_disk_copy -T -d hdiskX

where hdiskX is an unused disk not belonging to any volume group.