• How do I get two loop devices at the same time?

    From Chris Green@21:1/5 to All on Tue Aug 3 08:54:40 2021
    I want to mount both partitions of a .img disk image file at the same
    time, by default 'mount -o ....' uses the same loop device so on
    trying to mount the second partition one sees:-

    mount: /tmp/rootfs: overlapping loop device exists for /home/chris/dld/raspbian/2021-05-07-raspios-buster-armhf-lite.img.

    How do I crete a second loop device and get mount to use it?


    --
    Chris Green
    ·

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrzej Adam Filip@21:1/5 to Chris Green on Tue Aug 3 09:18:56 2021
    Chris Green <cl@isbd.net> wrote:
    I want to mount both partitions of a .img disk image file at the same
    time, by default 'mount -o ....' uses the same loop device so on
    trying to mount the second partition one sees:-

    mount: /tmp/rootfs: overlapping loop device exists for /home/chris/dld/raspbian/2021-05-07-raspios-buster-armhf-lite.img.

    How do I crete a second loop device and get mount to use it?

    According to "man mount" (on my comp)
    'mount -o loop' (no explicit loop device) should try to find/use
    unused loop device. Alternatively you may use
    'mount -o loop=…' to explicitly name loop device.

    --
    [Andrew] Andrzej A. Filip

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Burns@21:1/5 to Andrzej Adam Filip on Tue Aug 3 09:29:23 2021
    Andrzej Adam Filip wrote:

    Chris Green <cl@isbd.net> wrote:

    I want to mount both partitions of a .img disk image file at the same
    time, by default 'mount -o ....' uses the same loop device so on
    trying to mount the second partition one sees:-

    mount: /tmp/rootfs: overlapping loop device exists for /home/chris/dld/raspbian/2021-05-07-raspios-buster-armhf-lite.img.

    How do I crete a second loop device and get mount to use it?

    According to "man mount" (on my comp)
    'mount -o loop' (no explicit loop device) should try to find/use
    unused loop device. Alternatively you may use
    'mount -o loop=…' to explicitly name loop device.

    or try losetup, long time since I needed it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Green@21:1/5 to Andrzej Adam Filip on Tue Aug 3 10:04:52 2021
    Andrzej Adam Filip <anfi@onet.eu> wrote:
    Chris Green <cl@isbd.net> wrote:
    I want to mount both partitions of a .img disk image file at the same
    time, by default 'mount -o ....' uses the same loop device so on
    trying to mount the second partition one sees:-

    mount: /tmp/rootfs: overlapping loop device exists for /home/chris/dld/raspbian/2021-05-07-raspios-buster-armhf-lite.img.



    How do I crete a second loop device and get mount to use it?

    According to "man mount" (on my comp)
    'mount -o loop' (no explicit loop device) should try to find/use
    unused loop device. Alternatively you may use
    'mount -o loop=…' to explicitly name loop device.

    That doesn't seem to work though:-

    root@t470# fdisk -l 2021-05-07-raspios-buster-armhf-lite.img
    Disk 2021-05-07-raspios-buster-armhf-lite.img: 1.75 GiB, 1874853888 bytes, 3661824 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x9730496b

    Device Boot Start End Sectors Size Id Type
    2021-05-07-raspios-buster-armhf-lite.img1 8192 532479 524288 256M c W95 FAT32 (LBA)
    2021-05-07-raspios-buster-armhf-lite.img2 532480 3661823 3129344 1.5G 83 Linux
    root@t470# mkdir -p /tmp/boot
    root@t470# mkdir -p /tmp/rootfs
    root@t470# mount -o loop,offset=$((8192 * 512)) 2021-05-07-raspios-buster-armhf-lite.img /tmp/boot
    root@t470# mount -o loop,offset=$((532480 * 512)) 2021-05-07-raspios-buster-armhf-lite.img /tmp/rootfs
    mount: /tmp/rootfs: overlapping loop device exists for /home/chris/dld/pi/2021-05-07-raspios-buster-armhf-lite.img.
    root@t470#





    --
    Chris Green
    ·

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Green@21:1/5 to Chris Green on Tue Aug 3 11:18:59 2021
    Chris Green <cl@isbd.net> wrote:
    Andrzej Adam Filip <anfi@onet.eu> wrote:
    Chris Green <cl@isbd.net> wrote:
    I want to mount both partitions of a .img disk image file at the same time, by default 'mount -o ....' uses the same loop device so on
    trying to mount the second partition one sees:-

    mount: /tmp/rootfs: overlapping loop device exists for /home/chris/dld/raspbian/2021-05-07-raspios-buster-armhf-lite.img.

    ^M


    How do I crete a second loop device and get mount to use it?

    According to "man mount" (on my comp)
    'mount -o loop' (no explicit loop device) should try to find/use
    unused loop device. Alternatively you may use
    'mount -o loop=…' to explicitly name loop device.

    That doesn't seem to work though:-

    root@t470# fdisk -l 2021-05-07-raspios-buster-armhf-lite.img
    Disk 2021-05-07-raspios-buster-armhf-lite.img: 1.75 GiB, 1874853888 bytes, 3661824 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x9730496b

    Device Boot Start End Sectors Size Id Type
    2021-05-07-raspios-buster-armhf-lite.img1 8192 532479 524288 256M c W95 FAT32 (LBA)
    2021-05-07-raspios-buster-armhf-lite.img2 532480 3661823 3129344 1.5G 83 Linux
    root@t470# mkdir -p /tmp/boot
    root@t470# mkdir -p /tmp/rootfs
    root@t470# mount -o loop,offset=$((8192 * 512)) 2021-05-07-raspios-buster-armhf-lite.img
    /tmp/boot
    root@t470# mount -o loop,offset=$((532480 * 512)) 2021-05-07-raspios-buster-armhf-lite.img
    /tmp/rootfs
    mount: /tmp/rootfs: overlapping loop device exists for /home/chris/dld/pi/2021-05-07-raspios-buster-armhf-lite.img.

    root@t470#

    I found the answer (well, an answer), you need to limit the size of
    the first mount so (as the error message tells you) it doesn't overlap
    the second mount.

    The fdisk output shows the size, so the first mount needs to be:-

    mount -o loop,offset=$((532480 * 512)),sizelimit=256M 2021-05-07-raspios-buster-armhf-lite.img

    then the second one works OK with no error.


    Alternatively you can install kpartx and run:-

    kpartx -av 2021-05-07-raspios-buster-armhf-lite.img

    which does (almost) everything in one go, the partitions then get
    automounted.

    --
    Chris Green
    ·

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Burns@21:1/5 to Chris Green on Tue Aug 3 12:43:28 2021
    Chris Green wrote:

    Alternatively you can install kpartx

    Yes, I used to find that handy when using Xen VMs with LVM for storage.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)