OSMC not properly unmounting disks at reboot/shutdown [SOLVED - false issue]

This post was flagged by the community and is temporarily hidden.

OSMC uses systemd. Are there any systemd services which aren’t firing properly? If you mount your external hard disk and it’s always connected, you should do this in /etc/fstab, then OSMC will handle mounting and unmounting for you.



It’s highly unlikely that the file system is not being unmounted without your knowledge. If there are any delays during shutdown systemd will display a warning on the screen saying something like “Waiting for service x to stop” with a counting timer. Do you see anything like this ? If so can you take a screen shot ?

If you don’t see anything on the screen how have you determined that the shutdown sequence is not unmounting file systems ?

If you pull the power before the shutdown has finished then yes, it may cause corruption.

For what I understand from systemd, the configured modules are defined in /etc/systemd/system.
I can also “sudo systemctl --all” to list all services.
From here I’ve noticed that both reboot.target.wants and halt.target.wants only have hwclock-save.service defined.
There is no service active for file systems umount.
Not even rootfs !!!

Could you please validate ?
(if I’m correct this is a cause of major file systems corruption after some reboots !!!)

Thank you very muych
kindest regards

I don’t think you understand how systemd works.

All system supplied services are located in /lib/systemd/system, /etc/systemd/system is for user (sysadmin) created services.

Also all services are automatically shut down in the reverse order that they started during boot - there is no need to explicitly define this. System shutdown is handled by the systemd-halt.service:


Some logs including the system journal taken after a clean reboot may show something, as the fsck that runs during boot will be logged in the system journal.

Thank you for your note.
I may have not explained it correctly as I’m not a proficient English writer, but I do understand systemd.
But what is really worrying me is the fact that external hdd are not being unmounted in poweroff/reboot.
I know I can edit fstab. (I opted to create a simple unit to umount /media/*)

But May I leave a suggestion ?

Looking into the fantastic interface OSMC is delivering, targeting less “tech-aware” users, it would be great to have a automatic unmount of external mounted hdd’s without having to go into linux command line :wink:

Thanks and keep up the fantastic work :slight_smile:
I’ve already recommended OSMC for 2 other friends)

Kindest Regards

This is what you are claiming, but you have not provided a single piece of evidence to support this, not even a log file showing an unclean shutdown or fsck running and fixing errors on boot. You haven’t even explained how it is you think that the drive is not being unmounted ? I don’t understand what you’re basing your claim of filesystems not being unmounted on shutdown on.

Nobody has to go to the command line to unmount drives in OSMC. I can assure you most definitely that all file systems are unmounted correctly on reboot/shutdown - including external drives. If this were not the case we would have heard a lot more reports about this. But so far you’re the only person I can remember claiming external drives are not unmounted on reboot/shutdown.

So to go any further, please provide some proof such as log files that demonstrate filesystems not being unmounted correctly on a normal shutdown, because I find it a bit hard to believe.

very well. Which log file do you request ?

And please don’t take me wrong.
I didn’t want to be disrespectful.
I really believe OSMC is awesome.
(I’m just worried with this issue)


Let’s start with

What leads you to believe that your filesystem isn’t being unmounted on shutdown?

How have you mounted your filesystem? Fstab is acceptable and recommended for permanent mounts, but we also auto mount new media

Command line access is not required for the proper use of external drives nor is it recommended

I use a maxtor 500GB USB2 2.5" harddisk.
1 partition in a ext2 file system.

Usually it is connected to the Pi
It is properly mounted at start.
It doesn’t seem to be properly unmounted at shutdown / reboot.

Why do think that ?

A lot of file corruption in just some usages.
When I fsck it complains that the disk was not properly unmounted previously.

= I’ve made a small test:

  1. formatted the disk, now with a ext4 partition.
  2. pointed transmission do download some files to it.
  3. made 5 or 6 reboots using OSMC interface.
  4. went into ssh, manually unomunted the disk (umount /media/hdd).
  5. redone fsck.
  6. got a lot of errors.
  7. answered “y” to every question.
  8. in the end I’ve lost almost every file :frowning:

= another test

  1. reformatted the disk
  2. created a small unit to be called before reboot.target
    3 the unit does a “umount -v /media/hdd >> /var/log/test.log 2>&1”
    4 this unit is always logging that the disk was unmounted - meaning it was not yet unmounted when the unit was called (is it expected to be only unmounted by OSMC after this ?)

is there an additional test you want me to do ?
any particular log ?

thank you very much for your help on this.

Ive rewrote the unit clean-umount.sevice to be like this:

Description=Clean umount service

ExecStart=/bin/sh -c "LOG=/var/log/clean-umount.log ; date >> $LOG; sync;  umount -vr /media/* >> $LOG 2>&1; return 0"


installed with:
sudo systemctl enable clean-umount.service
It is working with shutdown and halt, which can be confirmed by the log file.

But also noticed that:
sudo systemctl list-dependencies umount.target
Does only return clean-umount.service as the only dependent unit.

I’m not sure if this matters, and i’m sorry if I’m raised some false problem, but shouldn’t a umount service be declared here by default to automatically umounts extenral media ?

(I’m sure I’m missing something here, And I’m sorry to make you lose your time. I just want to be sure that any external ~USB disk that may be connected to my OSMC powered Raspeberry is properly unmounted and shutdown/reboot.)

Thank you very much for transforming our Raspberry PIs in the most fantastic media centers :slight_smile:

Recently I decided to do a clean install of OSMC in my Pi3.
Used an official power supply and 3 usb hdd with different FS - namely FAT, NTFS and EXT4.

booted, powered off and rebooted all 3 hdd several times.
Then connected them to my ubuntu machine and runned fsck on all of them.
Oddly, no corruption whatsoever !!!

So, I confirm that everything is ok with OSMC standard unmounting every fs.

But then, what happened that I had so many issues in the past ?
After some thinking, I remember the difference: At the beginning I did not used a standard power supply: And the rainbow square was always blinking when accessing my maxtor 2.5" external hdd.

So went over the old power supply and connected it again to my pi3 together with that hdd.
With some attention I can perfectly ear the hdd noises of disconnect / spin down / spin up - and the obvious subsequent fs corruption after awhile.

Back to the standard pi power supply: no issue whatsoever !

For this I can only suggest: always use a standard pi3 power supply !!

But far mote important: there is no issue with OSMC at the disk unmounting level.

I’m truly sorry for any inconvenience I may have created by raising a false issue.

Keep up the fantastic work, guys :slight_smile:

[issue should be closed]


[Running OSMC + Retropie + Ps3 controller in a Raspberry Pi 3].

Thanks for the confirmation that it was a hardware fault.

We’re pretty confident that the way file system un-mounting on reboot/shutdown is handled is solid (its just standard Debian Jessie there - we don’t do anything special) so couldn’t see how a software issue would have been causing this.