Tuesday, April 9, 2013

How to clone archlinux installation to another pc (another ways)

Hi, i have a archlinux installed on my primary PC, then i want to clone it on my netbook. I'm using "copy-paste" methods to copy all files to new hard disk. There are official way that you can follow on here. But on this post i'm using my own methods to clone the archlinux installation.

Here's my methods:
1. Copy Paste all filesystem to new disk.
2. Boot into live USB.
3. Get into chroot
4. link lib to usr/lib
5. Reinstall kernel & glibc
6. Change permission folder /home
6. Reboot
7. Reinstall all packages.

Needed tools:
1. Sata to USB converter
2. Archlinux Live USB

On this situation:
My Archlinux installation:
Intel Dual Core 3.Ghz, Nvidia 9300GS
Target:
Intel Atom N270, Intel GMA.

Ok let's clone (Use it at your own risk).
Make sure your archlinux installation is upgraded to latest (pacman -Syu)
1. Insert Drive(sata drive) on PC (that archlinux installed).

2. Cek using fdisk -l where your drive is located. 
On my machine
Archlinux installation is /dev/sdc1
Target clone is /dev/sde4

3. Copy All files
#mount /dev/sde4 /mnt
#cp -r /bin /mnt/bin
#cp -r /boot /mnt/boot
#cp -r /dev /mnt/dev
#cp -r /etc /mnt/etc
#cp -r /home /mnt/home
#cp -r /lib /mnt/lib
#mkdir /mnt/mnt
#cp -r /opt /mnt/opt
#mkdir /mnt/proc
#cp -r /root /mnt/root
#mkdir /mnt/run
#cp -r /sbin /mnt/sbin
#cp -r /tmp /mnt/tmp
#cp -r /sys /mnt/sys --> if error just Ctrl +c
#cp -r /usr /mnt/usr
#cp -r /var /mnt/var
Done, put the clone hardisk into the machines (my netbook)

4. Boot Archlinux Live USB on the new machines & Configuring
On the new machines, sde4 is change to sda4.
#mount /dev/sda4 /mnt
#genfstab -p /mnt >> /mnt/etc/fstab
#arch-chroot /mnt
sh-4.2#ln -s /lib /usr/lib
sh-4.2#pacman -S linux glibc sudo
sh-4.2#chmod -R 0777 /home/youruser
-------------------------------
on my situation i'm using nvidia, and the target is intel (if your machine is same then you can skip it)
sh-4.2#pacman -R nouveau-dri xf86-video-nouveau
Download manually the driver from archlinux repo (intel-dri, xf86-video-intel) then install it using pacman -U
Edit /etc/mkinitcpio.conf, then change modules. on my machines i change nouveau to i915
--------------------------------
sh-4.2#mkinitcpio -p linux

5.Set timezone
sh-4.2#rm /etc/localtime
sh-4.2#ln -s /usr/share/zoneinfo/Yourregion/yourcity /etc/localtime
sh-4.2#nano /etc/locale.gen
Uncomment this for default english
en_US.UTF-8 UTF-8
en_US ISO-8859-1
sh-4.2#locale-gen

6. Set Grub (Legacy / Non Uefi)
sh-4.2#modprobe dm-mod
sh-4.2#grub-install --target=i386-pc --recheck --debug /dev/sda
sh-4.2#mkdir -p /boot/grub/locale
sh-4.2#cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
sh-4.2#grub-mkconfig -o /boot/grub/grub.cfg
sh-4.2#exit
#reboot

7. Reboot & Reinstall all packages.
Now you should boot into archlinux.(you will see error when booting it you can fix it later). Login into user, then connect the internet. 
#comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) | pacman -S -

Done
Now you can fix file configuration like /etc/fstab /etc/pacman.conf, etc.

8. Done. :D

This my PC with intel Dual core & Nvidia VGA Machines:

How to clone archlinux installation to another pc (another ways)

And here's the clone on my netbook.. :D :

How to clone archlinux installation to another pc (another ways)

Enjoy.
Share on Facebook
Share on Twitter
Share on Google+