How do I transfer my current Ubuntu system to a new, larger hard drive?
August 21, 2007 10:20 AM
Subscribe
How do I transfer my current Ubuntu system to a new, larger hard drive?
(If there's a good explanation of this anywhere, I've been unable to find it. I've seen some explanations of how to do this with older, LILO-based systems. But I haven't seen anything that explains how to do this with GRUB, UUID's in fstab, etc).
My current setup has two hard drives, one 20 gig root+swap and an 80 gig mounted at /home. I want to replace them with my new 250 gig drive. As I understand it, the following steps need to take place:
0. Reboot my system and go into recovery mode.
1. fdisk /dev/hdc
hdc1: 249 gig bootable type 83
hdc2: 1 gig type 82
2. mkfs /dev/hdc1
3. mkswap /dev/hdc2
4. mount /dev/hdc /mnt/hdc
5. cp -a /???? /mnd/hdc
6. dd if=/dev/hda of=/dev/hdc bs=1024 (?)
7. vi /mnt/etc/fstab (?)
In step 5, what should I be copying? Not /proc, presumably. /dev? What is /sys? /srv? How do I know what should and what should not be copied?
Is step 6 the right way to copy the boot loader if I'm using grub? Isn't GRUB bigger than the old LILO?
Fstab looks very strange to me these days. Instead of specifying the devices, Ubuntu seems to be using UUID's. Where did they come from? How do I find what my new HD's UUIDs are?
posted by bonecrusher to computers & internet (10 comments total)
3 users marked this as a favorite
I would recommend booting off a CD.
partition your new HD how you want it (it can differ from the old system). Mount it up as /mnt/hd-new. Mount the old HD as mnt/hd-old
(ie, /dev/hdc1 /mnt/hd-new, /dev/hdc2 /mnt/hd-new/usr, etc).
Then make a pipe (mkfifo transfer).
Then tar into the pipe (tar vfz transfer /mnt/hd-old/home /mnt/hd-old/usr /mnt/hd-old/var /mnt/hd-old/etc...)
On another terminal untar to the new drive..
tar xvf transfer /mnt/hd-new
When thats done, move hdc to hda (physically). Boot off the live CD again, mount up your partitions again, and run lilo/grup to configure the boot loader on the new drive.
Fix fstab if you changed partitions. As to what shouldn't be copied.. skip the un-bold entries (this is off my Centos system).
drwxr-xr-x 2 root root 4096 Aug 7 04:04 bin
drwxr-xr-x 4 root root 1024 Aug 6 12:23 boot
drwxr-xr-x 8 root root 5440 Aug 6 12:24 dev
drwxr-xr-x 91 root root 12288 Aug 15 04:02 etc
drwxr-xr-x 9 root root 4096 Jun 20 14:15 home
drwxr-xr-x 2 root root 4096 Feb 21 2005 initrd
drwxr-xr-x 12 root root 4096 Aug 7 04:04 lib
drwx------ 2 root root 16384 Aug 21 2006 lost+found
drwxr-xr-x 3 root root 4096 Aug 6 12:25 media
drwxr-xr-x 2 root root 4096 May 3 01:14 misc
drwxr-xr-x 2 root root 4096 Apr 26 10:47 mnt
drwxr-xr-x 2 root root 4096 Feb 21 2005 opt
dr-xr-xr-x 125 root root 0 May 29 08:51 proc
drwxr-x--- 31 root root 4096 Aug 20 10:01 root
drwxr-xr-x 2 root root 12288 Aug 7 04:04 sbin
drwxr-xr-x 2 root root 4096 Aug 21 2006 selinux
drwxr-xr-x 2 root root 4096 Feb 21 2005 srv
drwxr-xr-x 9 root root 0 May 29 08:51 sys
drwxrwxrwt 6 root root 4096 Aug 21 04:02 tmp
drwxr-xr-x 14 root root 4096 Aug 21 2006 usr
drwxr-xr-x 21 root root 4096 Mar 13 12:27 var
my SRV dir is empty, as is selinux.. i would copy them.
As for "Is step 6 the right way to copy the boot loader if I'm using grub? Isn't GRUB bigger than the old LILO?"
You dont. You copy the setup file, and the app (lilo, grub). You then run the app against the setup/conf file so it re-installs. Dont 'copy' it with dd.
dd only works well with EXACT duplicate drives. (same size, same logical setup, etc) One last thing!
I would REMOVE your second harddrive (/home) during this entire process. Once you move the system (20gb) to the 250gb, and have moved the 250gb to HDA, you can reattach the 80gb harddrive, unmount it as /home, make a new home, and copy files over with the same process. Its a step that will cost you maybe an extra 5 minutes, but protect you from somehow accidentally damaging your userfiles.
I've done this probably 20-30 times, and I would still remove the /home drive just to be 100% over-cautious.
posted by SirStan at 10:36 AM on August 21, 2007