You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
close
You are viewing the article in preview mode. It is not live at the moment.
Home > Linux > Ubuntu > Move an Ubuntu installation from one computer to another, keeping it identical
Move an Ubuntu installation from one computer to another, keeping it identical
print icon

#1 - Boot your origin computer on a Ubuntu live-CD or live-USB. Run GParted Partition Editor. Find the Ubuntu partition and shrink it, setting the new size to a couple of Gb bigger than the total space used (Reference source: http://askubuntu.com/questions/62340/how-to-copy-an-ubuntu-install-from-one-laptop-to-another/62383#62383).

#2 - Boot up Ubuntu on origin machine, make sure Ubuntu works fine, and the plug in an external disk, open a Terminal and run the command:

$ sudo dd if=/dev/sda5 of=/media/exteranldrive/sda5-root.img (where sda5 is the Ubuntu partition on the origin machine).

Note: this procedure can also be done booting up with Ubuntu live-CD or live-USB.

#3 - Install Ubuntu on target machine, so that dual-boot is configured and also grub (or grub2). Also swap partition will be created. The new Ubuntu partition needs to be larger that the one on origin computer.

#4 - Boot your target computer on a Ubuntu live-CD or live-USB. Plug in the external disk with the image.

#5 - Launch GParted Partition Editor on target machine. Format the Ubuntu partition created after installation on step #3.

#6 - Copy the origin image on the target partition just formatted. Open a Terminal and run command:

$ sudo dd if=./sda5-root.img of=/dev/sdb5 (where sdb5 is the target partition).

#7 - Because origin size is different than target, the used space on the partition will show wrong. Open Gparted Partition Editor, select the Ubuntu partition, right click with the mouse and select option “Check.” This will recalculate the exact used space (Reference source: http://ubuntuforums.org/showthread.php?t=1242394).

#8 - Now we need to edit the fstab file to point to the correct devices. If you have just copied the new disk partition on to your new disk, the fstab file is on that partition so you need to mount it in order to access the file.

On a Terminal, run these commands:

$ sudo mkdir /mnt/tmp  $ mount /dev/sdb5 /mnt/tmp 

$ gksu gedit /mnt/tmp/etc/fstab 

 

When I first did this, the fstab looked like this:

# <file system> <mount point>   <type>  <options>       <dump>  <pass> proc            /proc           proc    nodev,noexec,nosuid 0       0

/dev/sda6       /               ext4    errors=remount-ro 0       1

/dev/sda5       none            swap    sw              0       0

So, sda5 and sda6 were swapped, because in my system sda6 was the swap partition. So I had to edit the file and change it to this:

# <file system> <mount point>   <type>  <options>       <dump>  <pass> proc            /proc           proc    nodev,noexec,nosuid 0       0

/dev/sda5       /               ext4    errors=remount-ro 0       1

/dev/sda6       none            swap    sw              0       0

#9 - Still on target machine after booting up with Ubuntu live-CD or live-USB, install Boot Repair (Reference source: https://help.ubuntu.com/community/Boot-Repair).

Open a new Terminal, then type:

$ sudo add-apt-repository ppa:yannubuntu/boot-repair

$ sudo apt-get update

$ sudo apt-get install -y boot-repair && (boot-repair &)

Once Boot Repair is installed, run it and execute the “Recommended repair (repairs most frequent problems)” option.

#10 - Reboot the target machine and let Ubuntu boot up. Everything should be fine and the copy identical to what you had on origin machine. Note: some drivers may need to be updated.

Feedback
0 out of 0 found this helpful

scroll to top icon