How to clone your system with tar

tar

(tom) #1

salve

in case you want a full customized system on a other PC or on new SSD you can clone a customized system with bsdtar/tar.

you will need two things:

  1. a live system
  2. a media to store the system, perhaps a pen drive

how to proceed:

  1. boot your live system because then is /sys/ /root and so on the customized system are empty
  2. make two directory’s in /mnt
sudo mkdir /mnt/{src,dst}
  1. mount your system and your media for storing the system
sudo mount /dev/sdXY /mnt/src
sudo mount /dev/sdXY /mnt/dst
  1. go to the your system
cd /mnt/src
  1. start archiving your system
sudo tar cvpf /mnt/dst/myCustomizedSystem.tar.gz *

note: you can use this as backup

copy the customized system on the new media:

  1. boot your live system because then is /sys/ /root and so on the customized system are empty
  2. make two directory’s in /mnt
sudo mkdir /mnt/{src,newSystemPartition}
  1. mount the new and the storing media
sudo mount /dev/sdXY /mnt/src
sudo mount /dev/sdXY /mnt/newSystemPartition
  1. change to the new system partition
cd /mnt/newSystemPartition
  1. copy the tar to your new media
sudo tar xvpf /mnt/src/myCustomizedSystem.tar.gz
  1. if you use UUID thy must edit /etc/fstab on your new system and if you use grub /boot/grub.cfg must be updated to the new UUID.
    in case it’s new PC install the boot loader https://wiki.archlinux.org/index.php/Bootloader_installation

et voilà!

for more information please consult the man pages because you can use a different format like XZ or different compression program like pigz with different options

man tar

if you use a extra boot partition on your new media the partition must be mounted when you copy the system to the new media
2. make three directory’s in /mnt

sudo mkdir /mnt/{src,newSystemPartition}
sudo mkdir /mnt/newSystemPartition/boot
  1. mount the new and the storing media
sudo mount /dev/sdb1 /mnt/src
sudo mount /dev/sda1 /mnt/newSystemPartition/boot
sudo mount /dev/sda2 /mnt/newSystemPartition

How old is your Chakra installation?
(Skool182) #2

Hi,

Nice tutorial, but I suppose it’s better to use

sudo tar cvpf /mnt/dst/myCustomizedSystem.tar.gz ./

than

sudo tar cvpf /mnt/dst/myCustomizedSystem.tar.gz *

Because if you have some hidden files in the root directory (because you’ve a really custom filesystem), the * will not add it to the archive.


(tom) #3

this was always working for me so i can only talk about this and i think the supposed hidden files will be added.