13

I have a fresh install of Debian 9.0.0. It has a separate 1 GB partition for /var formatted at ext4. When I shutdown from the terminal, using shutdown -h now, there is a bright-red error message stating "failed unmounting /var".

What is the fix for this error?

Village
  • 4,655
  • 14
  • 46
  • 80
  • 1
    Seems like a common bug. Is it still shutting down successfully afterwards? – jesse_b Jul 15 '17 at 15:30
  • It does appear to shutdown after the error is displayed. – Village Jul 15 '17 at 16:44
  • 1
    When I googled it I found a few Ubuntu and Kali users experiencing the same issue and many people were chiming in that they saw the same thing but it didn't seem to affect anything. – jesse_b Jul 15 '17 at 21:59

1 Answers1

12

The problem is journald

Or rather how it is still logging to /var while systemd is trying to unmount it.

Solutions

According to this thread, there are two ways to go about it:

  1. Make journald log to a volatile location in /run so it doesn't lock /var, but the tradeoff is that you lose logs at shutdown.

Edit /etc/systemd/journald.conf to change the Storage= line to

Storage=volatile

This is what I did, and I it worked for me.

  1. (EDIT: this is ArchLinux-specific) Or set up a shutdown hook to unmount /var later. This won't remove the failed message as systemd will still try to unmount /var but will indeed unmount /var properly at the end of the shutdown sequence. You just won't see it. (I haven't tested that solution though)

Add a shutdown hook to mkinitcpio's HOOKS= array, e.g. :

HOOKS="base udev autodetect block keymap encrypt lvm2 filesystems usbinput fsck var shutdown"

Thibault Lemaire
  • 301
  • 3
  • 11
  • 1
    I have two laptops with Ubuntu (one with a single HDD and one with HDD+SSD) and I got that annoying error message only on the second. In the second laptop, `/var` is in a different partition from `/` (`/` is in the SSD and `/var` is in the HDD) and, in the first laptop, `/var` is within `/`. This might play a role in the problem. – Marcelo Ventura May 25 '18 at 03:11
  • Indeed: https://bbs.archlinux.org/viewtopic.php?pid=1204644#p1204644 – Marcelo Ventura May 25 '18 at 03:22
  • 1
    A variant of topic (1) is to leave `Storage=auto` in journald.conf and just remove /var/log/journal. This worked for me, too, and journald logs are done to /run/log/journal/, instead. See `man journald.conf`. – René Nov 29 '18 at 10:41
  • `mkinitcpio` is specific to Arch, so your option 2) needs to be implemented in some other way in Debian. – telcoM Dec 26 '20 at 22:48
  • @telcoM Okay thanks. I don't use Arch anymore, but I've updated the answer. – Thibault Lemaire Dec 30 '20 at 21:10