我有一个带有 Arch Linux 和 Kodi 的 Raspberry Pi。我尝试通过Systemd的新方式进行所有配置,即通过创建Systemd单元。例如,不要在启动时使用以下命令配置挂载点/etc/fstab文件,我是按单位做的.mount
。
我使用 Udisks2 和 Polkit 进行了自动挂载配置。
当我不拔下硬盘并命令系统重新启动时,我看到硬盘已安装在以下新目录中/媒体每次启动后。例如,假设在重新启动之前,HDD 已安装在/媒体/无标题。重新启动后,它将(自动)安装在/媒体/无题1。下次下一次/媒体/无题2等等。我希望它始终安装在/媒体/无标题。
也许,解决方案是这里,但我不知道。
编辑:我有以下安装单位(在/etc/systemd/系统目录):
引导安装单元(启动挂载):
# boot.mount
[Unit]
Description=Boot partition
[Mount]
What=/dev/disk/by-uuid/<BOOT_PART_UUID>
Where=/boot
Type=vfat
Options=defaults
[Install]
WantedBy=multi-user.target
根 (/) 安装单元 (-。山):
# -.mount
[Unit]
Description=Root partition
[Mount]
What=/dev/disk/by-uuid/<ROOT_PART_UUID>
Where=/
Type=ext4
Options=noauto,x-systemd.automount
[Install]
WantedBy=multi-user.target
家用安装装置(主页挂载):
# home.mount
[Unit]
Description=Home partition
[Mount]
What=/dev/disk/by-uuid/<HOME_PART_UUID>
Where=/home
Type=ext4
Options=noauto,x-systemd.automount
[Install]
WantedBy=multi-user.target
Polkit 规则是(根据/etc/polkit-1/rules.d目录):
50-udisks.规则
// 50-udisks.rules
polkit.addRule(function(action, subject) {
var YES = polkit.Result.YES;
var permission = {
//// only required for udisks1:
//"org.freedesktop.udisks.filesystem-mount": YES,
//"org.freedesktop.udisks.filesystem-mount-system-internal": YES,
//"org.freedesktop.udisks.luks-unlock": YES,
//"org.freedesktop.udisks.drive-eject": YES,
//"org.freedesktop.udisks.drive-detach": YES,
// only required for udisks2:
"org.freedesktop.udisks2.filesystem-mount": YES,
"org.freedesktop.udisks2.filesystem-mount-system": YES,
"org.freedesktop.udisks2.encrypted-unlock": YES,
"org.freedesktop.udisks2.eject-media": YES,
"org.freedesktop.udisks2.power-off-drive": YES,
// required for udisks2 if using udiskie from another seat (e.g. systemd):
"org.freedesktop.udisks2.filesystem-mount-other-seat": YES,
"org.freedesktop.udisks2.encrypted-unlock-other-seat": YES,
"org.freedesktop.udisks2.eject-media-other-seat": YES,
"org.freedesktop.udisks2.power-off-drive-other-seat": YES
};
if (subject.isInGroup("storage")) {
return permission[action.id];
}
});
(我使用的是 Udisks2。)
48-shutdown-power-group.rules 关闭电源组规则
// 48-shutdown-power-group.rules
polkit.addRule(function(action, subject) {
if ((action.id == "org.freedesktop.login1.reboot" ||
action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
action.id == "org.freedesktop.login1.power-off" ||
action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
action.id == "org.freedesktop.login1.suspend" ||
action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
action.id == "org.freedesktop.login1.hibernate" ||
action.id == "org.freedesktop.login1.hibernate-multiple-sessions") && subject.isInGroup("power"))
{
return polkit.Result.YES;
}
});
udev 规则(下/etc/udev/rules.d目录):
99-udiks2.规则
# 99-udisks2.rules
# UDISKS_FILESYSTEM_SHARED
# ==1: mount filesystem to a shared directory (/media/VolumeName)
# ==0: mount filesystem to a private directory (/run/media/$USER/VolumeName)
# See udisks(8)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"