今天升级到 12.04 期间,我在运行包的安装后挂钩时遇到错误resolvconf
:
Setting up resolvconf (1.63ubuntu11) ...
resolvconf.postinst: Error: Cannot replace the current /etc/resolv.conf with a symbolic link because it is immutable. To correct this problem, gain root privileges in a terminal and run 'chattr -i /etc/resolv.conf' and then 'dpkg --configure resolvconf'. Aborting.
好吧,我确实尝试运行chattr -i /etc/resolv.conf
,但dpkg --configure resolvconf
产生了同样的错误。
我尝试手动移动或删除该文件,但即使以 root 身份也无法执行此操作:
sudo mv /etc/resolv.conf /etc/resolv.conf.old
mv: cannot move `/etc/resolv.conf' to `/etc/resolv.conf.old': Operation not permitted
sudo rm /etc/resolv.conf
rm: cannot remove `/etc/resolv.conf': Operation not permitted
我能够(以 root 身份)在 /etc 中创建然后删除文件,因此 root 分区不会以只读方式挂载。另外:
lsattr /etc/resolv.conf
-----a--------- /etc/resolv.conf
答案1
就我的情况而言,是文件的不可变属性导致了这种情况。所以sudo chattr -a -i /etc/resolv.conf
答案2
根据帮助文件(man chattr
),
A file with the `a' attribute set can only be open in append mode for writing.
在你的情况下,文件具有此属性
The operator `+' causes the selected attributes to be added to the
existing attributes of the files; `-' causes them to be removed;
因此要尝试的命令是
sudo chattr -a /etc/resolv.conf
并尝试再次使用列出属性
lsattr /etc/resolv.conf
然后尝试删除该文件