9

I am trying to perform a recovery operation on a btrfs image file that I have extracted using

# dd if=/dev/sda1 of=/mnt/sda1.img

The file seems to be properly extracted:

$ file sda1.img 
sda1.img: DOS/MBR boot sector

Reading it with parted is a bit opaque though

$ sudo parted sda1.img
GNU Parted 3.2
Using /run/media/robert/exthdd2/sda1.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Model:  (file)
Disk /run/media/robert/exthdd2/sda1.img: 240GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End  Size  Type  File system  Flags

Trying to mount it results in an errors

$ sudo mount -o loop -t btrfs sda1.img /mnt/
mount: mount /dev/loop0 on /mnt failed: Operation not supported

However, I can run a btrfs check on the image file, so it's not broken ...

What can I do to mount such an image file?

1 Answer 1

9

Try:

losetup /dev/loop0 sda1.img
mount /dev/loop0 /mnt

dding /dev/sda1 and using gparted against it does not make sense because you have a partition image and not a drive image. dding /dev/sda would be another thing. In that case you should use

kpartx -av sda.img

to create the loop devices for the partitions in the disk image and mount like

mount /dev/loop0p1 /mnt
2
  • Well, the root cause was the broken state of the btrfs image, but since your answer helped me track that down I'll accept it. I get the following errors in the kernel log which show that: [16253.333199] BTRFS: error (device loop0) in btrfs_replay_log:2334: errno=-95 unknown (Failed to recover log tree) Jul 30, 2015 at 8:29
  • You can also force partition table scan with (new enough?) losetup -P option. (man7.org/linux/man-pages/man8/losetup.8.html)
    – XTL
    Nov 11, 2015 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .