Do you know that you should update your Linux file system, but can not face the difficulty? Here's how to convert ext2 and ext3 to ext4 without breaking a full reinstall.
Linux file systems
If you were polite, you would call the ext3 filesystem venerable and start it as you did in 2001
The modern file system in the Linux world is ext4, released in 2008. It is faster, less fragmentation-prone, able to handle larger file systems – and larger files. It has a more accurate file date stamps and did we mention that it is faster? Much faster.
OK, I'm sold – let's do that.
Let us think that through. Actually, you probably do not want to update your file system.
It makes more sense to upgrade your entire Linux system instead. By upgrading, we mean that you perform a few backups delete your system, reinstall a modern distribution, and restore your data. Go for the full update. Take advantage of a modern Linux distribution with updated software and a clean, up-to-date and newly installed file system.
If you can not run modern Linux on your hardware, you can also use one of the lightweight distributions like Lubuntu, LinuxLite, or CrunchBang ++, and you have to adhere to the existing Linux.
To upgrade your file system to ext4, you must use kernel version 2.6.28 or later. So, if you do not have this or any later version of the kernel, you must first upgrade your kernel .
Warning : Do not even think about doing this without trying this kernel version requirement. At the end, a computer that can not be booted is available. Check what kernel version you are using before proceeding.
Make sure you have an installation disk for the currently-used Linux version and keep it in standby mode. Upgrading your file system is not without its risks.
Backups are your safety net. Before doing anything, create some backups on different backup media and make sure you have the old Linux installation diskette handy. If something goes wrong, you can reinstall your old Linux and recover your data.
You also need a current live CD / DVD of a modern Linux distribution to perform the file system upgrade. So make sure you have one too. Incidentally, this article was researched with an installation by Ubuntu Jaunty Jackalope, which was released in April 2009. It was ext3 used as a file system.
Still with us?
John Wayne said that the courage is frightened, but still gets going. I admire your courage.
First, we check the kernel version with
uname . The command
uname can display various types of system information.
Open a terminal window on your old Linux computer and enter the following command. Type
uname a space
-r and then press Enter.
The version of Linux on this machine uses kernel version 2.6.28-11, so we met the kernel version requirement.
Seriously: If you have not met this requirement, stop now. Close enough is simply not enough. You must meet or exceed this kernel version number.
Now we check the disk IDs with
blkid which identifies the block devices in the system.
This system has a single hard disk (sda) on which there is a file system (sda1) mounted under / dev / sda1. This is an ext3 file system. This is the file system we will convert.
There is also a file system called swap, but we do not care.
Restart with the live CD.
Insert the Live CD and restart your computer. You may need to press a key during the restart to start the computer from the CD. The button to be pressed is displayed at the start of the boot process. Be fast – the time window will not last long. If you miss it, restart it and try again.
If you started the live CD environment, make sure you do not accidentally start an installation. Take time to read the options that are provided to you. If an option is similar to the "Try DistributionName" option, select this option.
Open a terminal window and type the following command. This effectively makes you root and means you do not have to type
sudo before each command. Sudo bash
Note that the command prompt has changed. You are root. Be careful.
Identifying the File Systems
We need to re-identify the file systems to see how they will appear in this Linux instance.
An output similar to the following is displayed.
The file system was recognized by us as the Live CD Linux. This is the first mini milestone.
The second is the file system conversion.
Conversion of the file system.
Here are two commands listed, one for converting ext2 to ext4 and one for converting ext3 to ext4. Make sure you use the right one for you!
Use this option to convert from ext2 to ext4:
tune2fs -O extents, uninit_bg, dir_index, has_journal / dev / sda1
Use this option to convert from ext3 to ext4:  tune2fs -O-Extents, uninit_bg, dir_index / dev / sda1
<img class = "alignnone size-full wp-image-424910" data-pagespeed-lazy-src = "https: //www.howtogeek. com / wp-content / uploads / 2019/06 / ext3_7.png.pagespeed.ce.6y4-lfnEWr.png "alt =" tune2fs -O-Extents, uninit_bg, dir_index / dev / sda1 in a terminal window "width =" 646 "height =" 57 "src =" /pagespeed_static/1.JiBnMqyl6S.gif "onload =" pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this); " onerror = "this.onerror = null; pagespeed.lazyLoadImages.loadIfVisibleAndMay] little overwhelming, because not much seems to happen, you will return to the prompt, so if you see an issue, it's probably error messages, so there are no good ones here Messages.
Check the file system.
Even if no errors have been flagged, we should be thorough and check the entire file system for problems, we will use a command called
e2fsck .This is a tool It can also try to fix detected problems The tool
e2fsck works with ext2, ext3, and also ext4 file systems.
-p (preen) causes e2fsck to fix bugs and tool
-f (force) causes
e2fsck to check the file system fen, even if the file system appears to be clean.
e2fsck -pf / dev / sda1
No errors were reported. We can now try to mount the file system.
Mounting the file system
We need to customize the file system table (fstab) and the grub bootloader to work with the converted file system. For this we have to mount the file system. We will mount it on / mnt. We used to identify the file system as sda1, so our command is: mount -t ext4 / dev / sda1 / mnt
19659006 ] Now that it's mounted, we should be able to list the filesystem. Let's check that. The root of the file system is at mount /mnt.[19659021)ls/mnt
<img class = "alignnone size-full wp-image-424956" data-pagespeed-lazy-src = "https: // www. howtogeek.com/wp-content/uploads/2019/06/ext3_12.png.pagespeed.ce.aGxOQiy0WH.png "alt =" mount -t ext4 / dev / sda1 / mnt in a terminal window. "Width =" 646 "height = "132" src = "/pagespeed_static/1.JiBnMqyl6S.gif" onload = "pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this);" onerror = "this.onerror = null; pagespeed.lazyLoadImages.loadIfIfVisibleA 
That's encouraging, it looks like we're expecting it.
RELATED: Hanging in and out of storage devices from the Linux terminal
We must edit the fstab file and change any references to ext3 (or ext2, if this is the file system from which you converted in ext4.
The live CD used in this example has the editor
nano it's a simple little editor, so we'll use it if
nano does not is available on your live CD, another editor is bundled by the Linux distribution on the CD.
nano / mnt / etc / fstab
The editor window
nano is displayed. You must look for occurrences of the string "ext3" or "ext2" and change them to "ext4". In this example ext3 is highlighted.
The ext3 was detached from 19459904 window with ext4 highlighted "width =" 646 "height =" 382 "src =" /pagespeed_static/1.JiBnMqyl6S.gif "onload =" pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this) ; "onerror =" this.onerror = null; .lazyLoadImages.loadIfVisibleAndMaybeBeacon (this); “/>
You must save the file and exit the editor. In
nano the file is saved with Ctrl + O, and Ctrl + X closes the editor.
Because we have mounted the file system sda1 under / mnt, the paths to directories in the file system have been moved virtually all one level deeper than usual. Therefore, the path that we have given for nano was, / mnt / etc / fstab instead of the usual / etc / fstab [19659006<DagruberwartetdassDingeanbestimmtenOrtengefundenwerdenmüssenwirdafürsorgendassdasDateisystemsoaussiehtalsobesnormalgemountetwäreWirbrauchendieWurzeldesDateisystemsum/undnichtum/mntMitdemBefehlchrootkönnenwireineBefehlsshellausführenunddenzuverwendendenStammpunktangeben
The command we use is:.
chroot / mnt
Note that the command prompt has changed.
We can now issue the command
update-grub so that the fstab file is scanned and reconfigured.
After grub has reconfigured, we need to install a new instance of grub on the hard drive. Note that this is the sda hard drive, not the sda1 file system. Do not enter "1" but "sda".grub-install / dev / sda
<img class = "alignnone size-full wp-image-424964" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content /uploads/2019/06/ext3_18.png.pagespeed.ce.yozW3ZJg9n.png "alt =" grub-install / dev / sda in a terminal window "width =" 646 "height =" 57 "src =" /pagespeed_static / 1 .JiBnMqyl6S.gif "onload =" pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this); " onerror = "this.onerror = null; pagespeed.lazyLoadImages.loadIfVisibleA [this] 19659007] Restart Linux
Reboot your system and remove the live CD. When your system has rebooted, open a terminal window and type the following command:blkid
<img class = "alignnone size-full wp-image-424965" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp- content / uploads / 2019/06 / ext3_19.png.pagespeed.ce._MR1DzWSZE.png "alt =" blkid in a terminal window "width =" 585 "height =" 184 "src =" / pagespeed_static / 1 .JiBnMqyl6S.gif " onload = "pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this); "onerror =" this.onerror = null; pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this);  now an ext4 file system.
The computer on which this article was researched took so long to reboot (over ten minutes) that it was assumed that something had gone wrong and that it would never come up again.
Maybe it was because it was a virtual machine, or maybe part of the file system conversion takes place during the first startup. In both cases, the patience won, and finally it reappeared. If your machine does something similar, wait and see. Maybe not everything is lost.
Subsequent restarts were as fast as normal.
Update your Linux instead.
Well, we are here. However, they still have a non-standard hybrid with an old Linux version on a modern file system.
If moving to a new file system is important to you and your hardware can handle it, then switching to a recent Linux distribution is the best way to go. You will enjoy all the other security and software benefits that come with this approach.
However, if there's nothing else - and we sometimes do not have the options we wanted - you can use these steps to upgrade your file system.