diff --git a/overlays/wwinit/etc/fstab.ww b/overlays/wwinit/etc/fstab.ww index 58fc3767..555d6b89 100644 --- a/overlays/wwinit/etc/fstab.ww +++ b/overlays/wwinit/etc/fstab.ww @@ -7,8 +7,17 @@ devpts /dev/pts devpts gid=5,mode=620 0 0 tmpfs /run/shm tmpfs defaults 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 +{{- if .FileSystems }} +# mounts for local file systems created with ignition in nodes.conf +# all with noauto as mounts happens with systemd units +{{- range $fsdevice,$fs := .FileSystems }} +{{ $fsdevice }} {{ $fs.Path }} {{ $fs.Format }} +{{- if $fs.MountOptions }} noauto{{range $index,$opt := $fs.MountOptions }},{{ $opt }}{{ end }} 0 0 +{{- else }} noauto,defaults 0 0 +{{- end }}{{ end }}{{ end }} {{- $IP:=.Ipaddr }} {{- if .Nfs.Enabled }} +# nfs mounts provided in warewulf.conf {{- range .Nfs.ExportsExtended }} {{- if .Mount }} {{ $IP }}:{{ .Path }} {{ .Path }} nfs {{ .MountOptions }} 0 0 diff --git a/overlays/wwinit/etc/systemd/system/ignition-ww4-mount.service b/overlays/wwinit/etc/systemd/system/ignition-ww4-mount.service deleted file mode 100644 index 35986da7..00000000 --- a/overlays/wwinit/etc/systemd/system/ignition-ww4-mount.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Ignition warewulf (mount) -Documentation=https://hpcng.github.io/warewulf -ConditionPathExists=/warewulf/ignition.json -ConditionPathExists=/usr/lib/dracut/modules.d/30ignition/ignition -DefaultDependencies=false -Before=ignition-complete.target - -After=ignition-ww4-disks.service - - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/lib/dracut/modules.d/30ignition/ignition --platform=metal --stage=mount --config-cache /warewulf/ignition.json -ExecStop=/usr/lib/dracut/modules.d/30ignition/ignition --platform=metal --stage=umount --config-cache /warewulf/ignition.json diff --git a/overlays/wwinit/etc/systemd/system/multi-user.target.wants/ignition-ww4-disks.service b/overlays/wwinit/etc/systemd/system/local-fs.target.wants/ignition-ww4-disks.service similarity index 100% rename from overlays/wwinit/etc/systemd/system/multi-user.target.wants/ignition-ww4-disks.service rename to overlays/wwinit/etc/systemd/system/local-fs.target.wants/ignition-ww4-disks.service diff --git a/overlays/wwinit/etc/systemd/system/local-fs.target.wants/ww4-disks.target b/overlays/wwinit/etc/systemd/system/local-fs.target.wants/ww4-disks.target new file mode 120000 index 00000000..6bebd069 --- /dev/null +++ b/overlays/wwinit/etc/systemd/system/local-fs.target.wants/ww4-disks.target @@ -0,0 +1 @@ +/etc/systemd/system/ww4-disks.target \ No newline at end of file diff --git a/overlays/wwinit/etc/systemd/system/multi-user.target.wants/ignition-ww4-mount.service b/overlays/wwinit/etc/systemd/system/multi-user.target.wants/ignition-ww4-mount.service deleted file mode 120000 index 112c95c9..00000000 --- a/overlays/wwinit/etc/systemd/system/multi-user.target.wants/ignition-ww4-mount.service +++ /dev/null @@ -1 +0,0 @@ -/etc/systemd/system/ignition-ww4-mount.service \ No newline at end of file diff --git a/overlays/wwinit/etc/systemd/system/ww4-disks.target.ww b/overlays/wwinit/etc/systemd/system/ww4-disks.target.ww new file mode 100644 index 00000000..b8e9d429 --- /dev/null +++ b/overlays/wwinit/etc/systemd/system/ww4-disks.target.ww @@ -0,0 +1,20 @@ +# This file is autogenerated by warewulf +# Host: {{.BuildHost}} +# Time: {{.BuildTime}} +# Source: {{.BuildSource}} +[Unit] +Description=mount ww4 disks +# make sure that the disks are available +Requires=ignition-ww4-disks.service +After=ignition-ww4-disks.service +Prequisite=ignition-ww4-disks.service +# Get the mounts +{{- range $fsdevice,$fs := .FileSystems }} +{{- $prefix := $fsdevice }}{{ $suffix := "mount" }} +{{- if eq $fs.Format "swap"}} +{{- $prefix = tr $fsdevice "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-"}}{{ $suffix = "swap"}} +{{- else }} +{{- if $fs.Path }}{{ $prefix = tr $fs.Path "/" "" }}{{ end }} +{{- end }} +Wants={{ print $prefix "." $suffix }} +{{- end }} \ No newline at end of file diff --git a/overlays/wwinit/etc/systemd/system/ww4-mounts.ww b/overlays/wwinit/etc/systemd/system/ww4-mounts.ww new file mode 100644 index 00000000..39a5fb9a --- /dev/null +++ b/overlays/wwinit/etc/systemd/system/ww4-mounts.ww @@ -0,0 +1,38 @@ +{{- $host := .BuildHost }} +{{- $time := .BuildTime }} +{{- $source := .BuildSource }} +{{- range $fsdevice,$fs := .FileSystems }} +{{- $prefix := tr $fs.Path "/" "" }}{{ $suffix:="mount"}} +{{- if $fs.Label }}{{ $prefix = $fs.Label }}{{ end }} +{{- if eq $fs.Format "swap"}}{{ $prefix = tr $fsdevice "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-"}}{{ $suffix = "swap"}}{{ end }} +{{- $filename := print $prefix "." $suffix }} +{{- file $filename }} +# This file is autogenerated by warewulf +# Host: {{ $host }} +# Time: {{ $time }} +# Source: {{ $source }} +{{- if eq $fs.Format "swap"}} +[Unit] +ConditionPathExists=/warewulf/ignition.json +After=ignition-ww4-disks.service +Before=swap.target +[Swap] +What={{ $fsdevice }} +[Install] +RequiredBy=swap.target +{{- else }} +[Unit] +ConditionPathExists=/warewulf/ignition.json +Before=local-fs.target +After=ignition-ww4-disks.service +[Mount] +Where={{ $fs.Path }} +What={{ $fsdevice }} +Type={{ $fs.Format }} +{{- if $fs.MountOptions }} +Options={{range $index,$opt := $fs.MountOptions }}{{if $index }},{{ end }}{{ $opt }}{{ end }} +{{- end }} +[Install] +RequiredBy=local-fs.target +{{- end }} +{{- end }}