[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: linux copying



On Tue, May 13, 2003 at 10:23:45AM -0400, Kevin McKinley wrote:
> On Wed, 14 May 2003 06:54:34 +0530
> JK Malakar <cave_man@hotpop.com> wrote:
> 
> > i have bought a 40GB HDD. is it possible to copy the existing Debian linux
> > from my old HDD to the new one as well as make it boot-able ?
> 
> Sure. I did something like this when I bought a second hard drive; I was
> able to duplicate a dual-boot WinME/Debian system.
> 
> I fumbled around a little, but these are the steps as I remember them:
> 
> 1. Partition the new hard drive and format the linux partition. For this
> message assume you use one / partition for everything.
> 2. Boot with a CD/floppy Linux such as Knoppix or LNX-BBC.
> 3. Mount your old and new partitions.
> 4. Copy the files over:
>      cp -a /mnt/old/* /mnt/new
> 5. Copy your MBR, but not the partition table:
>      dd if=/dev/hda bs=448 count=1 of=/dev/hdb
>    assuming /dev/hda is the old drive and /dev/hdb is the new one
> 6. Copy the parition boot record of the old linux / partition to the new:
>      dd if=/dev/hda? bs=448 count=1 of=/dev/hdb?

My variant involves more typing but avoids the CD/floppy boot and only
implies one step of fiddling with hardware:

0) Backup old drive!
1) Partition & format new drive
2) Mount new drive's Linux partition on /mnt
3) make directories on new drive, including all mount points and stuff:
  for x in `ls -1 /`; do if [ -d /$x ]; then mkdir /mnt/$x; chmod --reference=/$x /mnt/$x; fi; done
4) copy over the contents of directories, but omit /mnt, /proc and
   anything else not helpful - check the list against your own / and
   edit as appropriate. Yucky, but works:
  for x in bin boot dev etc home initrd lib opt root sbin usr var; do rmdir /mnt/$x; cp -a /$x /mnt; done
5) edit /mnt/etc/fstab to mount the new drive as /
6) umount /mnt
7) reconfigure your bootloader to boot off the new drive
8) reboot
9) if it doesn't work - you can always reconfigure your bootloader
     back to the old drive to get a working system back
   if it does - you can wipe your old drive and get an extra 20Gb free
     space.
	 
-- 
Pigeon

Be kind to pigeons
Get my GPG key here: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x21C61F7F

Attachment: pgpiUm9gJVjA0.pgp
Description: PGP signature


Reply to: