
今天升級到 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
我能夠在 /etc 中建立然後刪除檔案(作為 root),因此 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
然後嘗試刪除該文件