7

Assume I have two Debian 11 systems. System A with custom application setup. etc. And a vanilla system B. Now I would like to transfer the whole setup from A to B. I found some links, where users tried to transfer the whole root tree or clone their system to another drive. The main effort in this solutions are to re-install grub and adjust some crucial configuration files like fstab. Can I just exclude those directories, which contain crucial configurations files like /boot and /etc/fstab from copy/tar?

Or is there a tool that allows me make a backup of system A and create a boot able usb pen drive using this backup?

5
  • @BlockchainOffice do I have to run a live iso or unmount the source to clone the partition via dd if=/dev/sda of=/someotherlargedrive/backupname.iso bs=4M ?
    – Hölderlin
    Mar 22, 2023 at 14:28
  • 4
    If you can run a live iso or just an other distro from usb or an other drive it's better not to clone the running system. but cloning the running system will work too.
    – Z0OM
    Mar 22, 2023 at 14:34
  • a lot of people say don't clone a runnig system, but if you have no options it will work, don't forget to check your cloned drive after finish
    – Z0OM
    Mar 22, 2023 at 14:36
  • You can clone an image backup to a drive or clone directly to usb/hd etc.. from which you want to start it directly
    – Z0OM
    Mar 22, 2023 at 14:41
  • Don't forget the label name or uuid it will be the same on the cloned drive!
    – Z0OM
    Mar 22, 2023 at 14:45

1 Answer 1

2

One way is to create a blank os and copy all folders and files that you need.

There are a lot of tutorials for that.

Check for how to create a linux system backup with rsync

How To Backup Your Entire Linux System Using Rsync

Full system backup with rsync

The other way and the best way to clone a whole drive, partition with data or an os on a drive and I prefer that myself, is with dd, the best in my opinion for clone/backup of devices/partitions.

dd will clone everything bit per bit.

Before you start experimenting and trying out different tools, I would do a full backup/clone of the device to another with dd, if you have the option, and check if the backup/clone works.

If your whole devices is encrypted with luks as an example, you can do a whole clone and flash to your new device, that will work too!

If you work with mounted fuse/sshfs you can backup/clone directly to this network folders too.

You can list all your block devices with lsblk

Example:

  1. if your drive is /dev/sda and you wanna store/backup/clone on a directory or storage
dd if=/dev/sda of=/home/user/osbkp.img bs=1M status=progress

You don't need name.img it can be os123.bkp too

  1. do a live clone of a running system to target drive without creating an image.

source is /dev/sda and target is /dev/sdb

dd if=/dev/sda of=/dev/sdb bs=1M status=progress

Sometimes you create the new backup/clone to your new drive but you can't start from this device, than try again with dd(nothing works 100%)

  1. clone the image to a new drive, where target is /dev/sdb
dd if=/home/user/osbkp.img of=/dev/sdb bs=1M status=progress
  1. clone a given partition
dd if=/dev/sda1 of=/home/user/part1.img bs=1M status=progress

Explain:

if=INPUT/SOURCE

of=OUTPUT/TARGET

bs=BLOCKS SIZE FOR COPY There are different blocksize that can be used I prefer 1MB, you can speed the process up or slow done with this setting, you have to find by yourself what is the best option

status=progress STATUS IN REALTIME

  1. if you work with fat* as storage you can split the files, take a look at that posts too:

Break up a dd image into multiple files

Creating a 80GB image with dd on a FAT32 drive

There are a few thinks that you have to keep in mind:

0. dd will clone everything of this devices.

Your drive is /dev/sda and you clone this

with 5 partitions

/dev/sda1 /dev/sda2 /dev/sda3 /dev/sda4 /dev/sda5

You will get one file from /dev/sda with all this partitions, mbr, gpt, etc..

1. You can clone to every drive/storage

  • You can clone from a harddisk to usb, or usb to harddisk, etc.. and run your cloned os from your new device

2. Your running target devices must have the same size or must be bigger

  • you can't clone a bigger device to a smaller drive or clone only the used space of a partition
  • Example: Your partition to clone is 8 GB but your os on the partition is only 1GB so you have free space of 7 GB, your target where you wanna clone to run your os is 4GB, this is not possible! You will clone the whole device with dd to your new drive you can't resize this.

If you clone to a bigger devices you can create a new partition with the remaining space and mount/use that on your new device/os.

Take care if you try to merge the remaining space to your given partition!

3. The best way is to use a live system or other linux systems and than plugin your drives and clone from target to source or from target to storage

4. every device has it's unique uuid and a label name that identified the device if you clone drive a to b and you have both drives in one pc and you try to boot one of them with the label name or uuid, check grub or your bootmanager you will get a problem or you boot the wrong os.

You can check this with blkid and other commands.

You can change that and generate a new uuid, label, etc.. but be careful

5. You don't need to format the drive where your cloned image will run the dd will destroy/delete everything an create the new mbr, gpt, format, filesystem etc. from the given backed os

Create your basic clones with dd and do your stuff, but later I mean it is better to clone/copy only the changed files.

In GNU/LINUX everything is a File.

4
  • 1
    Your recommendation for rsync only regards the backup, there is no procedure to create a cloned boot able usb pen drive compare to dd? Or is dd just the simpler way?
    – Hölderlin
    Mar 22, 2023 at 15:06
  • dd is the simpler and better way in my opinion. with rsync you have to install a blank os and than copy the files with rsync. there are a lot of tutorials
    – Z0OM
    Mar 22, 2023 at 15:15
  • Make the full backup with dd and after that you can use rsync for the custom changed files
    – Z0OM
    Mar 22, 2023 at 15:19
  • You can try also the using of git on the cloned drive for the changes. there are a lot you can do and write so much about it and there are many options
    – Z0OM
    Mar 22, 2023 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .