Moving a Linux Install to a Different Drive 16
Pilchie asks: "I recently bought a new hard drive for my box at home that is much larger and faster than my old one. For those reasons, I would like to have Linux installed on it instead of leaving it on my old disk. The problem is that I have spent a lot of time and effort tweaking my box, and I don't want to go through it again. So far, all I have tried is using: "dd if=/dev/hdc1 of=/dev/hda1 bs=2048k" While this seems to work (can boot and everthing), once it has booted if I run df, it reports the size as the same as the original partition, even though fdisk reports the size correctly. Anyone have any ideas?" For file moving, I've always preferred the tar approach, but moving the files isn't the only thing you have to worry about: there are some system configurations you will HAVE to changem, /etc/lilo.conf being the one particular one that stands out in my mind. I'm sure there are others.
filesystem ne partition (Score:1)
There was a free nondestructive filesystem/partition resizer that understood e2fs announced 1-2 weeks ago (I think this [slashdot.org] is it, or you could go buy PartitionMagic (which I belive handles e2fs). Either way, you'll want to make the new partition the *same* size as the existing one, use dd to copy the filesystem, and *then* run the filesystem/partition resizer. Alternately, you could probably do what you've already done (dd a filesystem into a bigger partition) and use debugfs to size the filesystem by hand, but that's deeply magical and requires an understanding of the filesystem beyond what I have to offer.
You could also just make a new filesystem in the new partition and use 'cp -a' to copy files over, although it won't preserve ext2 attributes (lsattr) and you'll need to run lilo again on the new disk to make it bootable.
Copying Linux filesystem from one drive to another (Score:1)
0) Boot into Linux single mode (LILO: linux single). That will keep all your normal stuff from booting and create less potential conflicts.
1) Setup the partitions as you want them. Personally, I run a four-partition machine, and I recommend it to everyone I install Linux for. First partiton is about 200mb for the root directory. Second is a 24-128mb partition for swap space. Third is 350-1024mb for the
(Why a multi-partiton system? Well, you can backup your important dirs (mainly
2) Format the new partition(s).
3) make a new directory called
4) Use tar and a little black magic to copy your whole filesystem in one easy step:
(cwd:
tar -cf - (all dirs except
(ex: tar -cf - bin/ boot/ dev/ etc/ home/ lib/ lost+found/ mnt/ opt/ root/ sbin/ tmp/ usr/ var/ | (cd
You'll see all the files on your drive go zipping by (You can bypass this by omitting the v on the second tar). That's it copying all your files.
5) make the
6) Make any changes necessary to your
7) make a temporary boot disk ("dd if=/boot/vmlinuz of=/dev/fd0 bs=1024").
8) Shutdown the box normally and swap drives.
9) Boot using the temporary boot disk.
10) Login as root and run LILO ("/sbin/lilo").
11) Remove the bootdisk and reboot. Everything should work right.
GET OUT OF MY HEAD! (Score:1)
What I'll end up doing is either taring all the files, or cping them. Directions of how to do either are above (And this article is now bookmarked
there is a HOWTO for this (Score:1)
Dual Boot Linux (Score:1)
Read the How-Tos (Score:1)
You will find the file in HOWTO/mini/Hard-Disk-Upgrade.html. Remember to use the mirrors folks, hence no direct link.
Different slant on the question (Score:1)
What if you want to move across just the
HOWTO (Score:1)
I just used "cp -ax /
It worked fine. For more info check out the
HOWTO: http://metalab.unc.edu/LDP/HOWTO/mini/Hard-Disk-U
cp -a etc (Score:1)
I've done this (Score:1)
To run LILO on it edit lilo.conf on the running filesystem to install on
It should work. If not use a LILO disk (I like Slackare's no-BS boot disk: "mount root=/dev/hda1"). After it has successfully booted, update the
How about dump/restore? (Score:1)
I've never actually done this under Linux, but whenever I wanted to move the contents of drives on other Unixes, I always ran dump and restore. Create a new fs on the new drive, mount it on /new, then try something like:
dump -0 -f - / | (cd /new && restore -rf -)
(You may want to refer to the man pages to make sure the switches are correct -- it's been a while since I've done this. The idea is to dump to stdout and restore from stdin.)
BTW, using dd to copy filesystems is a BAD idea -- the fact your FS is the same size as the old one is evidence of that. There are some things dd just shouldn't be used for. =)
mini-HOWTO on this very subject! (Score:1)