🇩🇪 Deutsch 🇬🇧 English

17 May 2007

Linux - copy whole system to another (bigger) harddisk

Assumption: Your current harddisk is hda. Plug in the new harddisk as hdb (primary slave). Adjust the drive names if your milage varies. Partition hdb with the fdisk command in a similar way hda is, and generate the appropriate file systems. Do not forget to add swap space.

Now copy your existig Linux-installation to the new harddisk: mount the new root partition to something like /mnt/test

# mkdir /mnt/test
# mount /dev/hdb3 /mnt/test

Now copy the whole stuff using archive mode

# cp -axv / /mnt/test/
# umount /mnt/test

Repeat for every partition. Now plug in your hdb as hda and remove hda. Boot from any rescue system like knoppix. Reinstall the grub boot loader:

# mount /dev/hda2 /mnt
# chroot /mnt
# grub
> root(hd0,1)
> setup(hd0)
> quit

a more sophisticated example:

# mount /dev/sda2 /mnt
# chroot /mnt
# mount /dev/sda1 /boot
# grub
> root (hd0,0)
> setup (hd0)
> quit

(adjust the parameters according to your setup) If you then booted up your newly copied Linux-Installation, do not forget the following:

# mkswap /dev/hda1
# swapon /dev/hda1

(also adjust the hda-parameters accordingly to your setup)