best way to clone an OS from a drive to a partition on a new drive?
June 9, 2007 8:08 PM   Subscribe

What's the easiest way to clone the contents of one drive onto the partition of another? The one drive is 10GB and has a home rolled linux installation that runs beautifully on an old laptop. The other drive is 40GB and has a win98 partition, an Ubuntu partition, and a Zenwalk partition. I'm going to blow the last two away because they're slower than win 98, and put the homegrown flavor back. Should I do this from a liveCD Knoppix, perhaps, or DSL?

It gets tricky because there are three primary partitions on the 10GB drive and I'll want to copy them to logical partitions. At the moment I'm using LILO as a boot loader, on the old drive I have grub. I need to avoid copying the MBR from the old drive and update the info in the current drives MBR, not to mention modifying LILO accordingly. See, I spent months total building the perfect linux install for a then five year old laptop then got bored. Now it is seven years old and off the shelf linuxes, even the "small" ones are as bloated and slow as XP. I threw a new old drive in, installed win98 as a benchmark, and stared fooling around. Nothing compares to a kernel stripped to its essentials and the only modules available being those I actually need. there are sizable performance gains in compiling the GNU tools yourself, too.
posted by Grod to Computers & Internet (7 answers total)
 
Response by poster: In case it isn't obvious: which utilities would you use (there are so many) have you done this before or are you guessing, and are there any guides you found useful when you did something similar?
posted by Grod at 8:09 PM on June 9, 2007


Here's a suggestion: save up for an 4-bay external USB 2.0 enclosure, and get some extra drives when you can. Stripe the partitions on in RAID, or dedicate each drive to a different OS.

In any case, you can use any of NovaStor's offerings for mirroring the 10GB's contents.
posted by Smart Dalek at 9:03 PM on June 9, 2007


Huh? I can't tell if you're asking for help with boot config, partitioning, copying files around, or what.

For copying everything over, I'd boot from a live CD like Knoppix, mount the two filesystems, then run "(cd /mnt/src; tar cvf - .) | (cd /mnt/dest; tar xf -)". I've done this before; it works with absolute & relative symlinks & devices.

As for speed: Try a different window manager. Add more memory. Check out Gentoo while you're at it.
posted by Pronoiac at 9:08 PM on June 9, 2007


Response by poster: Pronoiac:

Sorry if I wasn't clear. Out of nostalgia and cheapness I still occassionally use a dell inspiron 4000 from late 2000. It used to be my primary machine and at one point I spent a lot of time setting up the absolute best OS possible. I used Sourcemage as a starting point, although Gentoo would've been a good choice too. Since then I've done all sorts of crap to the box, usually through the simple expidient of throwing in another low capacity HDD. I'm out of spare drives. I'm going to remove all the OSs I was playing with and set up a dual boot of the old 'perfect' linux and win 98. Building a complete OS on such an old system takes considerable time and I never kept track of what I was doing, so duplicating it would take as long. Instead, I want to move the OS on the 10GB disk to a section of the current drive. Once I've accomplished that I'll have to set up the boot loader again. Since it lives in the MBR it won't go bye bye with the linux partitions. So part of your response is useful, thanks. The wm I've used are: fluxbox (I like it), xfce (has potential), gnome (meh), kde (meh), jwm (meh), and enlightment DR17 (has a lot of potential and is surprisingly fast on older systems and, when I was using it, remarkably stable). I'll probably go back to using Enlightenment. On newer machines I would probably use a slackware based distro like Vector Linux because they seem marginally faster and more stable than Debian based distros, and either enlightenment or Xfce + Beryl for a window manager.
posted by Grod at 9:49 PM on June 9, 2007


It sounds like it would be hard to get both drives mounted in the same machine at the same time, so this is how I would approach it.

Make two Ubuntu boot CDs. Boot up both the source and the destination using them. On the destination, do your partitioning and filesystem layout however you want, and mount the target filesystems under the /mnt tree somewhere. Then run the ssh server on that machine, and enable remote root logins for that account. (You should assign a temporary root password before doing this.)

On the known good machine, mount your partitions under mnt, and then run a tar copy over ssh to the other machine. It would look something like this:

(on source machine:)

cd /mnt/goodlinux
tar -cvf - | `ssh root@targetbox "cd /mnt/destination; tar -xf -"`


What you're doing: starting up a tar of your local filesystem, and piping that to the ssh command that's in backticks. (the backticks are crucial!) Within the backticks, the ssh command connects to the other machine (you may need to type a password), cds to the target dir, and then uncompresses from standard input -- which is being stuffed full from the tar on the source machine.

You are, in essence, using SSH as a network pipe command. This is an extended version of Pronoiac's answer.
posted by Malor at 2:37 AM on June 10, 2007


Oh, dammit! I hit post instead of preview. I meant to add:

Once you have the target filesystem transferred, you'll need to get your boot manager running. Most often, that will work fine if you A) chroot into the root of the filesystem (chroot /mnt/newroot), and then -- and this is important -- B) mount the /proc filesystem under the chroot. You may also need to mount /sys as well if you have recent utilities, but it sounds like you're trying to preserve an ancient distro instead. They all used just /proc. Then modify your lilo.conf or menu.lst to suit the new drive and partition layout, and do your normal install process. Once you're done, BEFORE exiting the chroot, be sure to unmount the temporary /proc filesystem.

Then type exit, shut down, reboot, and with any luck, you'll have transferred your installation.
posted by Malor at 2:41 AM on June 10, 2007


Response by poster: thanks.
posted by Grod at 4:46 PM on June 10, 2007


« Older Trench Coat ID   |   Suggested resource for coding neural networks in... Newer »
This thread is closed to new comments.