Re: Easiest Way to Mount an Image File
Hi.
On Sun, 18 Dec 2016 08:41:01 -0600
"Martin McCormick" <martin.m@suddenlink.net> wrote:
> The following command works:
>
> sudo losetup /dev/loop0 /home/pgmaudio/2016-11-25-raspbian-jessie-lite.img
>
> When one does
>
> fdisk -l /dev/loop0 the result is sensable:
>
> Device Boot Start End Blocks Id System
> /dev/loop0p1 8192 137215 64512 c W95 FAT32 (LBA)
> /dev/loop0p2 137216 2715647 1289216 83 Linux
You could do the same without being root:
/sbin/fdisk -l /home/pgmaudio/2016-11-25-raspbian-jessie-lite.img
Or, better yet:
/sbin/parted /home/pgmaudio/2016-11-25-raspbian-jessie-lite.img print
> If you try something like
>
> sudo mount /dev/loop0 p2 /mnt
>
> The report is that it doesn't exist and ls /dev/loop0* only shows
> the original loop0 loopback device. I looked through all of /dev
> such as /dev/mapper and there seems to be nothing else pertaining
> to loop0 so what am I missing?
You're missing two things:
1) While losetup 'cooks' you a block device from the file, it does not
expose underlying partitions. What you need is:
sudo kpartx -a /home/pgmaudio/2016-11-25-raspbian-jessie-lite.img
Look for devices created in /dev/mapper, don't forget to run afterward:
sudo kpartx -d /home/pgmaudio/2016-11-25-raspbian-jessie-lite.img
2) You don't need to invoke losetup at all to mount a filesystem inside
a file. mount(1) is clever enough to do it on behalf of you:
sudo mount -o offset=$((512*8192)) \
/home/pgmaudio/2016-11-25-raspbian-jessie-lite.img <mountpoint1>
sudo mount -o offset=$((512*137216)) \
/home/pgmaudio/2016-11-25-raspbian-jessie-lite.img <mountpoint2>
Reco
Reply to: