systemd를 사용한 와일드카드 자동 마운트

systemd를 사용한 와일드카드 자동 마운트

저는 systemd 208로 jessie/sid를 실행 중이며 다음 와일드카드 autofs 구성을 또는 /etc/fstab/ .mount정의 .automount로 변환하려고 합니다.

$ cat /etc/auto.master
/home/* -fstype=nfs homeserver:/exp/home/&

/exp/home/(홈서버는 각 하위 디렉토리를 별도의 공유 로 사용하여 Solaris를 실행합니다 .)

systemd로 와일드카드 맵을 에뮬레이트하는 방법이 있습니까?

답변1

나는 아니라고 생각합니다. .mount/.automount 장치 이름은 로 이스케이프된 마운트 경로와 동일해야 합니다 systemd-escape --path. 그리고 systemd에서 단위를 인스턴스화하는 유일한 방법은 형식의 "템플릿 구문"입니다 [email protected]. 따라서 동적으로 인스턴스화된 마운트 장치를 갖는 것은 적어도 불가능합니다.

그냥 autofs를 사용하세요. systemd가 모든 것을 대체하는 것은 아닙니다.

답변2

systemd를 사용할 수 있습니다발전기 인터페이스. 기본적으로 시작 또는 다시 로드 시 즉시 서비스 파일을 생성합니다.

우리 클러스터에는 모두 동일한 디렉터리(물리적 디스크)를 내보내는 다양한 머신("dema"와 일부 숫자라고 함)이 있습니다. 생성기 인터페이스를 사용하여 하나를 만들었습니다..산그리고 하나.automount각 머신에 대한 파일:

#!/bin/sh

svc_dir=/run/systemd/generator

for i in $(seq 1 99); do
    # this must match the mount path, / is converted to -
    unit_bn=cluster-dema$i
    cat << EOF > "${svc_dir}/${unit_bn}.automount"
[Unit]
Description=dema${i}s localdisks automount point
Documentation=file:///usr/lib/systemd/system-generators/dema-automount-generator
Before=remote-fs.target

[Automount]
Where=/cluster/dema$i
EOF

    cat << EOF > "${svc_dir}/${unit_bn}.mount"
[Unit]
Description=dema${i}s localdisks
Documentation=file:///usr/lib/systemd/system-generators/dema-automount-generator

[Mount]
What=dema$i:/localdisks
Where=/cluster/dema$i
Type=nfs
Options=rw,nosuid,nodev,hard,intr,rsize=8192,wsize=8192,noauto,x-systemd.automount
EOF
    ln -s "../${unit_bn}.automount" "${svc_dir}/remote-fs.target.requires"
done

스크립트는 다음 위치에 배치되어야 합니다./usr/lib/systemd/system-generators실행 가능합니다. 거기에 넣어둔 후 전화주세요systemd 데몬 다시 로드그리고 당신은 단위를 찾아야합니다/run/systemd/발전기. 다음 재부팅 시 활성화되며 물론 다음을 호출하여 수동으로 시작할 수도 있습니다.systemd는 oneofthenames.automount를 시작합니다..

관련 정보