Friday, November 23, 2012


Converting the File System from ext3 to ext2 without data Loss

 

Release:

RHEL

 

Problem:

This document guide you on how to convert an ext3 file system to ext2 file system without data loss.

 

Solution:

In this document we are having a Red hat box with a partition /dev/sdb1 formatted using ext3 file system and mounted under /test directory.

[root@akhisar test]# mount

/dev/mapper/vg_akhisar-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)

/dev/sr0 on /media/RHEL_6.1 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)

/dev/sr0 on /mnt type iso9660 (ro)

/dev/sdb1 on /test type ext3 (rw)

 

We can see that the partition is containing data and the listed output for the /test directory is as below:

[root@akhisar test]# ls

file1   file16  file22  file29  file35  file41  file48  file54  lost+found

file10  file17  file23  file3   file36  file42  file49  file55

file11  file18  file24  file30  file37  file43  file5   file56

file12  file19  file25  file31  file38  file44  file50  file6

file13  file2   file26  file32  file39  file45  file51  file7

file14  file20  file27  file33  file4   file46  file52  file8

file15  file21  file28  file34  file40  file47  file53  file9

 

 

 

Now we are going to convert the file system for the partition /dev/sdb1 from ext3 to ext2.

 

Step 1:

Unmount the partition on which the activity needs to be carried out.

[root@akhisar /]# umount /test

[root@akhisar /]# mount

/dev/mapper/vg_akhisar-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)

/dev/sr0 on /media/RHEL_6.1 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)

/dev/sr0 on /mnt type iso9660 (ro)

 

Step 2:

Clear the has_journal using the tune2fs command along with the “^” string.

[root@akhisar /]# tune2fs -O ^has_journal /dev/sdb1

tune2fs 1.41.12 (17-May-2010)

 

Step 3:

Check the partition for errors by typing the following command as root:

[root@akhisar /]# e2fsck -y /dev/sdb1

e2fsck 1.41.12 (17-May-2010)

/dev/sdb1: clean, 67/42168 files, 6877/168648 blocks

 

Step 4:

Then mount the partition again as ext2 file system by typing the below command:

[root@akhisar /]# mount -t ext2 /dev/sdb1 /test/

 

Step 5:

You can check the same by using the mount option.

 

 

[root@akhisar /]# mount

/dev/mapper/vg_akhisar-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)

/dev/sr0 on /media/RHEL_6.1 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)

/dev/sr0 on /mnt type iso9660 (ro)

/dev/sdb1 on /test type ext2 (rw)

 

Step 6:

Check the data by browsing to the test folder.

[root@akhisar /]# cd test

[root@akhisar test]# ls

file1   file16  file22  file29  file35  file41  file48  file54  lost+found

file10  file17  file23  file3   file36  file42  file49  file55

file11  file18  file24  file30  file37  file43  file5   file56

file12  file19  file25  file31  file38  file44  file50  file6

file13  file2   file26  file32  file39  file45  file51  file7

file14  file20  file27  file33  file4   file46  file52  file8

file15  file21  file28  file34  file40  file47  file53  file9

 

 

**************************************

No comments:

Post a Comment