I have been having issues with the XBian-copier utility, similar to other users (also a bug report of same). Before I directly troubleshoot that, I would like to know if I can invoke the XBian copier from a simple command (or set of commands), like

Code:

xbian-copier /dev/mmcblk0 /path/to/file.img

I was digging around in the xbian-config include files (in /usr/local/include/xbian-config/), but failed to extract something simple from them.

Summary: How can I execute the same function of the XBian-config's XBian copier from the command line?

From the other post, I can invoke the XBian-config utility's xbiancopy function:

Code:

xbian-config xbiancopy start source dest [label] [size]

source: Source partition - normally this is /dev/root (actually booted root), but can by used to copy others as well (btrfs only)
dest: Destination partition - like /dev/sda2 etc. if "dest" is prefixed with "file:", then file will be created
label: By default is "xbian-copy" used
size: (This makes sense only for destination as file.) By default, it is size of source partition, but sometimes, you have 16gb SD card, but 2gb used, so could be specified.

the middleware is btrfs-auto-snapshot script which uses few different approaches. base idea for cloning btrfs is of course to use the native btrfs send | btrfs recv (it is atomic, copied are data streams not files so it is faster, supports incremental sends (on CoW the data saved since last send).

the img is created as:
1) file is created
2) file is truncated do needed size (size prealocation)
3) in the file 2 partitions are created (/boot and /btrfstop
3a) the parts are mounted via loop devices
4) into /boot /boot is copied and cmdline.txt adapted
5) btrfs send | btrfs recv is used to copy all found subvolumes
6) done

by default size of img is defined as used space reported by df (which unnecessary allocates waste space used by local snapshots which are NOT copied) + 500MB.

this size can be overriden on command line --size

check

Code:

btrfs-auto-snapshot --help

currently I added copying even from ANY filesystem to ANY files-system (via tar | tar -x) but because of formatting of dest partition only ext2/3/4 f2fs nfs is tested and paired with mkfs. this universal copy-to-copy is in /usr/local/include/xbian-config/modules/xbiancopy/main as one function.