losttup:找不到未使用的环路设备


10

我正在尝试创建一个循环设备,并收到一个我不理解的错误:

# losetup -f  /media/2TB/sdb2-fix-file
losetup: cannot find an unused loop device

我没有回路设备设置。来自的输出losetup -a为null,并且:

# ls -l /dev/loop*
crw-rw---- 1 root disk 10, 237 Oct  4 15:50 /dev/loop-control

跑步losetup -D根本没有帮助。

为什么会这样呢?


以下是完整的strace输出:

# 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 +++

如果这是一个XY问题:您可以直接挂载图像文件等,并mount会处理循环设备。您不必再打电话losetup了,尽管我猜想它仍然在网上的许多教程中
徘徊

我正在尝试创建用于的覆盖设备dm-setup。对于其他想知道的人,这是XY问题
汤姆·黑尔”

也许需要loop加载模块# modprobe loop
拉尔夫·隆奎斯特(RalphRönnquist),

2
我不同意结束这一点。在这种情况下,“偏离主题,因为它们不太可能帮助未来的读者”。我遇到了同样的问题,所提供的解决方案对我有所帮助。
user31389

Answers:


12

磁盘上的内核模块与正在运行的内核不兼容。我已经更新了内核,但尚未重启。

跑步modprobe loop给了我:

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

重新启动后,modprobe loop工作正常。


那么问题是“磁盘上的模块与正在运行的内核不兼容”吗?
dirkt

@dirkt谢谢,这些是我想要的词:)
汤姆·黑尔

@dirkt我一直在思考这个问题,并且考虑到我所遇到的症状,我想知道如何才能确定那确实是原因。(以前的升级没有引起问题)。如果您有任何指针,我将很高兴听到它们。
汤姆·黑尔

我从您所描述的解决方案(“重新启动后,可以正常工作”)中弄清楚了这一点。通常,编译内核会更改地址等,从而使新编译的模块与旧内核不兼容。这是您必须知道的,如果您了解汇编的工作原理,则很容易理解。这也是为什么您总是在编译新内核后重新引导。没有信息“我刚编译了一个新内核”,我将很难猜到问题所在。这再次表明,提供有关您在提问时所做的一切信息非常重要。
dirkt
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.