File Systems, Know you need to improve your Linux filesystem however can’t face the aggravation? Here’s the way to convert ext2 and ext3 to ext4 with out the upheaval of a complete re-set up.
If you have been polite, you’d name the ext3 file device venerable, launching because it did manner again in 2001. As for poor old ext2, that filesystem hails from 1993, and there’s no phrase for it apart from historic. In pc phrases, ext3 is an antique. And ext2 is an archaeological discover.
The contemporary filesystem in the Linux world is ext4 which changed into released in 2008. It is quicker, less vulnerable to fragmentation, capable of managing larger filesystems—and larger files—it has extra correct file date stamps and did we mention it’s quicker? A lot quicker.
OK, I’m Sold—Let’s Do This
Let’s think this through. Actually, you possibly don’t want to upgrade your filesystem.
File Systems, It makes more experience to upgrade your entire Linux gadget alternatively.
By upgrade we suggest take more than one records backups, wipe your system, re-set up a modern distribution, and restore your records. Go for the entire refresh.
Get the benefits of a modern Linux distribution with up to date software, in addition to a clean, contemporary, and newly established filesystem.
If you can not run a present day Linux in your hardware, even one of the light-weight distributions like Lubuntu, LinuxLite or CrunchBang++, and also you in reality ought to stick with the Linux you’ve were given, there are nonetheless caveats.
To upgrade your filesystem to ext4, you need to be the usage of kernel model 2.6.28 or later. So in case you don’t have that model of the kernel or a later model, you should upgrade your kernel first.
Warning: Don’t even consider trying this without pleasant that kernel version requirement. You’ll grow to be with an unbootable computer. Check which kernel model you’re using earlier than continuing.
Migrate Ext2 or Ext3 File Systems
Make certain you have an installation disk for the model of Linux you’re currently using and keep it on stand through. Upgrading your filesystem isn’t without risks.
Backups are your safety net. Before you do whatever, make multiple facts backups to one of a kind backup media, and ensure you’ve got that old Linux set up disk on hand. If something goes badly wrong, you may then re-installation your antique Linux and restore your information.
You’re also going to want a cutting-edge Live CD/DVD of a cutting-edge Linux distribution to perform the filesystem upgrade with. So ensure you’ve got one of those to hand too.
Incidentally, this article became researched the use of an install of Ubuntu Jaunty Jackalope, which changed into released in April of 2009. It used ext3 because the report machine.
Still With Us?
The first thing we’re going to do is test the kernel model with uname. The uname command can show different types of machine facts.
On your old Linux pc open a terminal window and sort the subsequent command. Type uname , a space, -r, then hit Enter.
The version of Linux in this computer is using kernel model 2.6.28-eleven, so we’ve met the kernel version requirement.
Seriously, If you haven’t met this requirement, stop now. Close enough simply isn’t enough. You ought to meet or exceed this kernel model variety.
Now we’ll take a look at the disk identifiers with blkid, which identifies the block gadgets on the machine.
This gadget has a unmarried difficult drive (sda) which has a file machine on it (sda1) that’s mounted at /dev/sda1. This is an ext3 filesystem. This is the filesystem we are going to convert.
There is also a filesystem referred to as swap, however that doesn’t interest us.
Reboot with the Live CD
Insert the Live CD and reboot your laptop. You can also want to press a key in the course of the reboot to make the computer boot from the CD.
The key to press might be displayed throughout the early levels of the boot-up system.
e quick – the window of opportunity doesn’t closing long. If you leave out it, reboot and attempt again.
File Systems, When you have booted into the Live CD surroundings, make certain you don’t accidentally start an set up.
Take time to study the alternatives you are furnished with, and if there may be one that says some thing just like “Try DistributionName,” pick out that alternative.
Open a terminal window and kind the following command. This efficiently makes you root and way you don’t need to kind sudo in front of every command.
File Systems, Note that the command spark off has modified. You are root. Tread carefully.
Identify the Filesystems
We need to identify the filesystems another time to see how they display up in this instance of Linux.
You’ll see some output similar to the following.
The filesystem we formerly recognized as sda1 has been found and recognized via the Live CD Linux. That’s the first mini-milestone.
File Systems, The second is converting the filesystem.
File Systems, Converting the Filesystem
There are instructions listed here, one for changing from ext2 to ext4 and one for converting from ext3 to ext4. Make positive you use the right one for you!
To convert from ext2 to ext4 use this:
tune2fs -O extents,uninit_bg,dir_index,has_journal /dev/sda1
To convert from ext3 to ext4 use this:
tune2fs -O extents,uninit_bg,dir_index /dev/sda1
It’s slightly underwhelming as no longer a lot seems to show up. You are lower back to the command spark off. If you do see a few output, it is probably going to be error messages. So no news is ideal news right here.
File Systems, Check the Filesystem
Even although no mistakes have been flagged, allow’s be thorough and check the entire filesystem for problems. We will use a command called e2fsck. This is a device used to test the integrity of filesystems. It also can try to repair any issues it unearths. The e2fsck tool works with ext2, ext3, and additionally ext4 filesystems.
The -p (preen) option reasons e2fsck to try and repair errors and the -f (force) option causes e2fsck to test the filesystem although the filesystem appears clean.
e2fsck -pf /dev/sda1
File Systems, No mistakes have been stated. We can now try to mount the filesystem.
Mounting the FIlesystem
We want to adjust the document system desk (fstab) and the grub bootloader to work with the converted filesystem.
To do this, we ought to mount the filesystem. We shall mount it on /mnt. We diagnosed the filesystem as sda1 in advance, so our command is:
mount -t ext4 /dev/sda1 /mnt
Now that it’s miles mounted we have to be able to list the filesystem. Let’s take a look at that. The root of the filesystem goes to be on the mount factor, /mnt.
That’s encouraging. It looks like we’d expect it to.
File Systems, Editing fstab
We want to edit the fstab record and exchange any references of ext3 (or ext2, if that’s the record device you’ve converted from) to ext4.
The Live CD used in this example has the nano editor on it. It’s a simple little editor, so we’ll use that. If nano isn’t always available to your Live CD there may be some other editor as a way to had been bundled by way of the Linux distribution on the CD.
The nano editor window will appear. You want to look for occurrences of the string “ext3” or “ext2” and change them to “ext4”.
In this example, there was one incidence of ext3, that’s highlighted.
The ext3 was replaced by ext4.
You want to keep the record and exit from the editor. In nano Ctrl+O will save the record, and Ctrl+X will near the editor.
File Systems, Upgrading grub
Because we’ve mounted the sda1 filesystem on /mnt, the pathways to the directories inside the filesystem have efficiently all been moved one degree deeper than ordinary. That’s why the path we furnished to nano changed into /mnt/and so on/fstab in place of the same old /and many others/fstab.
Because grub expects to find things in positive places, we want to make the filesystem appear as even though it have been established normally. We want the root of the filesystem to be at / and no longer at /mnt. The chroot command permits us to run a command shell and to specify the root factor we want to apply.
The command we use is:
File Systems, Note that the command activate has changed.
We can now problem the replace-grub command to have grub read the fstab file and reconfigure itself.
Once grub has reconfigured itself, we want to put in a new example of grub at the difficult drive. Note this is the hard force sda, now not the filesystem sda1. Don’t consist of the “1”, just kind “sda”.
File Systems, Rebooting Your Linux
Reboot your system and dispose of the Live CD. When your machine has rebooted, open a terminal window, and input the following command:
As we can see, the filesystem is now an ext4 filesystem.
The machine that this newsletter was researched on took so long to reboot (over ten mins) it changed into assumed something had long gone wrong and that it might by no means come returned up.
Perhaps it became because it changed into a virtual gadget, or perhaps a number of the filesystem conversion takes place all through that first boot up. Either manner, persistence gained out, and it sooner or later did resurface. If your device does something similar, wait it out. All may not be misplaced.
File Systems, Subsequent reboots have been as brief as ordinary.
Upgrade Your Linux Instead
Well, we were given there. But you’re nonetheless left with a non-trendy hybrid the usage of an old Linux release on a modern filesystem.
If moving to a new filesystem is important to you, and your hardware can take it, shifting to a current Linux distribution is the first-class path to take. You will revel in all of the other safety and software blessings that come from doing so.
Still, if there’s nothing else for it—and sometimes we don’t have the alternatives we desire we did—those steps will assist you to improve your filesystem.