4

I have a Linux machine I would like to clone, but I have to use it frequently and cannot take it down to use CloneZilla or other software that requires booting off of a live media. Is there anyway I can clone a running Ubuntu machine without powering the OS down? Ideally I want a single program that will handle the nitty-gritty for me. So a single-click or few-click program would be ideal.

I have seen that you can do this with rsync, but there is a lot of setup for that, especially since my drives aren't the exact same size. I would prefer something that is simpler to use.

4

Disclaimer: I am the original author of WereSync

WereSync can clone a running drive. It will also clone to a drive of a different size, including a smaller one if need be.

Install with pip:

pip install weresync

Then run the program with root permissions. It needs root permissions because it has to access your block devices in order to copy. The following is for a GPT partition table:

sudo weresync -C --grub-partition 2 --efi-partition 1 /dev/sda /dev/sdb

This command will make a bootable clone of /dev/sda on /dev/sdb. The -C flag marks that the target drive may not have the same partition scheme as the source drive. If the check fails, WereSync will repartition the target drive so it matches the source drive. After your first backup, you probably want to remove this flag, since the checking mechanism sometimes returns false positives and will erase the previous backup. WereSync backs up incrementally, so it's faster if you have the previous backup intact.

The --grub-partition flag should be passed the partition number for the partition on which grub should be installed. This is usually the partition mounted on /. So if you have /dev/sda2 as your root partition, pass --grub-partition 2 to WereSync.

The --efi-partition flag is only relevant to UEFI systems. It should be the number of your efi partition. If your efi partition is on /dev/sda1 pass --efi-partition 1 to WereSync. To find your efi partition use sudo parted /dev/sda p and look for the partition with the "boot" flag. It's number is in the far left column.

If you have your boot directory on a seperate partition, you will need to pass that partition's number to the --boot-partition flag.

This command will erase all data on /dev/sdb, so be sure to save any data you want from there. More documentation and command line options can be found at the WereSync documentation.


WereSync uses rsync, as mentioned in the question, but automatizes the process of copying. It will also update your fstab and reinstall grub to make the clone bootable. However, because of the variance of Linux systems, certain setups may not work properly.

Because of using rsync, clones made with WereSync will be update incrementally, greating increasing the speed of clones.

6
  • tried using this: sudo weresync -C /dev/sda /dev/sdb and got the following error: TypeError: str() takes at most 1 argument (2 given). Do you have any idea on how to solve this? I followed the instructions to install with pip, then could not run it with sudo weresync, so i run pip install with sudo -H option as well. now i can run for example sudo weresync -h but the "clone" command fails
    – flynorc
    Feb 14 '17 at 22:56
  • @flynorc Install with pip3, it's a python3 program. You may need to install pip3 first with sudo apt-get install python3-pip
    – DonyorM
    Feb 14 '17 at 22:58
  • thank you for a fast reply. I installed pip3 but it seems like i have bigger problems now (not related to the installation i guess...) the hard drive is no longer visible nor do i see it in bios :/. I'll try to put it to another pc and locate the problem... If i manage to bring it back to the cloning part and need more info i'll comment again. Thnx for now.
    – flynorc
    Feb 14 '17 at 23:30
  • @flynorc whoops, sorry about that. Let me know if you have anymore questions related to WereSync.
    – DonyorM
    Feb 14 '17 at 23:32
  • looks like drive is dead (also not working in another PC). Do you have any idea what could have caused that? strange...
    – flynorc
    Feb 15 '17 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.