20.3. 锁定重新分区
polkit 可让您为单个操作设置权限。对于磁盘管理服务工具 udisks2,配置位于 /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy。此文件包含一组操作和默认值,它们可被系统管理员覆盖。
重要
存储在 /etc 中的 polkit 配置会覆盖 /usr/share/ 中软件包所提供的配置。
流程
创建一个与
/usr/share/polkit-1/actions/org.freedesktop.udisks2.policy中内容相同的文件:cp /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy /etc/share/polkit-1/actions/org.freedesktop.udisks2.policy
cp /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy /etc/share/polkit-1/actions/org.freedesktop.udisks2.policyCopy to Clipboard Copied! Toggle word wrap Toggle overflow 不要更改
/usr/share/polkit-1/actions/org.freedesktop.udisks2.policy文件,您的更改会被下一次软件包更新所覆盖。删除您不需要的操作,并将以下行添加到
/etc/polkit-1/actions/org.freedesktop.udisks2.policy文件中:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 如果要确保只有
root用户才能执行此操作,请用auth_admin替换no。- 保存更改。
当用户尝试更改磁盘设置时,会返回以下信息:
Authentication is required to modify the disks settings.
Authentication is required to modify the disks settings.