copy_linux_to_a_new_harddisk

This is an old revision of the document!


Copy Linux to a new Harddisk

In the following howto i assume that sda is your source drive and sdb is your target drive.. please make sure not to mix this up in your setup! also i assume that your operating system disk has three partitions, sda1 as /boot, sda2 as swap and sda3 as /

  • stop any running services like apache, mysql etc. on the source system. or even better, boot from a live linux and work from there..
  • partition and format the new harddisk
    • parted /dev/sda –> print shows the current partitions of sda including their sizes.. that should help :)
  • create mountpoints for source and target
    mkdir /tmp/source
    mkdir /tmp/target
  • mount source and targed partitions:
    mount /dev/sda3 /tmp/source
    mount /dev/sda1 /tmp/source/boot
    mount /dev/sdb3 /tmp/target
    mkdir /tmp/target/boot
    mount /dev/sdb1 /tmp/target/boot
  • now copy the os:
    rsync -aHvx --numeric-ids /tmp/source /tmp/target
  • edit /tmp/target/etc/fstab and /tmp/target/boot/grub/menu.lst and update UUID according to harddisks_by_uuid_in_debian_lenny
  • chroot to the target drive and install grub:
    mount --bind /dev/ /tmp/target/dev
    mount --bind /sys/ /tmp/target/sys
    chroot /tmp/target
    grub-install /dev/sdb
    update-grub
    grub
    find /boot/grub/menulst

    (if you have an own partiton for boot, you can leave boot away in the above command)

    root (hd0,0)
    setup (hd0)
  • reboot your system
  • copy_linux_to_a_new_harddisk.1368482126.txt.gz
  • Last modified: 13.05.2013 23:55
  • by Pascal Suter