Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eject without requiring password #28

Open
dhjelmar opened this issue Apr 20, 2024 · 0 comments
Open

eject without requiring password #28

dhjelmar opened this issue Apr 20, 2024 · 0 comments

Comments

@dhjelmar
Copy link

Requested Capability

An option to eject any auto-mounted flashdrive without requiring a password would be helpful. Possibly there's a configuration file I could add to /etc/media-automount.d? It isn't clear to me though how to do that.

Supporting Detail

A password is required to eject using udev-media-automount. I am running PeppermintOS and successfully auto-mounted an exfat formatted flash drive.

No password is required to unmount and eject if I mount the same exfat drive using the following:

mount () { 
    # Usage example: mount sda1
    udisksctl mount --block-device /dev/$1
}

The same behavior is observed (i.e., requiring a password to unmount if mounted with automount, and not requiring a password to unmount if mounted with the above function) regardless of whether I use a file manager or the following command to eject:

unmount(){
    # Function that unmounts, if needed, then powers off a USB drive
    # Usage example: unmount sda1

    # # original simple unmount and power off function
    # udisksctl unmount -b /dev/$1 && udisksctl power-off -b /dev/$1

    disk=`lsblk | grep $1`                    # find target disk
    mounted="$(echo $disk | cut -d' ' -f7)"   # parse to find mountpoint (6th column)
    echo "disk = " $disk
    echo "mounted = " $mounted
    if [ -z "$mounted" ]
    then
        # $var is empty so just power off drive
	echo "Power off drive $1"
	udisksctl power-off -b /dev/$1
    else
        # $var is not empty so unmount and power off drive
	echo "Unmount and power off drive $1"
        udisksctl unmount -b /dev/$1 && udisksctl power-off -b /dev/$1
    fi
}

Aside

Your utility has been really helpful. I had been using the above commands to mount and unmount/eject, but I had not yet figured out how to mount a Yubikey. I found your script while researching udev rules, and it worked great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant