Linux Unmount all external hard drives via Script/Menu Button within Kodi?
#1
Question 
At the moment I have five or six external drives connected at once. To unmount the drives without shutting down the system I have to go to:

FileManager - Name of Drive - Context Menu - Remove Safely

This has to be repeated for each drive.

Is it possible to unmount all external hard drives via a Script which I can then map to Menu Button using RunScript(path.to.script)?Huh
Reply
#2
udisks --unmount /dev/sdXY
Reply
#3
(2015-06-02, 14:57)wsnipex Wrote: udisks --unmount /dev/sdXY

Created a Python Script called Unmount.py contents of which are:

udisks --unmount /dev/sdXY

Then I tried to run the following, RunScript("/home/creemyv/Unmount.py") but it didn't work

Also tried this in case it was what you meant

RunScript(udisks --unmount /dev/sdXY)
RunScript("udisks --unmount /dev/sdXY")
Reply
#4
I've tried with this python script and it succeeded:
PHP Code:
from subprocess import call
import os
for media_pathmounted_drives_filenames in os.walk('/media'):
    for 
mounted_drive in mounted_drives:
        
call(["sudo""umount""%s/%s"%(media_path,mounted_drive)])
    
#don't walk into subfolders
    
break 
Reply
#5
this needs special sudo rights.


@OP: you must replace /dev/sdXY with your actual device name, e.g. /dev/sdb1
Reply
#6
Default osmc installation grants sudo permission to osmc user.
Anycase, if you want to unmount ALL devices dynamically with your command, change call statement of my previous script:

call(["udisks", "--unmount", "%s/%s"%(media_path,mounted_drive)])
Reply
#7
the OP didn't say anything about osmc. Any normal linux will ask for a password when using sudo, so this will fail when running from a script.
Reply

Logout Mark Read Team Forum Stats Members Help
Unmount all external hard drives via Script/Menu Button within Kodi?0