You are not logged in.

#1 2008-03-11 18:29:07

md5fungi
Member
Registered: 2008-03-08
Posts: 14

Moving root filesystem to another hard drive

Hi everyone,

I've been using Arch Linux for a few months now and it is by far my favorite Linux distribution.

I currently have Arch on an old Pentium III, with a whopping 20 GB IDE hard drive. roll

I'm building a new computer, and want to use a larger 160 GB SATA hard drive, and I was wondering what is the best way that I can just transfer my entire root filesystem so I don't have to bother copying all the scripts, programs, etc.

Can I just tarball my root directory, partition my new hard drive, and use some other LiveCD to copy the root partition? I know this shouldn't be that difficult, because everything in the root partition is in /, unlike Windows, which has association problems with the registry.

Thanks!

Offline

#2 2008-03-11 19:04:36

bgc1954
Member
From: Edmonton, AB, Canada
Registered: 2006-03-14
Posts: 1,160

Re: Moving root filesystem to another hard drive

I haven't tried it with Linux but the following should work: if you setup your new drive as a slave drive you should just be able to copy over all the files using your favorite file manager as root.  I've done this before in winblows so linux should work more easily.

You'll need to add an entry to your /etc/fstab so when you reboot linux will recognize it /dev/sdb1 /mnt/newroot ext3 users,noauto 0 0 or something like that and make a new directory /mnt/newroot.  Use gparted for example to partition the new drive like you want it and make it like your old drive (ie. swap, root, home partitions in the same order as your original drive).  Mount the slave drive and copy away--just make sure you copy over the hidden files as well.

Then setup the new drive as master and you'll need either a boot floppy so you can enter your new drive or an arch install cd to setup grub on the new drive: http://wiki.archlinux.org/index.php/Reinstalling_GRUB

You'll also edit your /etc/fstab in the new drive to remove the /dev/sdb reference but that can be done later.

Last edited by bgc1954 (2008-03-11 22:35:32)


Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz

Offline

#3 2008-03-11 19:49:13

attila
Member
Registered: 2006-11-14
Posts: 293

Re: Moving root filesystem to another hard drive

I don't think linux will like to copy /dev so i suggest to google for a howto which explains it in the best way for you and very important: DON'T DO SOMETHING WITHOUT A WORKING BACKUP. http://www.int-x.org/doku.php?id=tipps:cpio is my favorite and works but it is in german. Two other examples be http://christophe.delord.free.fr/linux/ … index.html and http://www.swerdna.net.au/linhowtoimage.html.

Another minimal way ist to save your package list, to backup only dirs where you have had do some own configurations (/etc, /home [/var] [/root] [/boot]) to a backup medium (cd or usb stick) and install a minimal arch linux from the cd on the new pc.

Backup: pacman -Q | awk '{ print $1 }' > pkglist
Reinstall: pacman -S $(cat pkglist)

The disadvantage of this way is that you have more manual work but you don't have to read about all this other automatic ways to do this and for the most you go the way which you have gone some months ago. Good Luck.

Offline

#4 2008-03-11 22:47:11

bgc1954
Member
From: Edmonton, AB, Canada
Registered: 2006-03-14
Posts: 1,160

Re: Moving root filesystem to another hard drive

I'd never want to lead anyone down the garden path without at least trying this myself so for the last hour or so I've done just as described above on an old computer I have that I play around with and a spare small 8 gb hard drive.  I first tried copying the files over with thunar but that didn't work too well (froze up) probably due to trying to copy /sys and /proc--duh.

I tried again using midnight commander (to install do #pacman -S mc) and it worked perfectly.  The /dev directory copied over just fine but don't try copying /proc and /sys.  Just make empty directories so the system can put what it needs there.  Also just make an empty /mnt directory and put your devices in later--otherwise I'm not sure what would happen if you were copying your /mnt/newroot to itself, but I'm sure it wouldn't be good.

I tried to just install grub on the slave with #grub-install /dev/sdb and it said it installed fine but when I switched the slave to master and disconnected the old master, grub wouldn't boot (probably because it was installed to /dev/sdb?) so I had to use the arch install disk to install grub.  Then, much to my surprise--like I had any doubts--I rebooted and now I'm posting this with the newly copied Arch with xfce4.

It might not be a bad idea to backup any really important stuff but you are just copying and unless you do something silly, everything should work fine.

Last edited by bgc1954 (2008-03-11 23:13:58)


Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz

Offline

#5 2008-03-12 06:26:08

attila
Member
Registered: 2006-11-14
Posts: 293

Re: Moving root filesystem to another hard drive

@bgc1954 thunar is not a good idea because in this moment you use runlevel 5. For going your way runlevel 1 would be better because only than no file will be changed or created. Best is from my view still again is a live cd (or the arch install cd but there i don't know if you can run mc in the rescue mode).

And i don't think that you can install grub in a safe way without running for one time a live cd or the arch install cd if you copy your system from master to slave. There will be even 3 steps from my view:
1. Copy from master to slave ... copy is the title of the step not the command smile
2. Shutdown and change slave to master (or put the new hd to the new pc)
3. Boot a CD and install grub on the new master (or the new hd)

Offline

#6 2008-03-12 14:30:42

bgc1954
Member
From: Edmonton, AB, Canada
Registered: 2006-03-14
Posts: 1,160

Re: Moving root filesystem to another hard drive

Yes, I agree, using thunar, konqueror or nautilus is a bad idea.  I accomplished the above with mc in runlevel 5 just fine but you have a point that it's probably better to startup in single user mode and then use mc as root in the terminal with nothing else running in the background, although what I did worked--maybe just lucky.  And no, mc is not on the install disk that I could see.  Just install it before you reboot into single user mode.

Last edited by bgc1954 (2008-03-12 14:31:33)


Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz

Offline

Board footer

Powered by FluxBB