borg icon indicating copy to clipboard operation
borg copied to clipboard

can't use borg mount-ed device file backup for loop device

Open ThomasWaldmann opened this issue 10 years ago • 9 comments

From IRC:

It does not seem I can mount a device via a loop device (too bad, wanted to mount it without having to extract it):

# borg mount -o allow_root,dev,suid /repo::today /mnt
# losetup -f -r /mnt/dev/dm-18 
losetup: /mnt/dev/dm-18: failed to set up loop device: No such device or address

ThomasWaldmann avatar Jun 28 '16 10:06 ThomasWaldmann

(borg-env)tw@tux:~/w/borg$ borg --version
borg 1.0.4.dev62+ng02c72b9
(borg-env)tw@tux:~/w/borg$ borg create --read-special repo::spe /dev/sda1
(borg-env)tw@tux:~/w/borg$ borg list repo::spe -v
brw-rw-r-- root   disk          0 Fri, 2016-07-01 13:25:41 dev/sda1
(borg-env)tw@tux:~/w/borg$ borg mount repo::spe mnt
(borg-env)tw@tux:~/w/borg$ ls -l mnt/dev/sda1
brw-rw-r-- 1 root disk 0, 0 Jul  1 13:25 mnt/dev/sda1
(borg-env)tw@tux:~/w/borg$ sudo mount -o loop,ro mnt/dev/sda1 mnt2
mount: mnt/dev/sda1: failed to setup loop device: Permission denied

ThomasWaldmann avatar Jul 02 '16 15:07 ThomasWaldmann

Hmm, I suspect it is confused by mnt/dev/sda1 mode saying it is a block device, but it should be "regular file".

Considering that, I guess that this was not a sufficient fix: https://github.com/borgbackup/borg/pull/1216/files

Guess if we open and read the special file (like block device) like a regular file, we also have to reflect "regular" file in the item's metadata in the archive (and can not store the original mode there).

ThomasWaldmann avatar Jul 02 '16 15:07 ThomasWaldmann

Can you try sudo losetup -P /dev/loop0 mnt/dev/sda1 and then fdisk -l /dev/loop0 and ls /dev/loop0*? (assuming you don't have any loop devices mounted, if you do use loop1 or similar)

PlasmaPower avatar Jul 02 '16 15:07 PlasmaPower

@PlasmaPower what should running fdisk on a partition without MBR be good for?

ThomasWaldmann avatar Jul 02 '16 16:07 ThomasWaldmann

@ThomasWaldmann Oh, oops, I thought it was /dev/sda for some reason. Just see if sudo losetup /dev/loop0 mnt/dev/sda1 works.

PlasmaPower avatar Jul 02 '16 16:07 PlasmaPower

Fixed the mode, still no success:

(borg-env)tw@tux:~/w/borg$ ls -l mnt/dev/sda1 
-rw-rw-r-- 1 root disk 499122176 Jul  1 13:25 mnt/dev/sda1
(borg-env)tw@tux:~/w/borg$ sudo losetup /dev/loop0 mnt/dev/sda1
losetup: mnt/dev/sda1: failed to set up loop device: Permission denied

ThomasWaldmann avatar Jul 02 '16 18:07 ThomasWaldmann

crap, it was that allow_other/allow_root trap again.

now it works. :)

ThomasWaldmann avatar Jul 02 '16 18:07 ThomasWaldmann

I confirm it works now :) # borg mount --info --debug -o allow_root /backup/repo::archive /mnt # losetup /dev/loop0 /mnt/dev/dm-18 # mount -o ro /dev/loop0 /mnt2

sirchojin avatar Jul 04 '16 09:07 sirchojin

https://github.com/borgbackup/borg/pull/1242 was merged into 1.0-maint.

ThomasWaldmann avatar Jul 04 '16 12:07 ThomasWaldmann