copy_linux_to_a_new_harddisk

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
copy_linux_to_a_new_harddisk [28.01.2011 21:21]
Pascal Suter
copy_linux_to_a_new_harddisk [06.06.2014 10:54] (current)
Pascal Suter
Line 1: Line 1:
 ====== Copy Linux to a new Harddisk ====== ====== 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. +  * 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   * partition and format the new harddisk
-  * <code>rsync -aHvx --numeric-ids /source /target</code> for each partition +    parted /dev/sda --> print shows the current partitions of sda including their sizes.. that should help :)  
-  * edit fstab and /boot/grub/menu.lst and update UUID according to [[harddisks_by_uuid_in_debian_lenny]] +  * create mountpoints for source and target <code>mkdir /tmp/source 
-  * install grub +mkdir /tmp/target</code> 
-mount the root and boot partitions+  * mount source and targed partitions: <code> 
-  mount /dev/hdcX /mnt/new +mount /dev/sda3 /tmp/source 
-  mount --bind /dev/ /mnt/new/dev +mount /dev/sda1 /tmp/source/boot 
-  mount /dev/hdc0 /mnt/new/boot +mount /dev/sdb3 /tmp/target 
-  chroot /mnt/new +mkdir /tmp/target/boot 
-  grub-install /dev/hdc +mount /dev/sdb1 /tmp/target/boot 
- +</code> 
-  sudo grub +  * now copy the os: <code>rsync -aHvx --numeric-ids /tmp/source /tmp/target</code> 
-  find /boot/grub/menulst +  * edit /tmp/target/etc/fstab and /tmp/target/boot/grub/menu.lst and update UUID according to [[harddisks_by_uuid_in_debian_lenny]] 
-(if you have an own partiton for boot, you can leave boot away in the above command)  +  * chroot to the target drive and install grub<code> 
-  root (hd0,0) +mount --bind /dev/ /tmp/target/dev 
-  setup (hd0) +mount --bind /sys/ /tmp/target/sys 
 +mount --bind /proc/ /tmp/target/proc 
 +chroot /tmp/target 
 +grub-install /dev/sdb 
 +update-grub 
 +grub 
 +find /boot/grub/menulst</code>(if you have an own partiton for boot, you can leave boot away in the above command) <code> 
 +root (hd0,0) 
 +setup (hd0) 
 +</code> 
 +  * if you are moving your installation to new hardware (other than just the harddisk) you might need to update your initrd image to contain the necessary drivers (i.e. in redhat based systems). run ''dracut''
   * reboot your system   * reboot your system
  • copy_linux_to_a_new_harddisk.1296246066.txt.gz
  • Last modified: 28.01.2011 21:21
  • (external edit)