Forum
[SOLVED] Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Software (/forum-6.html)
+--- Forum: Installation (/forum-16.html)
+--- Thread: [SOLVED] Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? (/thread-2090.html)



Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? - TheBigD - 5th Feb, 2014 11:32 PM

I would like to restore an img file to an usb drive. The img file is much bigger then the usb drive, although the content should fit.

How do I do this? I'd like to do this from the RaspPi via ssh if possible.

The btrfs file system is new to me. When I mounted the img file I noted that things were saved in /@/ folders. So I assume that just copying things over to a the brfs partition on the usb drive would not work.

I tried using the xbiancopy via the cli but "btrfs-auto-snapshot xbiancopy -h" doesn't offer much in terms of documentation.


RE: Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? - mk01 - 6th Feb, 2014 12:27 AM

@TheBigD

btrfs-auto-snapshot has no support for restoring .img as this .img file is simply a blockdevice byte copy. normally, you would dd it back block device.

the size of created .img file is "used data at the time copy was taken" + 300MB.

the only difference you see comparing to other filesystems are the subvolumes (root, home, modules ...) you see. otherwise it is just filesystem as all others. if you are interested on system files, copy from "root/@". if you are interested in home (XBMC files, xbian user) then go for "home/@"

(always remember to copy ownership and mode file !!! when copying).


RE: Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? - TheBigD - 6th Feb, 2014 04:17 AM

Ok, so copying the files should work. Do i need to recreate the sub volumes on the target partiton? Like this?

Terminal
sudo -i

#mount img file after using parted to see offset
mount -o loop,ro,offset=36700160 /media/path/xbianBU140125/xbian.img /media/imgf

#format and mount usb stick to be used for system
umount /dev/sda2
mkfs.btrfs -L xbian-usb /dev/sda2
mount /dev/sda2 /mnt

cd /mnt

#create subvolumes?
btrfs subvolume create root
btrfs subvolume create home
btrfs subvolume create modules
btrfs subvolume create data

#copy files
rsync -aAX /media/imgf/root/@/* /mnt/root/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs} --progress

rsync -aAX /media/imgf/home/@/* /mnt/home/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs} --progress

rsync -aAX /media/imgf/modules/@/* /mnt/modules/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs} --progress

rsync -aAX /media/imgf/data/@/* /mnt/data/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs} --progress



RE: Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? - mk01 - 6th Feb, 2014 04:51 AM

oh, ok, ... forget all above and ...

yes, you can extract .img file to a partition. you have to map the .img with partition layout and use xbiancopy function from command line with speecifiing source different than default /dev/root:

Code:
sudo -i
modprobe loop
kpartx -av /path/to/my.img
btrfs-auto-snapshot xbiancopy /dev/mapper/loop0p2 /dev/sdXXXX
kpartx -dv /path/to/my.img

depending on kernel package version installed on .img and actual on /boot, after system boots reinstall kernel package if needed
Code:
apt-get install xbian-package-kernel

if you get error already installed

apt-get install --reinstall xbian-package-kernel

or second option is to take the /boot from img file (/dev/mapper/loop0p1) and copy to /boot


RE: Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? - TheBigD - 6th Feb, 2014 09:35 AM

Excellent! I haven't got it all up and running yet, but it seems that there is stuff on the usb stick now, so it looks promising.

Thanks!


RE: Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? - TheBigD - 8th Feb, 2014 05:49 AM

Just a follow up. Everything is up and running from the USB, as it should. I'll try to change the heading to reflect that.

My img files do not seem to be "the size of created .img file is "used data at the time copy was taken" + 300MB. " however. They seem to be the size of a raw copy to me.


RE: Can i use the "btrfs-auto-snapshot xbiancopy" cli to restore an img file? - mk01 - 17th Mar, 2014 11:37 PM

@TheBigD

"rawcopy" size ( -x00MB to allow flash if another card is used - same sized cards could have some minor differences) was used in very first version of this function.

I can't tell when exactly it was enhanced but it was already a while back.