我正在尝试挂载命名空间。我有一个 python 脚本,它创建一个绑定挂载,之后是一个带有unshare
系统调用的挂载命名空间。我打印 PID,并暂停脚本。我可以列出这些坐骑:
nsenter --mount=/proc/PID/ns/mnt
mount
让 python 进程在调用之前被中断umount
(或者让我们说它由于某些错误而终止)。现在/proc/PID
消失了。系统会处于一致状态吗?我的意思是会umount
被自动调用,还是会以其他方式“清理”坐骑?
我已经安装/dev
并立即尝试卸载:
$ sudo mount -o rbind /dev m
$ sudo umount m
umount: /tmp/m: target is busy.
$ sudo lsof m
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
kdevtmpfs 55 root cwd DIR 0,6 4420 2 m
kdevtmpfs 55 root rtd DIR 0,6 4420 2 m
我已经读过fuser
可以杀死访问挂载点的进程,但我想了解在这个简单的情况下发生了什么。根据lsof
输出,是否使用挂载点作为当前工作目录(cwd)?
我不想使用惰性卸载。
我有一个程序可以在磁盘上创建分区和文件系统。为了测试它,我创建了一个图像文件:
dd if=/dev/zero of=disk.img bs=1M count=100
并安装:
sudo losetup /dev/loop0 disk.img
分区过程似乎有效,我收到一个错误mkfs
:
mkfs.vfat: unable to open /dev/loop0p2: No such file or directory
我可以看到分区fdisk -l
:
sudo fdisk -l /dev/loop0
Disk /dev/loop0: 1000 MiB, 1048576000 bytes, 2048000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B2CB131D-0091-4102-89E1-1D94EC49484A
Device Start End Sectors Size Type
/dev/loop0p1 2048 10239 8192 4M BIOS boot
/dev/loop0p2 10240 272383 262144 128M EFI System
/dev/loop0p3 272384 1320959 1048576 512M Linux swap
/dev/loop0p4 1320960 2047966 727007 355M Linux filesystem
但不是lsblk
:
sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 1000M 0 loop
sda 8:0 0 465,8G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 457,3G 0 part /
└─sda3 8:3 0 8G 0 part [SWAP]
我究竟做错了什么?
我在 Debian 9 上,想设置一个静态 IP 地址。按照本指南auto eth0
,我应该找到以in开头的行/etc/network/interfaces
,但这里没有这样的东西。这些东西在 Debian 9 中是否发生了变化?从ip a
我的网络接口是wlo1
- 或者这只是一个环回设备?
root@emerald:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
root@emerald:~# ls /etc/network/interfaces.d/
root@emerald:~#
输出ip a
:
root@emerald:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether ec:9a:74:f3:72:a9 brd ff:ff:ff:ff:ff:ff
3: wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 74:de:2b:9f:23:90 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic wlo1
valid_lft 86377sec preferred_lft 86377sec
inet6 fe80::76de:2bff:fe9f:2390/64 scope link
valid_lft forever preferred_lft forever