| news - about me - my system - columns - blackbox styles - projects - licenses - the curse - contact | |||
|
Switching from an ext2 to an ext3 filesystem |
|
||
|
path xlife columns 20020211 |
|||
Switching from an ext2 to an ext3 filesystemXlife column for February 11, 2002:Summary:
1 IntroductionIn case you're wondering: a "filesystem" is a term used to designate the way an operating system organizes the files and directories on a hard-drive. Actually not only on a hard-drive but on CD-ROM's, flexible disks and generally any data storage medium. Different mediums and different operating systems use different filesystems. Linux traditionally uses ext2, or "the second extended filesystem". It's a good filesystem, which supports long filenames and the Unix-specific permission among other things. However, one thing is missing from version 2 of ext, and that is journaling. Journaling is a neat feature for a filesystem. Basicly, it means that the kernel (the core of the operating system) mantains an image of the filesystem's state at all times using a file on the disk. This image is updated often (every few seconds) or so, but only if everything is OK. Should something bad happen, like a system freeze which would require a cold reboot, the system would simply use the image to restore the filesystem to the last consistent state. This also eliminates the need for those long checks at reboot on such ocasions. So, I offer you a way to stay close to ext2, but still benefit from journaling. The solution is ext3, which has been described as "half a filesystem", because all it does is exactly this, add journaling to ext2. You may say: if I need a better filesystem, why not turn to an altogether different (and more advanced) one? ReiserFS or XFS are some of the best Linux filesystems around, and I encourage you to go have a look at them because they offer more than just a patch. However, switching to a completely different filesystem is more complicate than to patch ext2 over, that's why some of you may want to go for the quick gain with minor hassle. 2 How does the switch work?The switch involves converting an ext2 based system (most Linux distributions) to ext3. In order to do this you'll need to update these: the kernel, the disks-maintenance utilities, the filesystem itself and the configuration files. 3 Updating the kernelYou need to update the kernel because it is the one that will do the journaling and all the work involving the filesystem. Changing a vital part of the operating system, such as the filesystem, absolutely needs to be known by the kernel. The easiest way to update is to use kernel version 2.4.15 or later (it's the version in which native ext3 support was added; you may run into web pages saying you need 2.4.16 -- I checked the changelogs for these kernel versions and it's definitely 2.4.15). For earlier kernel versions you'll need to get patches (either 2.4.x patches or 2.2.x patches) which you apply to the kernel source in order to add ext3 functionality. No matter if you use a kernel with native ext3 support or you add it by patches, you get down to this: you'll need to recompile the kernel and enable the following options: ext3 support and JBD debugging (they're in the "filesystems" section of the configuration). WARNING: these options have to be compiled as static kernel parts! DO NOT COMPILE THEM AS MODULES! It's a "chicken and egg" reason behind this: unless you do it, upon system start the kernel will find itself in the situation to read the modules which "teach" it how to handle ext3 filesystems from an ext3 filesystem! Once you have the new kernel you can reboot and use it just fine, because it also knows ext2 filesystems (you left those options in, hopefully :) and your systems is still on ext2 at this stage. 4 Updating the disk-maintenance utilitiesThe utilities for both ext2 and ext3 maintenance are called e2fsprogs. Ext3 support was added since version 1.22, so be sure you get and install at least that version if you don't have it already. You're still OK after you've done this, since e2fsprogs 1.22+ handle ext2 and ext3 equally well. In case you plan to have ext3 partitions which will be auto-mounted, you also need to upgrade your util-linux package. 5 The line of no return!So far you are still OK, but once you start applying the changes below, KEEP GOING UNTIL THEY'RE ALL DONE! Doing otherwise will leave your system in an unstable state and you may lose everything on the affected disks! 6 Convert partition[s] to ext3Identify the partitions you want to convert from ext2 to ext3 and run the following command for each of them. In my case, I have the root partition on hda5, so it will go like this: tune2fs -j /dev/hda5 That -j option means, you guessed it, ext3 conversion. Apply it to any other partitions you want to convert. It would be a good idea to do this with some test partition first, not a vital one, just in case. 7 Modify configuration filesThere is one configuration file which needs to be modified, and that is /etc/fstab. You need to identify the line describing ALL converted partitions and change the ext2 keyword to ext3. This is how your fstab may look at first: LABEL=/ / ext2 defaults,grpquota,usrquota 1 1 LABEL=/data /data ext2 defaults 1 2 /dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0 /dev/fd0 /mnt/floppy vfat noauto,owner 0 0 none /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 /dev/hda6 swap swap defaults 0 0 And this is how it should look afterwards: LABEL=/ / ext3 defaults,grpquota,usrquota 1 1 LABEL=/data /data ext3 defaults 1 2 /dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0 /dev/fd0 /mnt/floppy vfat noauto,owner 0 0 none /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 /dev/hda6 swap swap defaults 0 0 Only do this for the partitions that you have previously converted to ext3! Attempting to use an ext2 partition as ext3 will most likely mess it up permanently! 8 Reboot and enjoyMake sure you're booting with the ext3-enabled kernel, this is important. Actually, you should take measures to make sure you don't accidentaly use an ext2-only kernel, whatever boot loader you may be using. In case you've done everything right, during system loading you'll something like ext3 journaling started (commit interval 5 seconds). You'll also notice a file named .journal under the root directory of each converted partition, it's the journaling image. Needless to say, don't play with it in any way. 9 Mantaining ext3You can fine-tune the ext3 partitions using various features: you can adjust the commit interval, disable automatic checkup upon system crash, create new ext3 partitions directly or perform other ext2 to ext3 conversions. You can find excellent information about these various tasks and more on the following pages: < Back to the top | Read other columns | Choose what column I should write next! > |
|||
|
Xlife ©2001-2009 Zuavra. All rights reserved. You are welcome to link to this site's text pages, but you must get explicit permission before you may reproduce or quote their contents. You may not link directly to binary files, such as images or tarballs. I do keep logs, you know, and offending sites will get their links redirected to shameful error messages. |
|||