gpt4 book ai didi

device-driver - Lostup -d 不工作

转载 作者:行者123 更新时间:2023-12-01 12:31:07 25 4
gpt4 key购买 nike

我在/tmp 文件夹中设置了 5 个带有备份文件的循环设备作为原始 40 MB 文件。

$ losetup -l
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop1 0 0 1 0 /tmp/1
/dev/loop2 0 0 0 0 /tmp/2
/dev/loop3 0 0 0 0 /tmp/3
/dev/loop4 0 0 0 0 /tmp/4
/dev/loop5 0 0 0 0 /tmp/5

我使用lvm为前4个设备创建了一个RAID阵列。因此,前 4 个设备变得繁忙,如下所示:
$ lsblk 
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 100M 0 part /boot/efi
├─sda2 8:2 0 900M 0 part
├─sda3 8:3 0 128M 0 part
├─sda4 8:4 0 372.6G 0 part
├─sda5 8:5 0 140.5G 0 part /
├─sda6 8:6 0 15G 0 part
├─sda7 8:7 0 186.3G 0 part
├─sda8 8:8 0 37.3G 0 part [SWAP]
├─sda9 8:9 0 93.1G 0 part
└─sda10 8:10 0 40.8G 0 part
loop1 7:1 0 78.1M 0 loop
├─vol_vg-raid4_rmeta_0 252:0 0 4M 0 lvm
│ └─vol_vg-raid4 252:8 0 48M 0 lvm
└─vol_vg-raid4_rimage_0 252:1 0 16M 0 lvm
└─vol_vg-raid4 252:8 0 48M 0 lvm
loop2 7:2 0 78.1M 0 loop
├─vol_vg-raid4_rmeta_1 252:2 0 4M 0 lvm
│ └─vol_vg-raid4 252:8 0 48M 0 lvm
└─vol_vg-raid4_rimage_1 252:3 0 16M 0 lvm
└─vol_vg-raid4 252:8 0 48M 0 lvm
loop3 7:3 0 78.1M 0 loop
├─vol_vg-raid4_rmeta_2 252:4 0 4M 0 lvm
│ └─vol_vg-raid4 252:8 0 48M 0 lvm
└─vol_vg-raid4_rimage_2 252:5 0 16M 0 lvm
└─vol_vg-raid4 252:8 0 48M 0 lvm
loop4 7:4 0 78.1M 0 loop
├─vol_vg-raid4_rmeta_3 252:6 0 4M 0 lvm
│ └─vol_vg-raid4 252:8 0 48M 0 lvm
└─vol_vg-raid4_rimage_3 252:7 0 16M 0 lvm
└─vol_vg-raid4 252:8 0 48M 0 lvm

我现在尝试删除循环设备 1。我在控制台或 dmseg 中都没有收到任何警告/错误:
$ sudo losetup -d /dev/loop1 
shehbaz@donjaffer:~$

现在,我再次列出所有设备如下:
$ losetup -l
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop1 0 0 1 0 /tmp/1
/dev/loop2 0 0 0 0 /tmp/2
/dev/loop3 0 0 0 0 /tmp/3
/dev/loop4 0 0 0 0 /tmp/4
/dev/loop5 0 0 0 0 /tmp/5
shehbaz@donjaffer:~$

我还看到 lsblk 输出与我上面提供的相同。

我尝试在我之前尝试过的命令上运行 strace(以查看是否存在某些权限被拒绝或未报告的某些其他形式的错误),我得到以下输出:
$ sudo strace losetup -d /dev/loop1
execve("/sbin/losetup", ["losetup", "-d", "/dev/loop1"], [/* 17 vars */]) = 0
brk(0) = 0x1985000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc13f271000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=108331, ...}) = 0
mmap(NULL, 108331, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc13f256000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/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\0\260R\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=134536, ...}) = 0
mmap(NULL, 2233952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fc13ee2e000
mprotect(0x7fc13ee4e000, 2093056, PROT_NONE) = 0
mmap(0x7fc13f04d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1f000) = 0x7fc13f04d000
mmap(0x7fc13f04f000, 1632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fc13f04f000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/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`\v\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1869392, ...}) = 0
mmap(NULL, 3972864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fc13ea64000
mprotect(0x7fc13ec24000, 2097152, PROT_NONE) = 0
mmap(0x7fc13ee24000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7fc13ee24000
mmap(0x7fc13ee2a000, 16128, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fc13ee2a000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc13f255000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc13f253000
arch_prctl(ARCH_SET_FS, 0x7fc13f253740) = 0
mprotect(0x7fc13ee24000, 16384, PROT_READ) = 0
mprotect(0x7fc13f04d000, 4096, PROT_READ) = 0
mprotect(0x60f000, 4096, PROT_READ) = 0
mprotect(0x7fc13f273000, 4096, PROT_READ) = 0
munmap(0x7fc13f256000, 108331) = 0
brk(0) = 0x1985000
brk(0x19a6000) = 0x19a6000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7216688, ...}) = 0
mmap(NULL, 7216688, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc13e382000
close(3) = 0
stat("/sys/block", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
uname({sys="Linux", node="donjaffer", ...}) = 0
stat("/dev/loop-control", {st_mode=S_IFCHR|0660, st_rdev=makedev(10, 237), ...}) = 0
stat("/dev/loop1", {st_mode=S_IFBLK|0660, st_rdev=makedev(7, 1), ...}) = 0
open("/dev/loop1", O_RDONLY|O_CLOEXEC) = 3
ioctl(3, LOOP_CLR_FD) = 0
close(3) = 0
close(1) = 0
close(2) = 0
exit_group(0) = ?
+++ exited with 0 +++
shehbaz@donjaffer:~$

我仍然看到所有设备都在使用 Lostup 命令。 -d 选项是否工作不正常?我也尝试卸载/dev/loop1,但它告诉我/dev/loop1 未安装。
$ umount -l /dev/loop1
umount: /dev/loop1: not mounted
shehbaz@donjaffer:~$

请帮忙。谢谢你。

最佳答案

关于上述 Tom hale 代码片段的重要说明:

bash 脚本中使用的lostup 命令对IFS 的值敏感。

试试这个来亲眼看看:

line="/dev/loop8 /somefile"
losetup $line # this works
IFS=""
losetup $line # this one will fail

如果您的变量 ($line) 包含多个参数,则 IFS 值允许 Lostup 检测它们。通过清除它,最后一个lostup认为完整的变量只有1个参数,这显然失败了。

关于device-driver - Lostup -d 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34093405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com