It's true that my answer was incomplete, due to time limitations I decided to deal with the easier part first, in case it was needed.
When it comes to cloning a complete distro to another partition, with all the settings and all files intact, the only foolproof method is to use a disk imaging application. Programs that work at the file-backup level, like rsync, or FSArchiver (both are available in LL repos) can never really do the job properly, sooner or later you will come across an error message about some file that just couldn't be copied for some reason. Here are the links, if you want to try going that route:
http://www.fsarchiver.org/
https://rsync.samba.org/
My favourite disk imaging application, that works 100% of the time, is Clonezilla. You can run it from a bootable CD or flash drive or you can install it on the hard drive just like any other distro. It is pure Linux, it supports a wide variety of file systems, it can be run from the terminal or a script, and it's free. The only drawback is that it doesn't offer incremental backups.
Here are the steps required to get the contents of /dev/sdb6 cloned to /dev/sdb2 with Clonezilla:
1) Create a folder or a dedicated partition for image files and backup scripts. In my case it's the dedicated partition /dev/sdb20
2) Boot to Clonezilla, start the command line and cd to that partition:
3) Create partition image of /dev/sdb6. Here is the script:
4) The script will create a folder similar to this one:
You need to modify two files inside that folder to change references from sdb6 to sdb2:
5) Run the "restore" script. It will restore the image of sdb6 to sdb2. To be exact, Clonezilla is tricked to think that it is restoring the image of sdb2 to sdb2.
6) Boot to another distro or live CD and change the UUID, Label and /etc/fstab of the new instance on /dev/sdb2. Currently those items are identical on both sdb6 and sdb2. They all need to be different.
Edit UUID in /etc/fstab
7) Change UUID in Grub2 and run
I don't use Grub2 so can't provide more details.
Below are the links to Clonezilla. You would need to do some more research because I'm using an older version (clonezilla-live-20141215-utopic-amd64) and some command line parameters might be different in newer versions.
http://www.clonezilla.org/
https://drbl.org/faq/fine-print.php?path...tition.faq
http://clonezilla.org/livehd.php
Hope this helps.
When it comes to cloning a complete distro to another partition, with all the settings and all files intact, the only foolproof method is to use a disk imaging application. Programs that work at the file-backup level, like rsync, or FSArchiver (both are available in LL repos) can never really do the job properly, sooner or later you will come across an error message about some file that just couldn't be copied for some reason. Here are the links, if you want to try going that route:
http://www.fsarchiver.org/
https://rsync.samba.org/
My favourite disk imaging application, that works 100% of the time, is Clonezilla. You can run it from a bootable CD or flash drive or you can install it on the hard drive just like any other distro. It is pure Linux, it supports a wide variety of file systems, it can be run from the terminal or a script, and it's free. The only drawback is that it doesn't offer incremental backups.
Here are the steps required to get the contents of /dev/sdb6 cloned to /dev/sdb2 with Clonezilla:
1) Create a folder or a dedicated partition for image files and backup scripts. In my case it's the dedicated partition /dev/sdb20
2) Boot to Clonezilla, start the command line and cd to that partition:
Code:
mount /dev/sdb20 /home/partimag
cd /home/partimag
3) Create partition image of /dev/sdb6. Here is the script:
Code:
#!/bin/bash
datetime=$(date +"%y%m%d-%H%M")
/usr/sbin/ocs-sr -q2 -j2 -z1 -i 2048 -fsck-src-part-y -p true saveparts lite-$datetime sdb6
4) The script will create a folder similar to this one:
Code:
lite-180224-1957
You need to modify two files inside that folder to change references from sdb6 to sdb2:
Code:
# edit this file (open it with any text editor)
parts
# rename this file
sdb6.ext4-ptcl-img.gz.aa
#
sdb2.ext4-ptcl-img.gz.aa
5) Run the "restore" script. It will restore the image of sdb6 to sdb2. To be exact, Clonezilla is tricked to think that it is restoring the image of sdb2 to sdb2.
Code:
#!/bin/bash
/usr/sbin/ocs-sr -e2 -c -t -r -k -p true restoreparts ask_user sdb2
6) Boot to another distro or live CD and change the UUID, Label and /etc/fstab of the new instance on /dev/sdb2. Currently those items are identical on both sdb6 and sdb2. They all need to be different.
Code:
tune2fs -U random /dev/sdb2
tune2fs -L mylabel /dev/sdb2
Edit UUID in /etc/fstab
7) Change UUID in Grub2 and run
Code:
sudo update-grub
I don't use Grub2 so can't provide more details.
Below are the links to Clonezilla. You would need to do some more research because I'm using an older version (clonezilla-live-20141215-utopic-amd64) and some command line parameters might be different in newer versions.
http://www.clonezilla.org/
https://drbl.org/faq/fine-print.php?path...tition.faq
http://clonezilla.org/livehd.php
Hope this helps.