{"id":1346,"date":"2012-09-06T11:10:06","date_gmt":"2012-09-06T03:10:06","guid":{"rendered":"http:\/\/rmohan.com\/?p=1346"},"modified":"2012-09-06T11:10:06","modified_gmt":"2012-09-06T03:10:06","slug":"centos-5-converting-ext3-to-ext4","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1346","title":{"rendered":"CentOS 5: Converting Ext3 to Ext4"},"content":{"rendered":"<p> OS: CentOS 5.6 64bit<br \/> Kernel version: 2.6.18-238.19.1.el5<br \/> Backup partition: \/backup (mount from \/dev\/sdb)<\/p>\n<p> 1. First of all, its recommended to backup everything first. We will us \u2018dd\u2018 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:<\/p>\n<p> $ fdisk \/dev\/sdb<br \/> &#8230;..<\/p>\n<p> Command (m for help): n<br \/> Command action<br \/> \u00a0 \u00a0e \u00a0 extended<br \/> \u00a0 \u00a0p \u00a0 primary partition (1-4)<br \/> p<br \/> Partition number (1-4): 1<br \/> First cylinder (1-3916, default 1):<br \/> Using default value 1<br \/> Last cylinder or +size or +sizeM or +sizeK (1-3916, default 3916):<br \/> Using default value 3916<\/p>\n<p> Command (m for help): w<br \/> The partition table has been altered!<\/p>\n<p> &#8230;&#8230;<\/p>\n<p> The sequence I press in the keyboard is: n &gt; p &gt; 1 &gt; enter &gt; enter &gt; w<\/p>\n<p> 2. Then, format the partition table \/dev\/sdb1 with ext3 filesystem:<\/p>\n<p> $ mkfs.ext3 \/dev\/sdb1<br \/> 3. Mount the backup partition to \u00a0\/backup:<\/p>\n<p> $ mkdir \/backup<br \/> $ mount \/dev\/sdb1 \/backup<br \/> 4. Lets check our partition summary:<\/p>\n<p> $ df -h<br \/> Filesystem \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Size \u00a0Used Avail Use% Mounted on<br \/> \/dev\/mapper\/VolGroup00-LogVol00<br \/> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a047G \u00a03.3G \u00a0 41G \u00a0 8% \/<br \/> \/dev\/sda1 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a099M \u00a0 20M \u00a0 75M \u00a021% \/boot<br \/> tmpfs \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 501M \u00a0 \u00a0 0 \u00a0501M \u00a0 0% \/dev\/shm<br \/> \/dev\/sdb1 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a076G \u00a0173M \u00a0 75G \u00a0 1% \/backup<br \/> 5. Lets backup \u201c\/\u201d partition and put the image into backup directory:<\/p>\n<p> $ dd if=\/dev\/VolGroup00\/LogVol00 of=\/backup\/VolGroup00-LogVol00.bak<br \/> 100466688+0 records in<br \/> 100466688+0 records out<br \/> 51438944256 bytes (51 GB) copied, 807.368 seconds, 63.7 MB\/s<br \/> 6. 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:<\/p>\n<p> $ yum -y install e4fsprogs<br \/> 7. We start to do the ext4 filesystem conversion:<\/p>\n<p> $ tune4fs -O extents,uninit_bg,dir_index \/dev\/VolGroup00\/LogVol00<br \/> tune4fs 1.41.12 (17-May-2010)<\/p>\n<p> Please run e4fsck on the filesystem.<br \/> 8. 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\u2019T PROCEED TO REBOOT ONCE THIS STEP COMPLETE!<\/p>\n<p> $ init 1<br \/> $ e4fsck -fDC0 \/dev\/VolGroup00\/LogVol00<br \/> &#8230;&#8230;&#8230;<br \/> Group descriptor checksum is invalid. FIXED.<br \/> Adding dirhash hint to filesystem.<\/p>\n<p> Pass 1: Checking inodes, blocks, and sizes<br \/> Pass 2: Checking directory structure<br \/> Pass 3: Checking directory connectivity<br \/> Pass 3A: Optimizing directories<br \/> Pass 4: Checking reference counts<br \/> Pass 5: Checking group summary information<\/p>\n<p> \/dev\/VolGroup00\/LogVol00: ***** FILE SYSTEM WAS MODIFIED *****<br \/> \/dev\/VolGroup00\/LogVol00: ***** REBOOT LINUX *****<br \/> \/dev\/VolGroup00\/LogVol00: 112086\/12558336 files (0.7% non-contiguous), 1252590\/12558336 blocks<br \/> 9. Change the \/etc\/fstab to make sure the system will mount the new ext4 filesystem afterwards:<\/p>\n<p> $ vi \/etc\/fstab<\/p>\n<p> Change following line:<\/p>\n<p> \/dev\/VolGroup00\/LogVol00 \/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ext4 \u00a0 \u00a0defaults \u00a0 \u00a0 \u00a0 \u00a01 1<br \/> 10. Rebuild the initrd to make sure our system will mount \/sysroot as ext4 and reboot the server once complete:<\/p>\n<p> $ mkinitrd -v -f initrd-2.6.18-238.19.1.el5.img 2.6.18-238.19.1.el5<br \/> $ init 6<br \/> 11. If we directly reboot after fsck on step 8, then we will have kernel panic, unless the kernel is 2.6.28 and later. Once up, lets check whether is it run on ext4 or not:<\/p>\n<p> $ mount | grep ext4<br \/> \/dev\/mapper\/VolGroup00-LogVol00 on \/ type ext4 (rw)<\/p>\n","protected":false},"excerpt":{"rendered":"<p> OS: CentOS 5.6 64bit Kernel version: 2.6.18-238.19.1.el5 Backup partition: \/backup (mount from \/dev\/sdb)<\/p>\n<p> 1. First of all, its recommended to backup everything first. We will us \u2018dd\u2018 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 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1346"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1346"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1346\/revisions"}],"predecessor-version":[{"id":1347,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1346\/revisions\/1347"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}