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?

3
  • 1
    Seems like a common bug. Is it still shutting down successfully afterwards?
    – jesse_b
    Commented Jul 15, 2017 at 15:30
  • It does appear to shutdown after the error is displayed.
    – Village
    Commented Jul 15, 2017 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
    Commented Jul 15, 2017 at 21:59

2 Answers 2

13

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"

5
  • 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. Commented May 25, 2018 at 3:11
  • Indeed: bbs.archlinux.org/viewtopic.php?pid=1204644#p1204644 Commented May 25, 2018 at 3:22
  • 2
    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é
    Commented Nov 29, 2018 at 10:41
  • mkinitcpio is specific to Arch, so your option 2) needs to be implemented in some other way in Debian.
    – telcoM
    Commented Dec 26, 2020 at 22:48
  • @telcoM Okay thanks. I don't use Arch anymore, but I've updated the answer. Commented Dec 30, 2020 at 21:10
1

I would like to thank @Thibault Lemaire for pointing me to the right cause. I successfully resolved the error by applying these changes to systemd-journald.service:

...
[Unit]
...
After:umount.target
Conflicts=umount.target

Basically all(?) mounts (including /var) will be unmounted by umount.target, so if we stop systemd-journald before starting umount.target we can fix the error.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .