Questions tagged [loop-device]

A loop device allows any file to be mounted as a filesystem image. Not to be confused with a loopback interface in networking. Don't use this tag for questions regarding "for-loops" (use the "for" tag instead).

A loop device is a pseudo-device that makes any file accessible through a block device. This way, a file containing a filesystem image can be mounted.

Not to be confused with , which is a network interface, or -loop, which is a looping construct for performing iterations in code.

179 questions
26
votes
3 answers

How to setup a growable loopback device?

I know I can create and use a loopback device like this: # Create the file truncate disk.img --size 2G # Create a filesystem mkfs.ext4 disk.img # Mount to use mount disk.img /mnt # Clean up umount /mnt However in this case the disk image is fixed…
phunehehe
  • 20,240
15
votes
1 answer

losetup: cannot find an unused loop device

I'm trying to create a loop device, and getting an error I don't understand: # losetup -f /media/2TB/sdb2-fix-file losetup: cannot find an unused loop device I have no loop devices setup. The output from losetup -a is null, and: # ls -l…
Tom Hale
  • 30,455
7
votes
2 answers

losetup --detach not removing loopback device

I am trying to detach a loopback device. The losetup --detach presumably succeeds (no error message and return code 0) but the device is still there. Any ideas? root@Cassiopeia:~# losetup -a /dev/loop1: [2053]:5243868…
pkaramol
  • 2,799
  • 6
  • 47
  • 79
6
votes
3 answers

Cannot mount a iso file "failed to setup loop device"

I am using Ubuntu 18.04, and trying to moutn Matlab ISO using the following command: sudo mount R2018a_glnxa64_dvd1.iso /mnt/cdrom -o loop But terminal is responding back as: mount: /mnt/cdrom: failed to setup loop device for…
6
votes
4 answers

Loop device with 4K sectors

Using the losetup command, you can turn a regular file into a pretend block device. You can then partition and format it like any other device. Is there some way to make Linux pretend that this "device" has a 4K logical sector size?
4
votes
1 answer

losetup: How to use the -f option?

For example, I would like to setup mydata.img to /dev/loop5, I would expect using the command below. However it gives the error losetp: unexpected arguments. losetup --show -Pvf /dev/loop5 mydata.img (-v is optional, just for more verbose output.…
midnite
  • 423
4
votes
0 answers

Provide loop device functionality for a regular file under a unique name

I want to add a few image files with file systems to a LVM volume group. If I make them available as loop devices changes are pretty high that one day the script gets corrupted due to an increasing number of used loop devices. Rather than increasing…
3
votes
3 answers

Loop Mounting in Parallel

I am doing a project in which I need to mount 100+ loop devices and merge it into AUFS mountpoint As an observation, for sequentially mounting 90 loop devices, it takes 25 seconds. I am looking for a solution which will minimize time by mounting…
SHW
  • 14,786
  • 14
  • 66
  • 101
2
votes
1 answer

Why does `losetup` need to associate loop devices with block devices?

man losetup says losetup is used to associate loop devices with regular files or block devices, to detach loop devices, and to query the status of a loop device. https://en.wikipedia.org/wiki/Loop_device says In Unix-like operating systems, a…
Tim
  • 101,790
0
votes
0 answers

sdm says the device is already mounted

Ubuntu 23.04, sdm v8.6, after rebooting the system I issue: sdm --customize \ --L10n \ --apt-dist-upgrade \ --autologin \ --hdmi-force-hotplug \ --journal none \ --nowait-timesync \ --ssh service \ …
Mark
  • 723
  • 1
  • 11
  • 24
0
votes
0 answers

How to sync a loop device when the backing file is changed

The data being displayed on a loop device mount is incorrect when the data in the underlying file is changed. Example: $ mkdir drv $ dd if=/dev/zero of=data.ext4 bs=1M count=10 $ mkfs.ext4 data.ext4 $ losetup /dev/loop0 data.ext4 $ mount /dev/loop0…
-1
votes
1 answer

WRITE_ZEROES not supported on loop devices

I ran into a strange problem where mkfs.ext4 won't work on loop devices backed by a temp file. tmp_file="$(mktemp)" fallocate -l 8M "$tmp_file" loop="$(losetup --show -f "$tmp_file")" mkfs.ext4 "$loop" I tried dd if=/dev/zero and truncate as well.…
user210007