Posts Tagged ‘ ext3/ext4 ’

ext3 to ext4 Migration

Before Migrationg Please make sure that the kernel module ext4 is installed in the Present Kernel.

root@server [~]# lsmod | grep ext
ext4                  285409  1 
jbd2                   47744  1 ext4
crc16                   1027  1 ext4
ext3                   94929  5 
jbd                    31739  1 ext3

1. First of all, its recommended to backup everything first. We will us ‘dd‘ command to backup the whole partition to another hard disk. That hard disk is attached via SATA cable. We will format the backup hard disk with ext3 filesystem and and mount as /backup partition:

fdisk /dev/sdb

The sequence I press in the keyboard is: n > p > 1 > enter > enter > w

2. Then, format the partition table /dev/sdb1 with ext3 filesystem:

mkfs.ext3 /dev/sdb1

3. Mount the backup partition to /backup:

$ mkdir /backup
$ mount /dev/sdb1 /backup

4.Lets backup “/” partition and put the image into backup directory:

dd if=/ of=/backup

5.Now we need to install one package called e4fsprogs. The e4fsprogs packages contain a number of utilities for creating, checking, modifying, and correcting inconsistencies in fourth extended (ext4 and ext4dev) file systems:

$ yum -y install e4fsprogs

We start to do the ext4 filesystem conversion:

umount /dev/sda7
tune4fs -O extents,uninit_bg,dir_index /dev/sda7

Please run e4fsck on the filesystem.

As what has been advised, we need to run filesystem check after tune. I rather do this in single-mode (init 1) to reduce risks. DON’T PROCEED TO REBOOT ONCE THIS STEP COMPLETE!

$ init 1
$ e4fsck -fDC0 /dev/sda7
root@server [~]# fsck.ext4 -yfD /dev/sda7
e4fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/home: ***** FILE SYSTEM WAS MODIFIED *****
/home: 127401/14499840 files (2.6% non-contiguous), 985022/28981252 blocks
$ vi /etc/fstab

make it as ext4

Now, all’s OK, just mount it as ext4:

mount -t ext4 /dev/sda7 /home/

If you have converted /boot file system , you need to update /boot/grub.conf. Use your favourite editor to open this file, find out current kernel config section and append the following parameter:


Here is sample config:

title CentOS 5 (2.6.39)
	root (hd0,0)
        kernel /vmlinuz- ro root=LABEL=/ rootfstype=ext4
        initrd /initrd-

Save and close the file. And run update-grub

Next, update your /etc/fstab file so that it can be mounted as ext4 file system by default. And finally, reboot your system

Rebuild the initrd to make sure our system will mount /sysroot as ext4 and reboot the server once complete:

mkinitrd -v -f initrd-