How to copy a Mint installation and boot it.

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Old Ruler
Level 5
Level 5
Posts: 555
Joined: Sat Jul 18, 2009 12:43 pm
Location: Shropshire, UK.

How to copy a Mint installation and boot it.

Postby Old Ruler » Thu Feb 11, 2016 4:02 pm

I used rsync to copy my entire Mint 17.3 installation from one partition to another. I've been using the copy for about a week now and everything seems fine. While the procedure I used is still fresh in my mind, I thought I'd write it up for the tutorial section.

Make sure you have installation media for the architecture you're using. I used an 8GB usb stick drive with the 64bit version of Mint 17.3 cinnamon. My situation was simple enough. sda1 is 200GB and was empty, and sda2 is 100GB and Mint was installed there. The source and destination can be different disks (or even on different computers on a network, but I haven't used that feature). The destination should be bigger (certainly not smaller of course) than the source.

If you're planning to remove the original HDD after copying it, you'll need to make sure the new drive has a swap partition and change its entry in fstab accordingly. More on that later.

Boot and run Mint on the Live media. Open the file manager and click on the two partitions you want to copy from and to. Then it's mostly command line from there, so open a terminal. I usually use 'df -h' to see what's mounted. It shows the sizes, which helps ensure I get FROM and TO right in the next steps.

The text in quote boxes below is pasted from a VirtualBox VM where I created a new drive with the intention of copying everything on the working installed (Mint 17.3) OS to it and booting it. I understand it's a pointless exercise in a VM, but it's useful for the tutorial. :)

mint@mint ~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/cow 1001M 35M 966M 4% /
udev 990M 4.0K 990M 1% /dev
tmpfs 201M 1.1M 200M 1% /run
/dev/sr0 1.5G 1.5G 0 100% /cdrom
/dev/loop0 1.5G 1.5G 0 100% /rofs
none 4.0K 0 4.0K 0% /sys/fs/cgroup
tmpfs 1001M 8.0K 1001M 1% /tmp
none 5.0M 0 5.0M 0% /run/lock
none 1001M 996K 1000M 1% /run/shm
none 100M 16K 100M 1% /run/user
/dev/sda1 18G 6.9G 11G 41% /media/mint/1e5eef50-3996-4e27-b0f4-e13166eb08c3
/dev/sdb1 20G 44M 19G 1% /media/mint/da1dfd8e-362d-4b2e-bd18-3edaa754c396


So there you can see the two partitions. /dev/sda1 has 6.9GB used and /dev/sdb1 is virtually empty. You'll need the long UUID number of the destination partition later, if the intention is to boot the copy.

Make partitions/folders to use as the mount points:

mint@mint ~ $ sudo mkdir /media/FROM
mint@mint ~ $ sudo mkdir /media/TO


Next un-mount the two partitions (either with 'umount' or in the file manager)

mint@mint ~ $ sudo umount /dev/sda1
mint@mint ~ $ sudo umount /dev/sdb1


I'm copying from sda1 to sdb1 for the example so to mount them at the new points:

mint@mint ~ $ sudo mount /dev/sda1 /media/FROM
mint@mint ~ $ sudo mount /dev/sdb1 /media/TO


Then to create the copy I used:

mint@mint ~ $ sudo rsync -avA --progress /media/FROM/ /media/TO


The -aA part is essential. The small a is for 'archive' and it does the same as '-rlptgoD' which is recursive, copies links, preserves permissions, modification times, groups, owners and device and special files. The big A is for ACLs to be copied as well. I don't think Mint uses many of those, but the Nemo file manager couldn't mount drives when I tried without that.

The -v and --progress are to make the process a bit more interesting. You can see the amazing speeds the file system can do while large files are copying.

The last few lines of the output are shown below:

var/spool/samba/
var/tmp/
var/tmp/kdecache-john/
var/tmp/kdecache-john/icon-cache.kcache
10,547,304 100% 28.74MB/s 0:00:00 (xfr#163754, to-chk=2/219026)
var/tmp/kdecache-john/ksycoca4
973,200 100% 2.45MB/s 0:00:00 (xfr#163755, to-chk=1/219026)
var/tmp/kdecache-john/ksycoca4stamp
518 100% 1.33kB/s 0:00:00 (xfr#163756, to-chk=0/219026)

sent 6,882,106,634 bytes received 3,328,593 bytes 49,714,333.77 bytes/sec
total size is 6,867,749,195 speedup is 1.00
mint@mint ~ $


and the last two lines of the output of 'df' now look like:

/dev/sda1 18G 6.9G 11G 41% /media/FROM
/dev/sdb1 20G 6.9G 12G 38% /media/TO


---------------------------------------------------------------------------------------

So that's the copying done. If you want to use the copy next boot, there's a little more to be done.

So while still in the Live environment - first run inxi:

mint@mint ~ $ inxi -pou
Partition: ID-1: / size: 1001M used: 35M (4%) fs: overlay dev: /dev/cow uuid: N/A
ID-2: /media/FROM size: 18G used: 6.9G (41%) fs: ext4 dev: /dev/sda1
uuid: 1e5eef50-3996-4e27-b0f4-e13166eb08c3
ID-3: /media/TO size: 20G used: 6.9G (38%) fs: ext4 dev: /dev/sdb1
uuid: da1dfd8e-362d-4b2e-bd18-3edaa754c396
ID-4: swap-1 size: 2.15GB used: 0.00GB (0%) fs: swap dev: /dev/sda5
uuid: 2536e8a0-8b87-4a70-ae71-dc1b39e4cafe
Unmounted: No unmounted partitions detected


Carefully edit the copied /etc/fstab to make the line for the root of the file system include the uuid (in my case) of the copied partition (or the 'label' if you're using them). I use 'nano', but use the editor you prefer. Don't be tempted to leave blank lines, as it will reject those iirc:

mint@mint ~ $ sudo nano /media/TO/etc/fstab


Before:

Code: Select all

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=1e5eef50-3996-4e27-b0f4-e13166eb08c3 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=2536e8a0-8b87-4a70-ae71-dc1b39e4cafe none            swap    sw              0       0


After:

Code: Select all

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=da1dfd8e-362d-4b2e-bd18-3edaa754c396 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=2536e8a0-8b87-4a70-ae71-dc1b39e4cafe none            swap    sw              0       0


You'll need to create a new swap partition somewhere other than its original location, if your intention is to remove the original drive, but it can be done later. Leave the old drive in place for now so that the original swap file can be used if necessary. The system may boot without one, but I expect you would need to remove the 'swap' line from fstab.

Now all that remains is to 'chroot' to the copy and make Grub configure itself.

Unmount the TO partition and mount it at /mnt

mint@mint ~ $ sudo umount /dev/sdb1
mint@mint ~ $ sudo mount /dev/sdb1 /mnt


Then mount all the device files etc.

mint@mint ~ $ for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done


Then go there:

mint@mint ~ $ sudo chroot /mnt


The "mint" should change to red, then update-initramfs:

mint / # update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.19.0-32-generic
Warning: No support for locale: en_GB.utf8
mint / #


(The warning can be ignored, or may not be seen.)

Then all that remains is to configure the Grub boot loader:

mint / # grub-install --recheck /dev/sdb
Installing for i386-pc platform.
Installation finished. No error reported.


Finally update Grub:

mint / # update-grub
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-3.19.0-32-generic
Found initrd image: /boot/initrd.img-3.19.0-32-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
No volume groups found
Found Linux Mint 17.3 Rosa (17.3) on /dev/sda1
done


Exit from chroot and from the terminal window and reboot:

mint / # exit
mint@mint ~ $


As a variation on the above - you can just use it as a way of keeping a backup copy. The rsync manual explains that "It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination." which makes it fast to keep up to date...

Hoping I haven't missed any steps, or included any unnecessary ones, but please let me know if you encounter any problems.

Many thanks to austin.texas for the post with the original idea. Rsync is a really useful tool...

User avatar
administrollaattori
Level 11
Level 11
Posts: 3977
Joined: Tue Sep 03, 2013 4:51 am
Location: Finland
Contact:

Re: How to copy a Mint installation and boot it.

Postby administrollaattori » Sat Feb 27, 2016 4:35 pm

From running system you can use command

Code: Select all

sudo rsync -aAXv --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*} /* /media/TO

johnniedoo
Level 2
Level 2
Posts: 50
Joined: Sun Jun 15, 2014 4:33 pm
Location: USA, NYC,NOLA,CT

Re: How to copy a Mint installation and boot it.

Postby johnniedoo » Wed Mar 02, 2016 7:16 pm

mint@mint ~ $ sudo nano /media/TO/etc/fstab

I got this far without any real problem, but I did not know what to change in the fstab that showed up
I have a new drive i put in (SSD) and the "FROM" was sda2 the "TO" is sdb2. i have all the UUID number ids but do not know how or what to edit or add.
not sure if i need to add a line, modify or remove and add.
I am doing anything like this (in linux) for the first time.
I am afraid to turn off the computer or re boot-it is on the LIve USB now. I do not know which , if any, partitions it will try to boot into. my fear is that it wont be able to boot at all.
I am not sure if i am stuck here. or am on the right course.
John

johnniedoo
Level 2
Level 2
Posts: 50
Joined: Sun Jun 15, 2014 4:33 pm
Location: USA, NYC,NOLA,CT

Re: How to copy a Mint installation and boot it.

Postby johnniedoo » Sun Mar 06, 2016 11:24 am

Sunday Mar6
I went back to this tutorial type place and all worked out just as it should except for the last stage or step installing recheck grub. it did not indicate anything about finding Mint17.3Rosa. only 2 memtest lines
I show a dual boot screen sda2 and sdb2 but it will only mount to sda2 regardless of which i choose
I do not know where to go to backtrack what i missed. I followed down this step by step with all results looking as they did on the site's page until the last grub install recheck and i got the hint there was no mount or something correct, just do not know where. still
i dont expect anyone to have telepathic vision either. i am going back to retrace the entries i made. the uuid is changed to the new one on the new drive and all boots up fine just to the old HDD still sda2. rather than sdb2
john

User avatar
chrisuk
Level 4
Level 4
Posts: 408
Joined: Thu Jun 12, 2008 6:16 am

Re: How to copy a Mint installation and boot it.

Postby chrisuk » Sun Mar 06, 2016 2:22 pm

Apologies if I've misread and misunderstood your post, but none of the typing is needed.

I've two laptops and a two desktops running clones of the one install; I've also four usb hard drives running the same clones. So eight identical Linux Mint installs. All were cloned using Timeshift. Both laptops have different hardware and gfx (one Nvidia - one Intel shared). One desktop has Nvidia gfx, the other AMD. I just cick "Clone" - include the Home folder from the options - select the target, and Timeshift does the rest. Grub, fstab etc. all setup too.

Linux detects the different hardware at boot, no problems as long as the same architecture (all 64bit)
Chris

LMDE2 MATE - SparkyLinux - MX Linux - Solus

User avatar
administrollaattori
Level 11
Level 11
Posts: 3977
Joined: Tue Sep 03, 2013 4:51 am
Location: Finland
Contact:

Re: How to copy a Mint installation and boot it.

Postby administrollaattori » Sun Mar 06, 2016 3:20 pm

chrisuk wrote:Apologies if I've misread and misunderstood your post, but none of the typing is needed.

I've two laptops and a two desktops running clones of the one install; I've also four usb hard drives running the same clones. So eight identical Linux Mint installs. All were cloned using Timeshift. Both laptops have different hardware and gfx (one Nvidia - one Intel shared). One desktop has Nvidia gfx, the other AMD. I just cick "Clone" - include the Home folder from the options - select the target, and Timeshift does the rest. Grub, fstab etc. all setup too.

Linux detects the different hardware at boot, no problems as long as the same architecture (all 64bit)

Too easy .. :lol:

johnniedoo
Level 2
Level 2
Posts: 50
Joined: Sun Jun 15, 2014 4:33 pm
Location: USA, NYC,NOLA,CT

Re: How to copy a Mint installation and boot it.

Postby johnniedoo » Sun Mar 06, 2016 5:11 pm

chrisuk wrote:Apologies if I've misread and misunderstood your post, but none of the typing is needed.

I've two laptops and a two desktops running clones of the one install; I've also four usb hard drives running the same clones. So eight identical Linux Mint installs. All were cloned using Timeshift. Both laptops have different hardware and gfx (one Nvidia - one Intel shared). One desktop has Nvidia gfx, the other AMD. I just cick "Clone" - include the Home folder from the options - select the target, and Timeshift does the rest. Grub, fstab etc. all setup too.

Linux detects the different hardware at boot, no problems as long as the same architecture (all 64bit)


this is great information--I have looked it over at teejee and will be trying it.
However, I did manage to get through the instructions and only ran into some minor issue changing the default boot order. which i have also gotten taken care thanks to the help of a couple of very concise and patient people. It took me a few tries but in the process, I was able to learn things I did not grasp prior. I am very grateful for the help since it got the job done and gave me a proper learning experience...way beyond the copy/paste stuff I had depended on over the past year since I've been at Linux-mint 17. I began when the lts 17.1 came out.
thanks
john

User avatar
linx255
Level 5
Level 5
Posts: 546
Joined: Mon Mar 17, 2014 12:43 am

Re: How to copy a Mint installation and boot it.

Postby linx255 » Fri Sep 16, 2016 11:45 pm

Very cool tutorial.

What if I want to have one /boot on its own partition to boot into two different Mint copies?
Let's say I have this /boot partition already setup and one Mint on sda5.
I want to setup another functionally identical Mint on sda6.
I don't want two /boot partitions, however.

So far no problems just using rsync, modify fstab, tune2fs /dev/sda# -U UUID, and modify grub.cfg UUID assignments, and both Mints share one /boot partition.

What does the update-initramfs step do and can / should it be modified to work with one /boot partition?

What about the grub-install & update grub commands? Should that be done from the first Mint or second, or should it be done more than once?

But I do suppose a 2nd / redundant /boot would be better for stability reasons, huh?
Maybe I do want two /boot partitions if that works.
Maybe each OS should be totally isolated.
I'm guessing both would need to be flagged as 'boot' and the 2nd Mint would need to point to the right one. )
- I'm running Mint 18 Mate 64-bit
- I'm using #!/bin/bash on all scripts, default sh is set to bash instead of dash

User avatar
austin.texas
Level 20
Level 20
Posts: 11037
Joined: Tue Nov 17, 2009 3:57 pm
Location: at /home

Re: How to copy a Mint installation and boot it.

Postby austin.texas » Thu Jan 05, 2017 11:30 am

linx255 wrote:What if I want to have one /boot on its own partition to boot into two different Mint copies?
Let's say I have this /boot partition already setup and one Mint on sda5.
I want to setup another functionally identical Mint on sda6.
I don't want two /boot partitions, however.

It is generally not necessary to have a /boot partition - unless you are doing something special like a RAID or LVM.
Do you need one for that?

By the way, yesterday I followed this tutorial to copy a Mint 18 Cinnamon root partition to a new drive, and it worked perfectly.
Good job, Old Ruler!
Mint 18.1 Cinnamon, Quad core AMD A8-3870 with Radeon HD Graphics 6550D, 8GB DDR3, Ralink RT2561/RT61 802.11g PCI
Microsoft-free environment since 1996

Linux Linx 2017


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 3 guests