Docs/SysAdmin/Filesystems/Conversion
From Mandriva Community Wiki
Converting ext3fs to reiserfs
> I am wanting to convert my ext3fs to reiserfs. How can I do that
> without losing all of my information and settings.
Well it depends on how you are set up and what resources you have available. In order to make more effective suggestions we will need you to post the following:
- The reason why you wish to convert to reiserfs in case we can suggest a better alternative.
- The output of the "df -h" command from the command line.
- Whether or not you have a backup system available and how much space can be made available on it.
Here is the info on my home server:
[root@enigma 0 sbin]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/ide/host0/bus0/target0/lun0/part5
35G 13G 21G 39% /
/dev/ide/host0/bus0/target0/lun0/part6
20G 5.3G 15G 27% /home
none 126M 4.0K 126M 1% /tmp
So if I wanted to convert completely over to reiserfs, I could use some of the following ideas:
First off, you could use a script that will build a list of rpms pretty much in the same order they were installed originally. I could use one of these two, so I'll write it for you (and me). The script below, run as root, can be used:
#!/bin/bash #Save this as a bash script file named rpmreinstall #Script by Jim Collings #If you like this script and know where I can find some work, #email me at j_c_llings@yahoo.com #Create a file name that is really unique #so that we can use it for a temp file. filename=`date +%F-%H:%M:%S:%N` #Dump the list of currently installed packages #to a file sorted by most recently installed first. #Also, omit the date/time information. rpm -qa --last | sed 's/\ .*//' >> /tmp/$filename #Rewrite the file in reverse order and dump it #to the file name specified by the user. tac /tmp/$filename > $1 #Clean up the temp file. rm /tmp/$filename
Run it like so:
./rpmreinstall [name of output file]
Run it once before reinstall and once again, with a different filename after a reinstall to get two files that can be used to build a script that will ensure that you will at least have all the packages you had when you started. The script below is the one that will do the building:
#!/bin/bash #Save this as a bash script file named rpmbuildscript #Script by Jim Collings #If you like this script and know where I can find some work, #email me at j_c_llings@yahoo.com touch $3 chmod 755 $3 echo -e "#!/bin/bash\n" comm -23 $1 $2 | sed 's/\ .*//' | sed 's/.*/urpmi --auto &/' >> $3
Run it like so:
./rpmbuildscript [file name A] [file name B] [file name C]
Where filename A represents the name of the file that was created before installation, B is the file name created after installation and C is the name you want to use for the resulting script.
OK, so I have a complete settings and user backup script which compresses and dumps /home, /etc, /var/lib/samba, /root and my root scripts at /usr/local/sbin. I could simply use it and then re-install. My backup drive is an old cast-off 20 Gig hard drive in an external USB 2.0 shell.
Now let's assume that I don't have a good backup system.
I could copy /etc, /root, /var/lib/samba, and /usr/local/sbin to some location on a different partition. /home, for example. Let's say, /home/etc, /home/root, home/samba, /home/sbin respectively. If/When I do this, I should ensure that I use "cp -a" or "cp -Rp" in order to make sure that the permissions and ownership of files are copied as well as subdirectories. I could probably do this with konqeror as well, but I don't know how off the top of my head.
Great, so now I've got all my stuff in one spot. I can compress it using my favorite compression protocol and again, I have to make sure I save those permissions and ownerships in the resulting compressed file. I use "zip -9quTyr -b /root/tmp [destination directory] [source directory] " in my backup script. Later when I want to extract that information, I would use " unzip -X [zipfile] -d [target directory] " to extract the files as well as the permissions.
Now I move the compressed file to /root which exists on the root partition.
At this point, I will find myself operating as the root user so I unplug my ethernet card from the network for security. Not really nescesary since we are about to start nukeing stuff anyway, but a good habit to develop.
Now I can login as root. I should not log in as a user and then su to root because I am about to nuke that user's home directory. I fire up X windows, unmount /home and use diskdrake to re-format it as a reiserfs partition. Then I can adjust /etc/fstab if required, re-mount it, extract the files (again makeing sure that I also extract permissions, ownerships etc.) back to the /home directory and voila! One partition down and it already has the root partitions settings saved on it! I should make sure that when I re-install that I do not under any circumstances format the /home directory since we are currently using it to store our backup. Make sure you plug back into the network when you are logged off.
During re-installation, I can re-format the root partition as reiserfs. While I should try to install as little as possible, if I am in doubt as to weather or not it was something that I had previously, I should install it anyway. I can always remove it later.
After re-installation, reboot and log in as the non-root user created during the install. Now I run updates immediately, paying special attention to bugfixes and the urpmi system itself. When finished, I can copy /home/etc/urpmi to /etc/urpmi (use the -a or -Rp flags and overwrite). This should restore my old urpmi settings but I will need to update each source.
Next I can use the list of rpms I made to make sure I have all the right packages. Generate a list of new packages by running the rpmreinstall script again with a new filename. Then run the rpmbuildscript on those two files to produce your re-install script. Go get a cup of coffee. This might take while.
Now you need to reconcile your two fstab files, the one in /home/etc/fstab and /etc/fstab. Take the new file system settings in /etc/fstab and update /home/etc/fstab with those settings without disturbing any special settings you may have.
To prevent loosing the /etc/urpmi data that I just set up, I may want to copy it to /home/etc/urpmi.
Great, next I would need to move the following, while overwriteing.
- /home/etc to /etc
- /home/root to /root
- /home/samba to /var/lib/samba
- /home/sbin to /usr/local/sbin
That should it! Good luck! :-)
Jim C.

