Converting Filesystems with Fstransform
Fstransform converts a filesystem without formatting the media or deleting any files.
Once you opt for a filesystem, it cannot be changed easily – especially if you already have files on it. Massimiliano Ghilardi changed this with the small Fstransform toolkit: One command is all it takes to change the filesystem.
Filesystems are responsible for how files are stored on hard drives. Unfortunately, a number of them currently are out there vying for that right. On Linux, ext4 is currently popular, with Btrfs waiting in the wings as its replacement. Windows uses NTFS, and its ancestor, FAT32, is particularly prevalent on USB sticks.
Normally, you decide which filesystem to use when you install Linux – if the distribution doesn’t take this decision out of your hands. Then, once the system is in place on the disk, making a change is difficult: To be on the safe side, you have to copy the files to a different disk, then reformat the hard disk completely, and finally copy all the files again and hope all the file attributes have been retained.
The command-line programs of the Fstransform toolkit, however, let you convert one filesystem to another. This means a second hard disk is no longer necessary for intermediate storage. Unfortunately, the Fstransform toolkit also has a few drawbacks.
Not Without My Backup
For example, Fstransform only supports the common filesystems on Linux: ext2, ext3, ext4, ReiserFS, JFS, and XFS. The Windows filesystems NTFS, MS-DOS, and FAT32 are explicitly excluded (Figure 1). The frequent need to convert an old Windows partition to ext4 thus remains unfulfilled.
Additionally, the danger always exists with Fstransform that the conversion will dump all your data into a black hole. Ghilardi expressly assumes no liability for data loss and issues a warning to this effect in the documentation: In other words, if you lose data, it’s your problem. Thus, if you want to use Fstransform, you should create a backup copy first, preferably in the form of an image. Then, you can quickly revert to the previous state if necessary. The Clonezilla Live CD is perfect for this.
For Fstransform to convert the filesystem, the partition must have at least five percent free space. The more free space available, the more smoothly the conversion will work. Ghilardi also advises against converting an almost full partition to the XFS filesystem. The hard disk should have at least 10 percent free space available in this case.
Additionally, the appropriate system tools must be installed for the existing and new filesystem. For example, if you want to upgrade a partition to the XFS filesystem on Ubuntu, you also need support for XFS from the xfsprogs package. But that’s not all: You also need to meet the conditions set out in the “Fstransform Requirements” box. However, this should be no problem for any distribution and for the filesystems already mentioned.
As a fairly young tool, Fstransform has not yet found its way into the distributions. For example, Canonical will not be adding it to its repositories until Ubuntu 12.10. At the moment, you have no alternative but to build Fstransform yourself. However, this is quickly done: First, install the C++ compiler and make using your package manager. On Ubuntu these two are provided by the packages g++ and make. Then, you can download the current Fstransform version from the homepage, unzip the archive on the hard disk, and run the following three commands in the directory created by the last step:
$ ./configure $ make $ sudo make install
If the partition to be converted is currently mounted, you need read and write access. Additionally, programs and processes are allowed to access the partition during the conversion. In other words, Fstransform needs to be able to unmount the partition. This also means you can’t convert the root partition on the fly. If all conditions are met, the only thing you have to do now is call fstransform as the root user. The required parameters are the device file for the partition to be converted and the target filesystem. For example, the command:
# fstransform /dev/sdc1 xfs
converts the first partition on an external hard disk (sdc1) to the XFS filesystem.
In the first step, Fstransform checks to see whether all the tools are present. If you see an error as shown in Figure 2, you should cancel the process by pressing Enter and install the missing programs.
If the partition to be converted is not mounted somewhere, Fstransform mounts it in a directory below /tmp. Some distributions, such as Ubuntu, open the File Manager automatically when this happens. You should immediately close the File Manager window again; otherwise, the next error message will appear in a matter of seconds.
Fstransform now stops once again and offers you one last chance to cancel the entire process by pressing Ctrl+C (Figure 3).
If you want to continue, press the Enter key. After completing the first part of the conversion, Fstransform unmounts the partition you are converting. If anything should go wrong, for some reason, Fstransform lets you know (Figure 4).
An unmountable device is no reason to panic: You can simply open a second terminal window and unmount the partition manually; for example:
$ sudo umount /dev/sdc1
Back in the window with Fstransform, type continue and press Enter.
At some point, a message that Fstransform is ready to go should appear (Figure 5).
Again, press the Enter key then help yourself to a gallon of coffee. The conversion takes about a minute per gigabyte; thus, a partition with 250GB of data can take up to four hours. During this time, you cannot interrupt Fstransform under any circumstances; the best thing is not to touch the system at all until a success message appears (Figure 6).
The fstransform program is just a script; the actual conversion in the background is handled by two programs: fsmove and fsremap. If something should go wrong, you will find several logfiles below /var/tmp/fstransform: fstransform.log.<number> and fsremap.job.<number>/fsremap.log. If fsremap cancels, you can try:
# fsremap --resume-job=Number /dev/sdc1
to continue the task.
Fstransform is extremely useful, especially if you want to convert filesystems that have major technical differences – such as ReiserFS to ext4. Because Fstransform fires some pretty big guns for this job, you should take the warnings very seriously and make sure you have a usable backup. Incidentally, some filesystems come with their own conversion programs, which can be somewhat faster and safer than Fstransform.
To convert older ext filesystems to newer versions, you do not need to rely on Fstransform. The ext developers offer a tool called tune2fs for this task . It can convert an ext3 filesystem to an ext4 filesystem, for example, more conservatively, more quickly, and more safely than Fstransform.
 Sparse file
 “Configuring Filesystems” by Nathan Willis, Linux Shell Handbook, 3rd edition, pg. 35
But if you are not using the latest Linux kernel, your system is insecure.
Home routers will give room for custom firmware but still comply with FCC rules
Frank Karlitschek will continue to lead the open source ownCloud project
“Xenial Xerus” comes with a new packages format and several improvements for the enterprise.
Linux users can now download and install the Windows code editor
New initiative will address security and interoperability concerns around container technology.
Developers can use RHEL as a development platform without a subscription fee.
Windows users will soon have native access to the Bash shell.
Improvements to SMTP will provide better guarantee of confidentiality
Graphics vendor embraces new reality in Linux graphics