Copying the system from one HD to another

Sam Varshavchik mrsam at courier-mta.com
Mon Dec 25 22:25:00 UTC 2006


redhatdude at bellsouth.net writes:

> Hi,
> My FC6 box has an internal 40 Gig ATA hard drive in it. I'd like to  
> upgrade it to an 80 Gig SATA drive. Is there a way to copy the whole  
> system from one to the other so I don't have to reinstall Fedora and  
> reconfigure all my services?

I did something like this a long time ago (with an earlier distro, but 
there's no reason this won't work with FC6).  This is possible, but is not 
for the faint of heart.  The basic procedure is:

1) Connect the second hard drive.  I believe that in FC6, ATA drives come up 
via SCSI emulation, as /dev/sd??, so your existing hard is probably 
/dev/sda.  When you hook up your second drive it's going to come up as, 
_probably_, /dev/sdb.  In any case, your first order of business is to 
figure out the device node for your primary hard drive, and the device node 
for your second hard drive.

2) Boot into single user mode (run level 1).  In grub, don't hit enter to 
boot, hit 'E' to edit the boot configuration, hit 'E' again to enter the 
kernel command line, and append "1" to the end of the command line (preceded 
by a space).  Push 'B' to boot into run level 1.

3) Use fdisk to format your second hard drive.  DON'T SCREW UP your device 
node, verify that you're _really_ wiping the partition table on your new 
hard drive, and not your existing one.  If you're screw up here, you're 
boned.  Kiss your arse good-bye.

4) After formatting the partitions on the new hard drive, mount them under 
something like /mnt/newdisk.  You can use this as an opportunity to 
repartition your system.  You don't have to set up partitions on your new 
hard drive the same way they are on your current drive; you can pick a 
better layout for your data.  Personally, I don't go crazy with partition 
layout.  For the last eight years I just always partition about 100-200MB 
for /boot, and the rest for /.  So, in my case, I'd end up mounting 
/mnt/newdisk and /mnt/newdisk/boot, if I were doing this myself.

5) Now, it's time to copy everything.  I am impartial to using tar, since in 
my experience it's more reliable for copying all the special device files 
and preserving all the file attributes.  Things get hairier if you use 
selinux, ACLs, or other file extensions.  There's a tar-equivalent in FC6, 
whose name escapes me in the moment, which can accurately preserve extended 
file attributes.  Before doing this, you should make some test copies of 
files with extended attributes and verify that they get properly copied.  
Anyway, from /, I would run something like this

tar cf - bin boot etc home lib lost+found media misc [...] | (cd /mnt/newdisk; tar xvf -)

You need to manually list all your root directory entries, except for /mnt 
(also the special mounts, see below). Don't include /mnt, since that's where 
you've mounted /mnt/newdisk and you'll end up recursively copying everything 
until you fill up your second hard drive.  Instead, manually recreate any 
addition mount points in /mnt/newdisk/mnt.

Use the "mount" command to see all the active special mounts:

# mount
/dev/md1 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/md0 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

So you know you need to exclude proc and sys -- the special mounts -- from 
your tar copy, but you'll need to manually create an empty mount point 
directory in their place: /mnt/newdisk/proc, and /mnt/newdisk/sys.  You'll 
also need to exclude /dev/shm and /dev/pts, but you do need (definitely!) to 
copy the rest of your /dev, so it's easier to include /dev in your tar copy, 
then manually wipe out /mnt/newdisk/dev/shm and /mnt/newdisk/dev/pts, and 
leave an empty mount point directories in their place.

6) After you've _carefully_ copied everything, taking extreme care to copy 
over all the necessary bits, run the shutdown command.  Pull your existing 
hard drive.  Re-jumper or reconnect your second drive, if necessary.

7) Boot the FC6 installation DVD, type "rescue" to go into rescue mode.  If 
you did everything correctly, the installer should find your copied FC6 
install image, and throw you into a shell prompt, with your new FC6 system 
mounted as /.

8) Do some sanity check.  Look around with ls; make sure that everything 
seems to be in its place.  Run /sbin/grub-install, to reinstall the 
bootloader.

9) Shut down and reboot, hopefully your new system will come up and boot 
without any issues.


Like I said, this is not for the faint of heart; but this is doable if you 
know your way around, and take it easy, one step at a time.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20061225/9420895f/attachment-0001.sig>


More information about the fedora-list mailing list