How to Defragment Linux JFS
All file systems are subject to some level of fragmentation. Most computers that run the Linux operating system do not need defragmenting because the file system has defragmentation codes in place to prevent fragmentation from occurring. One of the file systems you can install for Linux is the Journaled File System (JFS). JFS was originally ported from the OS/2 operating system, so the defragmentation codes that are in place do not entirely correct fragmentation issues within Linux. You will need to manually defragment JFS to increase system performance.
Instructions
-
-
1
Log in to Linux as root.
-
2
Open a terminal window within Linux.
-
-
3
Type the script below into the terminal window:
umount /dev/hdc1
dd bs=4k if=/dev/hdc1 of=/dev/hdj1
jfs_fsck /dev/hdj1
mount -o ro /dev/hdj1 /fs/hdj1
jfs_mkfs /dev/hdc1
mount -o rw /dev/hdc1 /fs/hdc1
(cd /fs/hdj1 && tar -cS -b8 --one -f - .) | (cd /fs/hdc1 && tar -xS -b8 -p -f -)
umount /dev/hdj1
This script will unmount your hard drive, save the data on your hard drive and format the hard drive. Your data will then be copied back to your hard drive without fragmentation and the drive will be re-mounted. This is the only way to properly defragment your hard drive when using JFS.
-
1
Tips & Warnings
You must type the script in correctly without errors or you will risk wiping your entire hard drive without a chance for recovery.
- Photo Credit Hemera Technologies/Photos.com/Getty Images