Home page of this blog

Sunday, January 31, 2010

This article tries to help someone like me who want to migrate from one filesystem in linux to another filesystem. I converted my debian squeeze ext4 partition to ext3 and could not find a similar blog posted on net when I tried to convert.

I got my partition converted from ext4 to ext3 after multiple tries and found it rather simple than what I thought earlier. The article requires command line skill and a boldness to try out (and maynot work, so I disclaim any problems because of this, you are on your own to try out and may not worry if you backed up your data)

Missing Parts

Skip reading missing parts and jump to Requirements to directly start reading the core/gist of the article. But missing parts is my effort in trying to give the background information about why I wrote (writing) this article, what is required, so if you have time and patience, please read

I wanted to put many screenshots (not just from virtualbox, I wanted to put actual screenshots), proof read, format properly and make the article look more professional. But again, I am putting whatever I am drafting, I will try to refine it later

When I told my friend, how I converted my ext4 partition to ext3, he asked me to post it in my blog, as it may help someone though it is text only and feels vague with command line geekiness

I request readers to forgive my grammatical/technical mistakes. You can post your comments on mistakes and I will try to correct it. Again, I can only read your comments over weekend, as that is the only time I am a bit free. After all I am prone to mistakes as I am human

Now I will try to put whatever I tried as requirements and steps. These requirements are real as without them, the migration of ext4 to ext3 can never materialize.

For example, I used many live CD sessions to migrate (opensuse 11.2, Fedora 12, Ubuntu 9.10, Parted Magic 4.6, System Rescue CD, Arch Linux live USB and Linux Mint 8). All of the above listed live sessions crashed in the middle due to graphics driver or some weird memory overflow problem except Linux Mint 8 and Ubuntu 9.10. Especially, Fedora 12 was completely unusable for doing rescue work on systems with nvidia graphics card. Of the two, Linux Mint 8 and Ubuntu 9.10, I liked linux mint 8, as command line highlighted root in red color and grep selections were colorful. Linux Mint 8 felt very close to command line work, though it supported well, modern graphics restricted drivers

I will tell you, first time I got amazed by the stability of Linux Mint 8, kudos to Linux Mint 8

Requirements

To migrate from a ext4 to ext3 is not straightforward and so requires the following.

If you are converting a partition of size 30 GB, ensure you have 31 GB of free space in another partition. Having free space in external hard disk is recommended.

When I tried migrating my home partition which was 7 GB size, I used a external hard disk formatted in ntfs (Seagate 320 GB portable hard disk) which had free size

You should require a live CD and I recommend using Linux Mint. I used Linux Mint 8 64 bit version to migrate both my home and root partitions from ext4 to ext3

If you have a NVIDIA or a ATI radeon graphics card or an intel graphics card whose drivers are restricted, then you should be having an internet connection to download the restricted drivers and install in linux mint live session. This is because, when I tried using parted magic live cd to migrate, it was way fast, but the graphics driver crashed due to too much of prints (I enabled verbose mode to see what is happening). Except linux mint 8 and Ubuntu 9.10 none of them worked with nvidia as they used by default nv driver (which crashes if lots of text prints in command line)

Linux Mint 8 is better with its command line than Ubuntu 9.10 as it shows root as red and way easy to handle. Kudos to linux mint. But you can try with Sabayon Linux live CD or Mandriva live CD as they all enable restricted graphics drivers while booting into live session. A word of caution for nvidia owners, Fedora 12 crashes with its nouveau and unfit for live CD work. opensuse 11.2 is also good, but again it crashed after stressing live cd for a while

To summarize the requirements, they are

1. Linux Mint 8 live CD (use 64 bit linux mint version if your processor is 64 bit) or Sabayon Live CD or Mandriva One Live CD. Again I recommend Linux Mint 8 for systems with nvidia graphics card, it felt like rock solid

2. External hard disk with enough space or more free space than the partition we want to migrate. External hard disk is recommended, but if there is a spare partition with enough free space in the same hard disk that is also fine

3. Internet connection for fetching/installing restricted graphics drivers in live session if you have nvidia/ati radeon graphics card

4. A UPS (Uninterruptible Power Supply), if your partition is large and if you fear, there might be a power cut

Migration in gist is like a short summary or easy to remember points of how to convert from ext4 to ext3 (or any filesystem to any filesystem)

If you are geeky, you already knew it. You can easily migrate from one partition to another by just reading the following summary.

If you are not geeky, feel no fear, the later part of article, tries to explain each of the summarized table of contents, as much as possible by me. If you still feel, you can't migrate, take help from your geeky friend who is near and dear to you

Migrating a filesystem from one format to another requires tremendous patience. If you are impatient, please do not try it as it may damage your data. I tried a whole day after migrating my partition as grub was not working, when I just figured I missed boot flag after a whole day of trying various stuff with grub2

How the steps are presented here?

Each step, I tried to explain in detail. If there is any link which is quoted, please follow them for further information on that subject.

There is a fallback in each section, Fallback is in red color highlight signalling a warning. This is to ensure, if the step fails, what should be done to avoid problems or how to make the step work properly

I highlighted in green color, wherever I felt surprised when something worked, when I thought some more has to be done!

Enabling restricted driver, downloads extra packages from internet, so this step additionally requires an internet connection, preferably ethernet connection (but I did using wireless as that is enabled by default in Ubuntu 9.10/Linux Mint 8 by default)

If you can't use restricted graphics drivers, there is no guarantee, lots of printing in screen will not cause a hang. So note down, if you run with basic graphics drivers, not to enable verbose while doing a tar operation

This step is straightforward in Linux Mint 8/Ubuntu 9.10. Just click the partition you want to mount in nautilus. To goto nautilus, double click Computer icon on the desktop.

The screenshot shows 4.1 GB home partition which I installed as ext4 inside virtualbox, just to demonstrate how the migration works from ext4 to ext3

The following is a spare partition which is 11 GB in size and no data inside it. I just mounted it by clicking 11 GB icon from left navigation bar of nautilus. To unmount you can see that red colored triangle next to the mounted partition. Isn't it superb?

Following screenshot shows, both partitions mounted on linux mint desktop

Fallback

Ensure you did not mount your ntfs partition or some other partition by mistake. It is simple, you know the files inside it. Open the partition and see some sample files/folders. If they are from a different partition, which you did not want to mount, no problem, press the triangular icon next to the partition you mounted to unmount it. Oh oh, Linux Mint 8/Ubuntu 9.10 rocks here by allowing us to mount/unmount with a mouse click

Mount another partition which has enough free space. I recommend using an external hard disk or another hard disk. Why ? Because reading and writing on same hard disk makes your hard disk to spin more and requires more time. If you have external hard disk or another hard disk, use it as a temporary storage to help you migrate your partition file system type.

Again mounting your external hard disk is easy in Linux Mint 8/Ubuntu 9.10. It is a plug and a play. Just plug it and it gets mounted in Linux Mint 8/Ubuntu 9.10!! The mounted external hard disk pops up a new file browser window

Even if your spare partition is ntfs, feel no fear. Ubuntu 9.10 and Linux Mint 8 comes with a fuse driver for mounting your ntfs partitions writable. You don't need to do an extra step in Ubuntu 9.10/Linux Mint 8

How do you find, how much free space you require for migrating? Oh it is easy in Ubuntu 9.10/Linux Mint 8. Just run gnome-system-monitor and goto last tab (File Systems), to see how much space is occupied by each of your mounted partitions

The screenshot below shows, the 4.1 GB home filesystem as ext4 and the spare partition as ext3 along with size available and size used. Your spare partition size available should be greater than size used of the partition you intend to convert

In the above screenshot, the one highlighted in green color is ext4 (which I installed inside virtualbox using linux mint 8 to demonstrate how the ext4 to ext3 works)

Fallback

If you do not have a spare partition, or if your spare partition size is lesser than or equal to the size of data on your hard disk, do not try to migrate or proceed further

You can also launch terminal from Applications --> Accessories --> Terminal in Ubuntu 9.10

or just clicking Terminal after clicking Menu in the bottom right

To become root, use sudo su

In linux mint 8, after you become root, the root prompt will change into a cute red color

If you are using any other linux, use su command to become root, for this, you should have root account password

Fallback

If your live CD does not allow you to become root, it is not a right live CD you should use. Some live CD have passwords for root which you can learn from the site where you downloaded them. Use Linux Mint 8 or Ubuntu 9.10 instead as you can use sudo su

Do not copy the contents to external hard disk directly as it may not preserve permissions. This step creates a tarball of your home partition

After becoming root, we come here.

There are two partitions we already mounted in step 4, the partition which we want to convert and the backup partition.

Now we need to know the exact path of each partition before we operate.

click Computer icon on desktop, click the partition you wanted to convert and copy its path from location bar. The location bar can be activated by giving Ctrl + L inside the file browser

See the above screenshot, I copied the entire path of the home partition I mounted, by giving Ctrl + L and then right clicked my mouse and pressed copy

After copying the path, paste it after cd command in your root terminal. See the screenshot below

Now we should make a tarball of the mounted partition recursively

Before that we should know the path of the backup partition, where we wish to place the zipped partition. It is similar to copying the path like before, see below screenshot, how I copied the path of the backup partition

Whatever path you copied in the above step, paste after tar cvzfp in root terminal. After that give a name for your zipped partition, say zipped-home.tar.gz in this case (you can name however you like) followed by a space and a dot (this dot is very important, which means from current directory, the reason why we first changed directory to the partition which we want to backup

The above command is very powerful. The command zips all the files and folders under the current directory, see the last dot in the command do not miss that dot. The permissions of zipped files and folders will be preserved as we gave p option, the zipped will be compressed with gzip compression. The output file zipped-home.tar.gz will go inside the backup partition, whose path we copied. The extension should be tar.gz or tgz which allows us to uncompress the archive whenever we like easily

the following is the generic syntax to create a backup is, replace <backup path> with the path of the backup partition and <backup archive> with the name you like. for this to work, you should first cd to the path which you need to backup (read this step slowly from beginning to understand, how I did changed directory to the partition, which I wanted to backup)

tar cvzfp <backup path>/<backup archive>.tar.gz .

Fallback

option v should not be given when running with a basic video driver(it should be tar czfp instead of tar cvzfp if you have an nvidia card and you did not install a restricted nvidia driver in live session), as it may hang system

In the previous step tar command ensures, the backup archive is created directly inside your spare partition. But there is a catch, don't think it is written to disk.

Ensure it is written well, by calling sync.

sync

Remove external hard disk and plugg it in to check if the tarball is intact (or is there where you created). Further, tabulate tarball to check if all permissions are intact. This is simple, in Linux Mint 8, just mount the tar.gz to see if all the files are zipped properly

See the following screenshot to see how the archive manager tabulates archive, if you wish command line, you can use tar tvzfp .tar.gz which gives more control

Fallback

Please do not tabulate, if your RAM capacity is less or if you are running on a basic video driver on an nvidia card. Also do not double click the archive, if you have very less RAM

This is where the real migration starts. The partition which we wish to migrate to a different filesystem needs to be reformatted. To achieve this, we need to unmount it first.

8.1 Unmount the partition to be converted after you created a tarball of it and saved it in backup partition

The partition which we want to migrate to ext3 from ext4 needs to be unmounted. This can be done from command line or using nautilus file browser in Linux Mint 8. After the previous step, get outside of the directory which we archived by giving just

cd

The above will ensure, no process is accessing the filesystem which is to be unmounted

Then goto filebrowser by double clicking computer icon on desktop and press the red triangle to unmount the ext4 partition which you archived in earlier 2 steps

See the below screenshot, I am right clicking and unmounting the partition, which can be done just by clicking the red triangle after the partition

You can also use umount command to unmount the partition (unless you are a geek you won't do this)

8.2 Use gparted to format the partition you intended to converted to the desired partition type

run gparted from Menu or using Alt + F2 or through System --> Administration --> Partition Editor under ubuntu

Right click the ext4 partition you wanted to convert to ext3 from ext4 and select Format to --> ext3

Screenshot below shows, I formatted my ext4 to ext3

Fallback

Do not by mistake format a different partition. Do not by mistake format a different drive. Do not forget to close gparted after doing your partitioning

This is as simple as clicking in Linux Mint 8. Click the newly formatted partition.

Tuning your newly created partition

ext2/ext3/ext4 comes with an excellent tune2fs command, which can be used to tune filesystem further. Ensure partition is not mounted when you give tune2fs

You can tune your newly created partition reserved space by using the following trick.

tune2fs -m 0 /dev/sda<N>

Change the <N> to the correct partition number of your choice. -m 0 tells tune2fs to reserve zero percent. Suppose you want to reserve 1 percent it should be tune2fs -m 1 /dev/sda5 tells tune2fs to reserve 1 percent for sda5

The above tunes my newly created partition reserved space to zero percent. This will be helpful if the partition you created is large. Say you have a 400 GB partition, by default gparted reserves 5 percent of 400 GB which is huge and I use tune2fs to reduce the reserved space. I learned this trick from arch linux wiki

Fallback

Don't forget to set the boot flag, if you are migrating your root partitions. Goto gparted and set the boot flag if you are migrating your root partition. I struggled a whole day just forgetting to set boot flag and figured it after much trial and error

This is where we recreate and do the penultimate step in migrating to the new file system. This can be done step by step

1. change directory to newly reformatted partition

As earlier, you can copy the path of the newly mounted partition from file browser in linux mint 8/ubuntu 9.10

In Linux Mint 8 there is another trick, which allows opening terminal from the folder!!

See the below screenshot, I opened terminal from the newly mounted path and became root by giving sudo su

2. unzip the backed up archive

This step restores the entire file system content with permissions intact. Hurray, here the tar archiver works miracles, by allowing us migrate to the new filesystem type. To do this, we need to know the path of the archive we backed up. Open filebrowser and use Ctrl + L to copy the path of the backup partition, where we created a tarball of the partition earlier

the following is the generic syntax to extract a backup, replace <backup path> with the path of the backup partition and <backup archive> with the name you like. for this to work, you should first cd to the path where you need to restore

tar xvzfp <backup path>/<backup archive>.tar.gz

Fallback

Please do not use v (verbose) option if you run from basic drivers on your nvidia card.

Do not think, just extracting wrote everything properly to your newly mounted drive. Force it to be written by giving

sync

Wait till sync finishes and comes to the command mode (next line)

Fallback

If sync is not working and red light is glowing always, do not panic. Try unmounting filesystem and remounting again. If that does not work, reboot your system in live mode and repeat steps 8 to 11. sync will take as much time more if you extracted a very big archive (say 100 GB and don't expect sync to just come to command line immediately, though the buffer is limited to RAM, linux will also use swap!, have patience for sync to finish)

This is the final step of the migration. You have converted your filesystem from ext4 to ext3, but there is a small problem. Its uuid has changed, its partition type has changed

change the uuid of reformatted partition in /etc/fstab

To get the uuid of newly formatted/restored partition, use nautilus file browser and take the 32 digit hexa decimal number from its path after /media/

see screenshot below, also you can see the new uuid in the titlebar of the file browser.

If you are a geek, use the following command as root

ls -l /dev/disk/by-uuid/

For this, you should know the partition number, in this example case it is sda5. see the following screenshot where the new uuid is highlighted,

Now mount your root partition, open terminal, become root, and replace the new uuid. Edit ./etc/fstab and update new uuid. I used sed command. You can use vi or gedit or nano, whichever you are familiar

After changing ext4 to ext3 in etc/fstab the migration step is complete with a sync

Fallback

If you migrated your root partition, mount your root partition, change its fstab with new uuid, new fs type. Apart from this you need to re create the grub. Follow reinstalling grub2 in grub2 community documentation in ubuntu from the following link

If you run into disk errors while booting (in case of debian, wont allow if there is even a date/time change), do a fsck on the migrated partition. To do an fsck, the filesystem should not be mounted, otherwise it will damage the files

for doing fsck on the ext3 partition become root using root password and use

fsck /dev/sda<N>

Do not forget to sync and unmount. Here is the screenshot of mint running with migrated ext3 partition

Corrections

Please post in comments, if there is any error and I will try to correct the errors during weekends

Disclaimer

I put the disclaimer here to ensure that what you try out is at your own risk.

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

Monday, January 18, 2010

The above screenshot shows the vbox modules highlighted. Pardus comes with all the virtualbox kernel modules and runs like native inside virtualbox

Pardus 2009.1 comes with all the modules for virtualbox inbuilt, due to which Pardus 2009.1 runs very smooth and fast inside virtualbox, feels like running Pardus 2009.1 native. Pardus 2009.1 feels very clean and highly sophisticated technology. With easy to configure Kaptan and super integration of KDE 4.3.4, gives a feel of great power to end user.

I took all the screenshots inside virtualbox-ose running inside debian-squeeze (debian testing and I love it more than Ubuntu). See the last screenshot which shows, debian in the background and Pardus inside virtualbox

While installing, I saw modules for broadcom wireless being installed shown in status bar, I will try Pardus 2009.1 in my netbook next