4

I'm having a really strange issue.

I have backups of my machine in a local RAID array. They were created by Clonezilla, so I've created an actual filesystem image like so:

cat 2013-11-29/sda3.btrfs-ptcl-img.gz.* | gzip -d -c | \
    partclone.restore -C -s - -O 2013-11-29.sda3.img

This has created a nice big image file in the current directory.

However, when I go to mount it, I've noticed that it doesn't actually mount the image file; it simply creates a loop to /:

$ sudo mount 2013-11-29.sda3.img /mnt

To test this, I've created a simple file that shouldn't exist in the backup.

$ ls /home/naftuli | grep "newfile"
$ ls /mnt/home/naftuli | grep "newfile"
$ touch ~/newfile

I would expect that now, /home/naftuli/newfile exists, but /mnt/home/naftuli/newfile does not exist. However, it is apparent that the mount is looping to /, as the newfile exists in both places:

$ ls /home/naftuli | grep "newfile"
newfile
$ ls /mnt/home/naftuli | grep "newfile"
newfile

How can I force mount to mount the image file and specifically not loop to /?

Naftuli Kay
  • 38,686
  • 85
  • 220
  • 311

2 Answers2

4

Due to an implementation specific issue, I was unable to mount the image in the end.

On BTRFS, filesystem UUIDs need to be unique. When I tried mounting my partclone image, Linux would see that a device with the same image was already mounted at /, and therefore would simply loop back to that device. There isn't really a workaround, as BTRFS stores UUID information in every block and there isn't a way to simply ignore the UUID during mount.

Naftuli Kay
  • 38,686
  • 85
  • 220
  • 311
2

I think you need to provide the -o loop switch to mount these .img files.

Example

$ sudo mount -o loop 2013-11-29.sda3.img /mnt

You might need to provide the -t switch too, to mount. This switch tells mount the type of filesystem you're attempting to mount.

$ sudo mount -o loop -t ext3 2013-11-29.sda3.img /mnt

See the section in the mount man page, that covers loop devices.

References

slm
  • 363,520
  • 117
  • 767
  • 871
  • It's _still_ binding to `/` and not mounting the archive. If the volume id of the image file is the same as `/`, could that be the reason it won't use the image file, as it thinks its already mounted? – Naftuli Kay Dec 06 '13 at 08:33
  • I'm really thinking that mount is seeing that the volume ids of `2013-11-29.sda3.img` and `/` are the same and is refusing to "remount" the image and simply looping back to `/`. – Naftuli Kay Dec 06 '13 at 08:37