V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  wniming  ›  全部回复第 5 页 / 共 24 页
回复总数  474
1  2  3  4  5  6  7  8  9  10 ... 24  
148 天前
回复了 saranz 创建的主题 Linux 各位 Linux 用的输入法都是?
我装了 fcitx 但只是作为带历史记录的剪切板用,平常打字(也包括现在回复你的帖子),都是用:

https://chromewebstore.google.com/detail/google-input-tools/mclkkofklkfljcocdinagocijmpgbhab?hl=en

因为开着 hk 的梯子所以打字的输入速度还是很快的,我觉得应该要比任何需要安装的 linux 输入法还要快。
148 天前
回复了 yagamil 创建的主题 生活 将来你老了,你最后悔的会是什么?
别的都不后悔,只后悔投胎
155 天前
回复了 imes 创建的主题 Rust RUST 的未来在哪里?
rust 适合用来开发轻量级 vmm ,cloud-hypervisor ,firecracker microvm 这种,公有云场景下非常注重安全性。
@kiracyan 是,老款的百兆网口的 tp 路由器可以单独关闭 dhcp ,新款的千兆网卡的都不支持,你用的是百兆 x 老款的那种吧?
@kuanat #32

dnf --installroot=/path/to/fedora_rootfs 这个确实不如 chroot /path/to/fedora_rootfs dnf ,dnf --installroot= 这种方式会导致 dnf history 时显示的 Command line 会包含 installroot 相关的几个参数,如果我一次性在命令行指定很多个包时后面的包会显示不出来,dnf --installroot= 更适合在空目录创建全新的 base rootfs 。
@zbinlin #29 可以,在我的这个使用场景下效果和 podman unshare 一样,你这个方法才是我发帖时最想得到的答案
@77ShiORi 这个是在开启无线桥接的情况下才能生效的,已经打算换小米路由器了,tplink 真是在退步,之前我用了好几年的老款 tplink 百兆路由器还支持单独关闭 dhcp ,新款居然不支持,真不知道他们产品经理是咋想的
@yanqiyu #24

dnf --installroot 应该是只需要 root 用户的,但是实测是不行的,不管是 fuse2fs -o fakeroot 还是普通的目录都报一样的错:

d@develop:~$ bwrap --dev-bind / / --unshare-user --uid 0 --gid 0 dnf --installroot=/home/d/.local/mnt/1/ --releasever=/ --config /etc/dnf/dnf.conf install vi
Last metadata expiration check: 0:05:21 ago on Sun 30 Jun 2024 05:57:21 PM CST.
Dependencies resolved.
===================================================================================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================================================================================
Installing:
vim-minimal x86_64 2:9.1.158-1.fc40 fedora 806 k
Installing dependencies:
vim-data noarch 2:9.1.158-1.fc40 fedora 23 k

Transaction Summary
===================================================================================================================================================================================================================
Install 2 Packages

Total size: 829 k
Installed size: 1.6 M
Is this ok [y/N]: y
Downloading Packages:
[SKIPPED] vim-data-9.1.158-1.fc40.noarch.rpm: Already downloaded
[SKIPPED] vim-minimal-9.1.158-1.fc40.x86_64.rpm: Already downloaded
Running transaction check
Transaction check succeeded.
Running transaction test
RPM: error: Unable to change root directory: Operation not permitted
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction test error:
Errors occurred during test transaction.

d@develop:~$
@guo4224 #21
@yanqiyu #22

刚才又试了一下不用 fuse2fs -o fakeroot 这种方式挂载的目录,就用普通的目录作为 rootfs 会怎样,结果还是不行:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.6 MB/s | 11 MB 00:06
Fedora 40 - x86_64 1.6 MB/s | 1.6 kB 00:00
Importing GPG key 0xA15B79CC:
Userid : "Fedora (40) <[email protected]>"
Fingerprint: 115D F9AE F857 853E E844 5D0A 0727 707E A15B 79CC
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-40-x86_64
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
RPM: error: Unable to change root directory: Permission denied
[Errno 13] Permission denied: '/home/d/.local/mnt/2/var/lib/dnf/rpmdb_lock.pid'
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Failed to store expired repos cache: [Errno 13] Permission denied: '/home/d/.local'
[Errno 13] Permission denied: '/home/d/.local'
d@develop:~$
@guo4224 #21
@yanqiyu #22

实际上 setuid 是无法满足我的这个需求的,原因跟我 #8 楼说的一样,比如我给 python 设置了 s 标志:

chmod u+s /usr/bin/python3.12

然后执行 dnf:

d@develop:~$ dnf --installroot=/home/d/.local/mnt/0/ --releasever=/ --config /etc/dnf/dnf.conf install tar
Config error: [Errno 13] Permission denied: '/home/d/.local/mnt/0/var': '/home/d/.local/mnt/0/var'
d@develop:~$
@0o0O0o0O0o #19 用 podman 比 docker rootless 更好,主要有以下 2 点

1 ,podman 的安装比 docker rootless 更方便,一条 dnf 命令搞定
2 ,docker 貌似没有类似 podman 的 unshare 子命令,用 docker 的话我就必须再依赖一个 fedora 的 container , 还要做个目录共享,例如:

docker run --name fedora4 -itd -p 2223:22 -v /home/d/.local/mnt/0/:/mnt/0 fedora:latest

然后用如下命令来实现:

docker exec -it fedora4 dnf --installroot=/mnt/0/ --releasever=/ --setopt=reposdir=/etc/yum.repos.d/ --setopt=cachedir=/var/cache/dnf --config /etc/dnf/dnf.conf install tar


如果用 bwrap 也能做到类似 podman unshare 的效果的话我也很乐意尝试一下,但暂时不打算研究了。
@yanqiyu 你的这种方法完美解决了我的问题:

podman unshare dnf --installroot=/home/d/.local/mnt/0/ --releasever=/ --config /etc/dnf/dnf.conf install tar
@sduoduo233 这个不提供 x86_64 架构下的安装包,而且我比较倾向于用 fedora 官方支持的工具来实现。
@0o0O0o0O0o fakeroot 的不是基于命名空间技术实现的,虽然可以用这个命令来骗过 dnf 命令, 让 dnf 命令不报那个需要特权用户的错,但执行到一半还是会报错:

d@develop:~$ fakeroot dnf --installroot=/home/d/.local/mnt/0 --releasever=/ --config /etc/dnf/dnf.conf install tcpdump
Last metadata expiration check: 0:04:10 ago on Sun 30 Jun 2024 02:58:04 PM CST.
Dependencies resolved.
===================================================================================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================================================================================
Installing:
tcpdump x86_64 14:4.99.4-6.fc40 fedora 501 k

Transaction Summary
===================================================================================================================================================================================================================
Install 1 Package

Total size: 501 k
Installed size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
[SKIPPED] tcpdump-4.99.4-6.fc40.x86_64.rpm: Already downloaded
Running transaction check
Transaction check succeeded.
Running transaction test
RPM: error: Unable to change root directory: Operation not permitted
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction test error:
Errors occurred during test transaction.

d@develop:~$
@dhb233 不行的,因为我是用

fuse2fs -o fakeroot ~/fedora.raw /path/to/fedora_rootfs

这种方式来挂载虚拟机的磁盘镜像的,这种方式就只能用普通用户来读写挂载目录的文件,用 root 用户反而没有读写的权限(所以用 sudo 肯定也不行)。

我觉得用基于命名空间的 root 用户是可以读写的,因为我把/path/to/fedora_rootfs 目录共享给 docker ,在 docker 内能用 root 用户读写这个目录,docker 的 root 用户就是通过命名空间技术映射到 host 的普通用户的。
@xscit 能具体一些吗?我就是想当伸手党才来问的,哈哈
@cccer 不是的,我用的 docker 是完全不需要 root 权限的:

https://docs.docker.com/engine/security/rootless/

docker 服务都是用普通用户来运行的:

d@develop:~$ systemctl --user start docker
d@develop:~$ systemctl --user status docker
● docker.service - Docker Application Container Engine (Rootless)
Loaded: loaded (/home/d/.config/systemd/user/docker.service; enabled; preset: disabled)
Drop-In: /usr/lib/systemd/user/service.d
└─10-timeout-abort.conf
Active: active (running) since Sat 2024-06-29 18:44:10 CST; 19h ago
Docs: https://docs.docker.com/go/rootless/
Main PID: 5727 (rootlesskit)
Tasks: 170
Memory: 912.4M (peak: 1006.0M)
CPU: 1min 17.179s
CGroup: /user.slice/user-1000.slice/[email protected]/app.slice/docker.service
@Features 有道理,但是人和电脑还是有区别,电脑是可以随便压榨的(只要别超频),但人压榨的太狠还是会反抗的。
@julyclyde 是的,所以我打算以后都用 lvm 了,昨天就遇到个 lvm 的问题,今天发帖问了一下,刚刚有位老哥帮我解决了:

https://v2ex.com/t/1052008

希望你以后能多给其他人提供有价值的回答。
1  2  3  4  5  6  7  8  9  10 ... 24  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1172 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms · UTC 18:27 · PVG 02:27 · LAX 10:27 · JFK 13:27
Developed with CodeLauncher
♥ Do have faith in what you're doing.