2

Backgroud: Running XBian (Debian ARM distribution for Raspberry Pi), which uses BTRFS. I fragged my system and decided to start over. However, I ripped the image from the root filesystem device before starting fresh.

I have a running BTRFS system, and an image (raw filesystem data) file which contains the data from a previous installation. I want to access the data from this image file to restore configuration and things like that. So, I mount this image with the following command (I found the offset with fdisk /path/to/image.img, print, and then multiplied the start sector by 512, the sector size - e.g. start sector 10000, offset = 512*10000 = 5120000):

mount -t btrfs -o loop,offset=5120000 /path/to/image.img /mnt/prev-image

After this command, I see that (at /mnt/prev-image/) the filesystem doesn't look as straightforward as ext2 or other traditional filesystems. I am probably having a misunderstanding at this point, or with the mount command.

When I try to access a file from the image, say my Samba configuration, I navigate to /mnt/prev-image/root/@/etc/samba/smb.conf. But, I notice that I'm seeing the same filesystem as my main filesystem and that the smb.conf file I access is the same as my current Samba configuration in /etc/samba/smb.conf. I think BTRFS is treating the data in the image file as a baseline snapshot for my base system, and serving me the "latest" smb.conf file, which comes from my fresh installation.

I want to know how to access the data from the image file, and where my misunderstandings lie.

2 Answers 2

2

Your probable problem is that you've mounted the wrong subvolume. To mount the "parent" subvolume, throw an additional parameter into your "-o" section: subvolid=1 such that your whole line would now look like

mount -t btrfs -o loop,offset=5120000,subvolid=1 /path/to/image.img /mnt/prev-image

I think that should do the trick for you.

1
  • Mounting like this still merges the filesystems so that I can't see the two separate files. This works well when mounting on a non-btrfs system, though. Commented Feb 28, 2014 at 19:35
0

I understand this is an ancient question and probably no longer relevant to @palswim, but I will add my answer for the sake of others who come here from a search.

btrfs filesystems have a UUID. If you try to mount two btrfs filesystems that have the same UUID at the same time on the same computer there will be problems. Making a copy with dd and other similar techniques will preserve the UUID. Use btrfstune -U, -u, -M or -m to fix this situation. Check "man btrfstune".

https://btrfs.wiki.kernel.org/index.php/Gotchas#Block-level_copies_of_devices https://unix.stackexchange.com/a/553253/315251

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.