You know, you should upgrade your Linux file system, but you can’t run into an aggravation? Here’s how to convert ext2 and ext3 to ext4 without doing a full reinstall.
Linux File
If you were being polite, you would call the ext3 filesystem venerable by running it just like it did back in 2001. As for the legacy ext2 , this filesystem was born in 1993 and there’s no other word for it than ancient. In computer terms, ext3 is an antique. And ext2 is an archaeological find.
The modern file system in the Linux world is ext4, released in 2008. It’s faster, less prone to fragmentation, able to handle large filesystems and large files, it has more accurate file date stamps and did we mention that it’s faster? Much faster.
ok i’m sold let’s do it
Let’s think this through. Actually, you probably don’t want to update the file system.
It makes sense to upgrade the entire Linux system instead. By renewal we mean the creation several backing up your data, cleaning your system, reinstalling a modern distribution, and restoring your data. Go to full update. Take advantage of a modern Linux distribution with updated software and a clean, up-to-date and freshly installed file system.
If you can’t run modern Linux on your hardware, even one of the lightweight distributions like Lubuntu, LinuxLite, or CrunchBang++, and you absolutely have to stick with whatever Linux you have, there are still caveats.
To upgrade the file system to ext4, you must use kernel version 2.6.28 or newer. Therefore, if you do not have this kernel version or later, you must update the kernel first.
Warning: don’t even think about it without satisfying that kernel version requirement. You will end up with an unbootable computer. Check which kernel version you are running before proceeding.
Make sure you have the install disk for the version of Linux you are currently using and keep it in idle mode. Updating the file system is not without dangers.
Backups of your safety net. Before you do anything, do couple back up your data to another medium and make sure you have that old Linux installation disc. If something goes wrong, you can reinstall your old Linux and recover your data.
You will also need a current Live CD/DVD of a modern Linux distribution in order to perform a filesystem upgrade. So make sure you have one of those in hand too.
Incidentally, this article was researched using the lively Jackalope as a component of the Ubuntu install, which was released in April 2009 and used ext3 as its filesystem.
Still with us?
John Wayne said that courage was frightened, but still burdensome. I admire guts.
The first thing we are going to do is check the kernel version with uname .uname command can display various types of system information.
On your old Linux computer, open a terminal window and enter the following command. Enter uname space, -r and then press Enter.
uname -r
The version of Linux on this machine uses kernel version 2.6.28-11, so we have met the kernel version requirement.
Seriously, if you don’t meet this requirement, stop. Close enough is just not enough. You must match or exceed this kernel version number.
Now we will check the disk IDs with blkid A that identifies the block devices on the system.
BLKID
This system has one hard drive (SDA) which has a filesystem on it (sda1) which is mounted to /dev/sda1. This is the ext3 file system. This is the file system we are going to convert.
There is also a file system called swap, but we are not interested in that.
Reboot from Live CD
Insert the Live CD and restart your computer. You may need to press a key during the restart in order for the computer to boot from the CD. The key to press will be displayed early in the boot process. Being fast — the window of opportunity doesn’t last long. If you miss this, restart your computer and try again.
After booting into the Live CD environment, make sure you don’t accidentally run the installation. Take the time to read the options that are provided with, and if there is one that says something similar to «Try Distribution Name» select this option.
Become Root
Open a terminal window and enter the following command. This effectively makes you root and means you don’t have to type sudo before each team.
Sudo Баш
Note that the command line has changed. You are the root. carefully.
Define File
We need to identify the filesystems again to see how they appear on this Linux instance.
FDISK -l
You will see output similar to the following.
The file system we previously identified as sda1 was found and recognized by the Linux Live CD. This is the first mini milestone.
The second transformation of the file system.
File system conversion
There are two commands listed here, one for converting from ext2 to ext4 and one for converting from ext3 to ext4. Make sure you are using the right one for you!
To convert from ext2 to ext4 use this:
tune2fs -O экстентов, uninit_bg, dir_index, has_journal / DEV / sda1
To convert from ext3 to ext4 use this:
tune2fs -O экстенты, uninit_bg, dir_index / dev / sda1
It’s a little crushing not much that seems to have happened. You will return to the command line. If you see any output, it will probably be an error message. So no news is good news here.
Check file system
Even though no errors were flagged, let’s take a closer look at the entire file system for problems. We will use a command called e2fsck . It is a tool used to check the integrity of file systems. She can also try to repair any issues he finds. Tool e2fsck works with ext2, ext3, and ext4 file systems.
Option -p (preen) makes e2fsck try to fix errors, and the option -f (force) forces e2fsck check the file system even if the file system seems clean.
e2fsck -pf / DEV / sda1
no errors were logged. Now we can try to mount the file system.
Mounting FileSystem
We need to set up the filesystem table (fstab) and the grub bootloader to work with the converted filesystem. To do this, we must mount the filesystem. We will install it to /mnt. We defined the file system as sda1 before, so our command is:
крепление -t ext4 / DEV / sda1 / мнт
Now that it’s installed, we should be able to enumerate the file system. Let’s check it out. The filesystem root will be at the /mnt mount point.
Ls / мнт
This is reassuring. Looks like we’re looking forward to it.
RELATED:How to Mount and Unmount Storage Devices from the Linux Terminal
Editing fstab
We need to edit the FSTAB file and change all links from ext3 (or ext2 if that’s the filesystem you’ve converted from) to ext4.
The live CD used in this example has nano editor for it. It’s a simple little editor so we’ll use . If a nano is not available on your Live CD, there will be another editor that will be included with the Linux distribution on the CD.
нано / шоссе / и т.д. / Fstab
The editor window will open nano . You need to find occurrences of the string «ext3» or «ext2» and change them to «ext4». In this example, there was one occurrence of ext3 which is highlighted.
ext3 has been replaced by ext4.
You need to save the file and exit the editor. AT nano Ctrl + O will save the file and Ctrl + X will close the editor.
Grub update
Since we mounted the sda1 filesystem on /mnt, the paths to the directories on the filesystem have effectively all been moved one level deeper than usual. That’s why we specified the path to nano/mnt/etc/fstab instead of the usual /etc/fstab.
Since grub expects to find something in certain places, we need the filesystem to look like it was mounted normally. We want the filesystem root to be /, not /mnt. The chroot command allows us to launch a shell and specify the root point we want to use.
Using the command we have:
корневой / мнт
Note that the command line has changed.
Now we can run the command update-grub to have grub read the fstab file and reconfigure itself.
обновление-личинка
,
After grub is reconfigured, we need to install a new grub instance on the hard drive. Note that this is an sda hard drive, not an sda1 filesystem. Do not include «1», just enter «ASD».
grub-install / dev / sda
Linux reboots
Reboot the system and remove the Live CD. When your system reboots, open a terminal window and enter the following command:
BLKID
As we can see the file system is currently an ext4 file system.
The machine that this article was researched on for so long a reboot (over ten minutes) assumed something had gone wrong and that it would never come back up.
Perhaps it was because it was a virtual machine, or perhaps some filesystem transformations happen during the first boot. Somehow, patience won out and it eventually came back. If your machine is doing something similar, wait it out. All cannot be lost.
Subsequent reboots were as fast as usual.
Upgrade Your Linux Instead
Well, we got there. But you are still left with a non-standard hybrid using an old release of Linux on a modern filesystem.
If moving to a new file system is important to you and your hardware can accept it, going to Linux current distribution is the best route to take. You will enjoy all the other security and software benefits you receive.
However, if there is nothing else for it, and sometimes we do not have the opportunity, we want, we do, these steps will allow you to update the file system.