Commit 58a03627 authored by David Johnson's avatar David Johnson
Browse files

Make our systemd fstab-generator work with (bad?) systemds.

It seems that some systemds (i.e. 219) cannot handle by-uuid unitfile
names (although they are happy to print them out via systemctl
list-units).  So, in one place in the fstab-generator, just use the raw
device naming convention.  systemd doesn't care what we use.  From the
comments:

  Ok, don't use the by-uuid method (dev-disk-by\\x2duuid-${transuuid}.swap).
  It seems to me that the vintage of systemd on Centos7
  (i.e. 219) doesn't correctly process dev-by-uuid filenames nor
  unitnames (even systemctl status <blah>, where <blah> is a
  by-uuid unit name reported by systemctl list-units, does not
  work!).  systemd 229 on Ubuntu seems happy to use the by-uuid
  unitfilename we generated above.

(Perhaps I should have done this in all places in this script, but I
didn't for now :(.  I believe my by-uuid encoding is correct, and I
really don't want to rock a mostly-working boat.  This fix is enough for
all the cases we have, I hope.)
parent 095f2ce1
......@@ -276,8 +276,22 @@ if [ $haveemulabswap -eq 0 -a -n "$emulabswapdev" ]; then
if [ -z "$uuid" ]; then
logit "Failed to mkswap default Emulab swap partition $emulabswapdev !"
else
transuuid=`echo "$uuid" | sed -e 's/\(-\)/\\\\x2d/g'`
unitfilename="dev-disk-by\\x2duuid-${transuuid}.swap"
#transuuid=`echo "$uuid" | sed -e 's/\(-\)/\\\\x2d/g'`
#unitfilename="dev-disk-by\\x2duuid-${transuuid}.swap"
#
# Ok, don't use the by-uuid method (dev-disk-by\\x2duuid-${transuuid}.swap).
# It seems to me that the vintage of systemd on Centos7
# (i.e. 219) doesn't correctly process dev-by-uuid filenames nor
# unitnames (even systemctl status <blah>, where <blah> is a
# by-uuid unit name reported by systemctl list-units, does not
# work!). systemd 229 on Ubuntu seems happy to use the by-uuid
# unitfilename we generated above.
#
# But it is possible and easier to just use the raw device
# unitfilename in our case, so do that.
#
unitfilename=`echo $emulabswapdev | sed -e 's/^\///g' | sed -e 's/\//-/g'`
unitfilename="${unitfilename}.swap"
cat <<EOF > $1/$unitfilename
# Automatically generated by Emulab systemd-fstab-generator wrapper
......@@ -287,7 +301,7 @@ SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
[Swap]
What=/dev/disk/by-uuid/$uuid
What=$emulabswapdev
EOF
mkdir -p $1/swap.target.requires
ln -s $1/$unitfilename $1/swap.target.requires/$unitfilename
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment