8

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 /dev/loop*
crw-rw---- 1 root disk 10, 237 Oct  4 15:50 /dev/loop-control

Running losetup -D doesn't help at all.

Why is this occuring?


Below is the full strace output:

# strace -fs80 losetup -f  /media/2TB/sdb2-fix-file
execve("/usr/bin/losetup", ["losetup", "-f", "/media/2TB/sdb2-fix-file"], 0x7ffc6fe88c38 /* 164 vars */) = 0
brk(NULL)                               = 0x55a51e754000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=215090, ...}) = 0
mmap(NULL, 215090, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f35d682e000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libsmartcols.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000n\0\0\0\0\0\0@\0\0\0\0\0\0\0\210\341\2\0\0\0\0\0\0\0\0\0@\0008\0\10\0@\0\34\0\33\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=190600, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f35d682c000
mmap(NULL, 2290720, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f35d640f000
mprotect(0x7f35d643b000, 2097152, PROT_NONE) = 0
mmap(0x7f35d663b000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2c000) = 0x7f35d663b000
mmap(0x7f35d663e000, 1056, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f35d663e000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\20\2\0\0\0\0\0@\0\0\0\0\0\0\0\360s\37\0\0\0\0\0\0\0\0\0@\0008\0\n\0@\0G\0F\0\6\0\0\0\5\0\0\0@\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2065840, ...}) = 0
mmap(NULL, 3893456, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f35d6058000
mprotect(0x7f35d6206000, 2093056, PROT_NONE) = 0
mmap(0x7f35d6405000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ad000) = 0x7f35d6405000
mmap(0x7f35d640b000, 14544, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f35d640b000
close(3)                                = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f35d6829000
arch_prctl(ARCH_SET_FS, 0x7f35d6829740) = 0
mprotect(0x7f35d6405000, 16384, PROT_READ) = 0
mprotect(0x7f35d663b000, 8192, PROT_READ) = 0
mprotect(0x55a51ccf5000, 4096, PROT_READ) = 0
mprotect(0x7f35d6863000, 4096, PROT_READ) = 0
munmap(0x7f35d682e000, 215090)          = 0
brk(NULL)                               = 0x55a51e754000
brk(0x55a51e775000)                     = 0x55a51e775000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1687072, ...}) = 0
mmap(NULL, 1687072, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f35d668d000
close(3)                                = 0
stat("/sys/block", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
uname({sysname="Linux", nodename="svelte", ...}) = 0
stat("/dev/loop-control", {st_mode=S_IFCHR|0660, st_rdev=makedev(10, 237), ...}) = 0
openat(AT_FDCWD, "/dev/loop-control", O_RDWR|O_CLOEXEC) = -1 ENODEV (No such device)
stat("/dev/loop", 0x7fffae014c60)       = -1 ENOENT (No such file or directory)
stat("/dev/loop0", 0x7fffae014c00)      = -1 ENOENT (No such file or directory)
stat("/dev/loop1", 0x7fffae014c00)      = -1 ENOENT (No such file or directory)
stat("/dev/loop2", 0x7fffae014c00)      = -1 ENOENT (No such file or directory)
stat("/dev/loop3", 0x7fffae014c00)      = -1 ENOENT (No such file or directory)
stat("/dev/loop4", 0x7fffae014c00)      = -1 ENOENT (No such file or directory)
stat("/dev/loop5", 0x7fffae014c00)      = -1 ENOENT (No such file or directory)
stat("/dev/loop6", 0x7fffae014c00)      = -1 ENOENT (No such file or directory)
stat("/dev/loop7", 0x7fffae014c00)      = -1 ENOENT (No such file or directory)
open("/dev/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=3400, ...}) = 0
getdents(3, /* 170 entries */, 32768)   = 4936
getdents(3, /* 0 entries */, 32768)     = 0
close(3)                                = 0
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2997, ...}) = 0
read(3, "# Locale name alias data base.\n# Copyright (C) 1996-2017 Free Software Foundatio"..., 4096) = 2997
read(3, "", 4096)                       = 0
close(3)                                = 0
open("/usr/share/locale/en_AU.utf8/LC_MESSAGES/util-linux.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_AU/LC_MESSAGES/util-linux.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/util-linux.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/util-linux.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "losetup: ", 9losetup: )                = 9
write(2, "cannot find an unused loop device", 33cannot find an unused loop device) = 33
write(2, "\n", 1
)                       = 1
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++

closed as off-topic by Satō Katsura, Kusalananda, G-Man, Jeff Schaller, Shadur Oct 8 '17 at 12:46

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Satō Katsura, Kusalananda, G-Man, Jeff Schaller, Shadur
If this question can be reworded to fit the rules in the help center, please edit the question.

  • In case it's an XY-problem: You can mount images files etc. directly and mount will take care of the loop device. You don't have to call losetup anymore, though I guess it still floats around in many tutorials on the web ... – dirkt Oct 8 '17 at 5:20
  • I'm trying to create an overlay device for use with dm-setup. For others wondering, here's what an XY problem is. – Tom Hale Oct 8 '17 at 6:03
  • Perhaps it needs the loop module loaded.. # modprobe loop. – Ralph Rönnquist Oct 8 '17 at 7:59
  • 2
    I disagree with closing this. "off-topic as they are unlikely to help future readers" is false in this case. I had the same problem and the solution provided helped me. – user31389 Dec 25 '18 at 13:27
8

The kernel modules on disk were incompatible with the running kernel. I had updated my kernel and not yet rebooted.

Running modprobe loop gave me:

modprobe: FATAL: Module loop not found in directory /lib/modules/4.9.51-1-MANJARO.

After rebooting, modprobe loop worked just fine.

  • So the problem was "modules on disk incompatible with running kernel"? – dirkt Oct 8 '17 at 10:19
  • @dirkt Thanks, those were the words I wanted :) – Tom Hale Oct 8 '17 at 11:39
  • @dirkt I've been reflecting on this, and wonder how I would have worked out that that was indeed the cause, given the symptoms I was experiencing. (Previous upgrades caused no issues). If you have any pointers, I'd be glad to hear them. – Tom Hale Nov 14 '17 at 6:34
  • I figured this from your described solution ("after rebooting, it worked"). In general, compiling a kernel will change addresses etc., so that makes newly compiled modules incompatible with the old kernel. That's something you have to know, and it's easy to understand if you understand how assembly works. Which is also why you always reboot after you compile a new kernel. Without the information "I just had compiled a new kernel" it would have been hard to me to guess the problem. Which again shows it's very important to give all information about what you did when asking a question. – dirkt Nov 14 '17 at 6:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.