Connecting to NFS shares at boot using fstab in Debian 9 Stretch

Note – this fix in principle should work on most systemd distributions.

Problem – trying to get a Debian 9 system to mount an NFS share at boot. This was declared in /etc/fstab in the normal way, but kept failing on boot. However, once the system was up you could log in and do a mount -a, which would work fine. Reading around, it looks like a case of the system trying to mount before the network is up (and in this case the network should be reliable, as it’s an internal one between a VM and it’s host…)

Tried using the bg option first, which should mount in the background and come up eventually, but still got error on boot.

192.168.45.1:/export  /hostshare  nfs  bg,rw,soft  0   0

There is another option that in theory should help: _netdev. I haven’t tried this yet.

What does work is adding an option x-systemd.automount. This, unsurprisingly, tells systemd to try and mount the share on demand. So changing the line in fstab to read:

192.168.45.1:/export  /hostshare  nfs  rw,soft,x-systemd.automount  0   0

works. Booting the system gives no errors (on the console anyway). The share does not show as mounted until the local mountpoint is accessed, and then it works without complaint.

Footnotes

  1. The context for this is a VM running under VirtualBox. The VM is Debian 9, the host is Ubuntu 17.10. The VM has one network interface with the default NAT setup to talk to the outside world, and a second interface to talk to a host-only network. This allows you to SSH into the the guest from the host, and also allows this NFS setup. You can use the VirtualBox shared folder setup to transfer files, but I figured as both the host and guest were Linux NFS would be easier (and not require the Guest Extensions to be installed on the guest).
  2. Debian 9 wouldn’t successfully install on the laptop, but I needed it for an easy install of LALSuite (Debian is a reference system for this, Ubuntu isn’t and has dependency issues). Hence this rather complicated setup. Fortunately LALSuite is entirely command line based…
  3. Yes, Docker or similar would be more efficient. I’m not so familiar with it and it’s a bit of a pain to get it talking to the host filesystem. I’d argue that running a full VM is slightly more portable, although you’d need to change how the filesharing is set up on a Windows or Mac host.

Proxmox clustering and multicast (also, DNS)

After much problems with getting a new Proxmox cluster up and running two things have helped:

Putting the SAN IP addresses in the hosts file, avoiding DNS dependancies (especially when one of the systems isn’t in there yet…). This put me on track: http://blog.rhavenindustrys.com/2013/04/curious-proxmox-clustering-fix.html

Important bit:

127.0.0.1 localhost.localdomain localhost
169.254.0.1 proxmox1.local proxmox1 pvelocalhost
169.254.0.2 proxmox2.local proxmox2

10.10.5.101 proxmox1.example.com
10.10.5.102 proxmox2.example.com

This associates the short aliases with the network used by corosync, while leaving the long addresses to the outside world.

Then tried tests detailed at: https://pve.proxmox.com/wiki/Troubleshooting_multicast,_quorum_and_cluster_issues

The multicast test failed – i.e. running

omping -c 10000 -i 0.001 -F -q <list of all nodes>

on both nodes at the same time resulted in 100% loss. Fixed this by disabling IGMP snooping on the SAN VLAN. ExtremeOS command is:

disable igmp snooping <vlanname>

Hey presto, after getting the second node to join properly:

pvecm add 192.168.xxx.xxx -force

it gets quorum immediately. I suspect this issue was causing a lot of the historical issues with getting quorum to work on this switch.

updatedb.mlocate hangs on stale NFS mounts (Proxmox)

After properly configuring postfix on the Proxmox hosts to send email, emails to root were noticed daily:

/etc/cron.daily/mlocate:
 /usr/bin/updatedb.mlocate: `/var/lib/mlocate/mlocate.db' is locked (probably by an earlier updatedb)
 run-parts: /etc/cron.daily/mlocate exited with return code 1

After logging on to one of the boxes, killing (-9) the updatedb process and running it with verbose on:

updatedb.mlocate -v

The output indicated it was hanging on one of the ”/mnt” directories. Looking at the output of ”mount” a couple of old nfs shares were noticed, that should have been deleted (and didn’t appear in the GUI). Unmounting these shares made updatedb run happily.

If the unmount complains the device is busy, check the updatedb.mlocate process has been killed.

Configuring Proxmox hosts (and other postfix installs) to send email via smarthost

Proxmox uses postfix as its MTA. To configure this to send email via smarthost run

dpkg-reconfigure postfix

For general type we want Satellite

SMTP server - usual

Mailbox size – could use the suggested 51200000 here – should be more than big enough seeing as nothing should be ending up in the system mailbox anyway.

Once this is done, edit ”/etc/aliases”. It should look like:

postmaster: root
nobody: root
hostmaster: root
webmaster: root
www: root

Add a line at the end:

root: Your.Email@example.com

Regenerate the database with ”newaliases” (or possibly ”postalias filename” on other distributions)

Test with something like

echo "test" | mail -s "test mail sent to root" root

Windows Server 2003 (and XP) logon screen power config to allow reliable ACPI shutdown

It can sometimes be difficult to get Windows systems to shut down reliably using an ACPI signal (either the power button for a physical system, or an equivalent signal from a virtual machine hypervisor). Generally you find after the system has been on for a period of time, the first ACPI signal merely wakes up the screen. On a physical system this makes some sense – it shows you the system is in fact on already. To turn a physical system off you just press the power button again. For a virtual system this is not convenient, especially when you want the system to shut down cleanly when the host system is going down. The trick is to keep everything, particularly the screen, alive so that the first ACPI signal does actually initiate shutdown.

Power scheme configuration

Server 2003 and XP can do odd things with the standard power schemes. The most reliable way to make a power scheme stick appears to be to create a custom one. The registry files here create a new power scheme that really does leave the monitor on permanently.

For the current user:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\PowerCfg\PowerPolicies\6]
"Policies"=hex:01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,32,32,00,00,04,00,00,00,04,00,\
  00,00,00,00,3d,77,2e,f2,07,00,00,00,00,00,84,03,00,00,00,00,00,00,08,07,00,\
  00,00,00,64,64,64,64,91,7c
"Name"="Really always on"
"Description"="Non-standard power scheme that keeps the monitor on to allow reliable ACPI shutdowns"

For the default user (i.e. the one system uses at the logon screen):

Windows Registry Editor Version 5.00

[HKEY_USERS\.DEFAULT\Control Panel\PowerCfg\PowerPolicies\6]
"Policies"=hex:01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,32,32,00,00,04,00,00,00,04,00,\
  00,00,00,00,3d,77,2e,f2,07,00,00,00,00,00,84,03,00,00,00,00,00,00,08,07,00,\
  00,00,00,64,64,64,64,91,7c
"Name"="Really always on"
"Description"="Non-standard power scheme that keeps the monitor on to allow reliable ACPI shutdowns"

Save these as .reg files and merge them in as necessary.

Compare these policies to the “always on” policy – there are some differences in the data. It seems that quite often the standard policies get overwritten by something, possibly the global policy. Note that these policies have timeouts associated with the DC (i.e. battery) power profile, but this isn’t relevant for virtual servers (might want to think about this for physical systems on a UPS). Use ”powercfg -query” to see the power plan details.

Go to ”[HKEY_USERS\.DEFAULT\Control Panel\PowerCfg]” and set the ”CurrentPowerPolicy” value to ”6”.

Screen saver configuration

The screen saver also seems to interfere with things. To turn it off go to ”[HKEY_USERS\.DEFAULT\Control Panel\Desktop]” and set the ”ScreenSaveActive” value to ”0”.

Group Policy configuration

Remember to check that you can shut down the system without being logged on, as per Windows Server 2003 shutdown Group Policy