SHOW:
|
|
- or go back to the newest paste.
| 1 | ==================================================== | |
| 2 | - | How to transfer a Linux install to another machine. |
| 2 | + | The short short version (see full here http://pastebin.com/4NLFkdzQ) |
| 3 | ==================================================== | |
| 4 | ||
| 5 | - | Either the source or destination can be a virtual machine, physical machine, or possibly even a broken disk you can't boot or mount. This howto doesn't really make an assumption of which, so be intelligent and adapt to your needs. |
| 5 | + | |
| 6 | parted /dev/sda mkpart root 1 -- -1 | |
| 7 | - | If you want to end up with 2 machines in the end, make sure you have 2 machines to start. If the destination is a virtual machine, make a new vm with a blank disk to send the install to. Make sure the source disk is attached in a way that you can access it, such as attached to a working virtual machine. |
| 7 | + | |
| 8 | mkfs.ext4 /dev/sda1 | |
| 9 | ||
| 10 | - | Full version |
| 10 | + | |
| 11 | ||
| 12 | # this only copies rootfs. If you have separate /home, /var, etc. then you need to run separate commands for those. | |
| 13 | - | either: |
| 13 | + | rsync -avHPAXx sourceMachine:/ /mnt/root/ |
| 14 | - | 1) Start both machines and boot the destination one on a LiveCD. (physical machines, or virtual machines) |
| 14 | + | |
| 15 | - | 2) mount the destination disk inside the source machine (more difficult to get the bootloader working, but then you don't need a LiveCD) |
| 15 | + | |
| 16 | mkdir dev proc sys media mnt | |
| 17 | - | On the destination machine: |
| 17 | + | |
| 18 | - | Format the disk the way you want it, For example: |
| 18 | + | |
| 19 | - | parted /dev/sda mktable gpt |
| 19 | + | |
| 20 | - | parted /dev/sda mkpart root 1 -- -1 |
| 20 | + | |
| 21 | - | mkfs.ext4 /dev/sda1 |
| 21 | + | |
| 22 | mount -o rbind /sys sys | |
| 23 | - | Then mount the new disk. |
| 23 | + | |
| 24 | - | mkdir /mnt/root |
| 24 | + | |
| 25 | - | mount /dev/sda1 /mnt/root |
| 25 | + | |
| 26 | arch-chroot /mnt/root | |
| 27 | - | Transfer using rsync or scp. |
| 27 | + | |
| 28 | - | at this point, it is assumed that the source disk is not changing so fast that an rsync copy would be inconsistent. You should shut down all your services on the source machine. You should especially shut down running databases. |
| 28 | + | |
| 29 | make sure UUIDs are right | |
| 30 | - | scp push from the source machine (best for speed over fast network): |
| 30 | + | |
| 31 | - | source machine : |
| 31 | + | |
| 32 | - | cd / |
| 32 | + | |
| 33 | - | ls |
| 33 | + | |
| 34 | - | scp -r bin boot etc home lib lib64 opt root run sbin selinux srv test tmp usr var destMachine:/mnt/root/ |
| 34 | + | |
| 35 | ||
| 36 | - | If the scp is interrupted, you can resume it with scp again, or resume with rsync. But if you use scp again, you also should run rsync afterwards just to fix any half transferred files. |
| 36 | + | |
| 37 | - | |
| 37 | + | |
| 38 | - | rsync pull (best for speed over slow network, or to resume an interrupted transfer): |
| 38 | + | |
| 39 | - | Then use rsync to pull the whole root system to the new machine (exclude /dev /proc /sys and anything else unneeded: /mnt /media etc). |
| 39 | + | |
| 40 | update-initramfs -u | |
| 41 | - | rsync -avHP --exclude dev --exclude proc --exclude sys --exclude media --exclude mnt sourceMachine:/ /mnt/root/ |
| 41 | + | |
| 42 | - | |
| 42 | + | |
| 43 | - | (add -z if you have a very slow network, which compresses things) |
| 43 | + | |
| 44 | mkinitcpio -p /etc/mkinitcpio.d/linux.preset | |
| 45 | - | Create some directories we need |
| 45 | + | |
| 46 | - | cd /mnt/root |
| 46 | + | |
| 47 | - | mkdir dev proc sys media mnt |
| 47 | + | |
| 48 | #debian based: | |
| 49 | - | Then from the destination machine, you chroot into wherever you put the files, and run "grub-install /dev/sdX" and "update-grub" |
| 49 | + | |
| 50 | #openSUSE: | |
| 51 | - | # next 4 lines: general, non-arch based (works for arch too, but pacman won't work within chroot) |
| 51 | + | |
| 52 | - | mount -o rbind /dev dev |
| 52 | + | |
| 53 | - | mount -o rbind /proc proc |
| 53 | + |