Xbian is my proffered media center solution for some time now and one of the great features is ability to create .img of your current system so that you can use it for backup purposes or multiplication.
All you need to do is to create your backup using xbian-config script run as root and navigate to Xbian copier:
To create .img in Destination field write following:
Image created this way can easily be restored with a simple dd command:
pv /[YOUR_PATH]/[YOUR_FILE/.img | dd of=/dev/mmcblk bs=1M
I am using here pv tool for progress monitoring of data through pipe, normal way would be without verbosed output:
dd if=/[YOUR_PATH]/[YOUR_FILE/.img of=/dev/mmcblk bs=1M
One cool thing you can do also is to mount your backup to a folder and use it for example to copy some files, compare configs etc.
First peace of information you will need to obtain is the start location of your btrfs partition in the .img file.
You can do this with fdisk command for example:
fdisk -l /mnt/volume_2/backup/xbian_20150804.img Disk /mnt/volume_2/backup/xbian_20150804.img: 8.1 GiB, 8665432064 bytes, 16924672 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x000af7b0 Device Boot Start End Sectors Size Id Type /mnt/volume_2/backup/xbian_20150804.img1 * 2048 71679 69632 34M b W95 FAT32 /mnt/volume_2/backup/xbian_20150804.img2 71680 16924671 16852992 8G 83 Linux
Notice the start sector of your btrfs partition is 71680, and your sector size is 512 bytes. You need to calculate the offset for this .img file so that you can mount directly to your btrfs partition.
Simple bash command would do:
echo "$((71680 * 512))" 36700160
Now you will need kernel loopback module for mounting image files if it is not already loaded;
And now finally the complete mount command:
mount -v -t auto -o loop,offset=36700160,ro /mnt/volume_2/backup/xbian_20150804.img /mnt/temp/ mount: /dev/loop0 mounted on /mnt/temp.
Now you can access your btrfs partition in /mnt/temp folder.