You are not logged in.
Pages: 1
I just want to mount hdd and ssd with this line of code:
sudo mount /dev/sda2 /mnt/ssd && sudo mount /dev/sdb1 /mnt/hddand execute within the LXDE run command like "mountdrives" , is it even possible?
Offline
`PATH` is an environment variable with a list of directories, where executables are being searched for. So you need to put your script in one of the directories listed in `$PATH`. This is “/usr/local/bin” for executables to be available to anybody.⁽¹⁾ If an executable is to be available only to your user, you may put it somewhere in yoru home directory and add that directory to `$PATH`. It’s entirely up to you, what directory you choose, but conventionally it’s “~/.local/bin” or whatever directory would be a sibling to `$XDG_DATA_HOME` and `XDG_STATE_HOME`.
That regards script location. But there are other issues with the script itself. I don’t know LXDE, but I assume that “run command” is some GUI tool. And you are trying to run code, that is meant to be executed in a terminal. You’ll not be able to interact with sudo and you use temporary device names, which normally you would type by hand while using a terminal.
So, first things first: device names. Don’t use temporary, unreliable device names. Those are randomly assigned by kernel and may change at any time. Use persistent, reliable names from “/dev/disk/by-*” hierarchy. Preferably “/dev/disk/by-uuid/” entries. Then: you don’t need sudo. Configure the partitions to not require root privileges in fstab.
However, this still leaves one important problem open. You need to explicitly call this script to mount the drives. Why not simply mount with your file manager? It’s not 1990s anymore, you almost never need to invoke `mount` manually or elevate privileges.
____
⁽¹⁾ Unless you make it into a pacman package, in which case it goes to “/usr/bin” or “/usr/local/bin”, depending on your choices. Opinions differ on managing “/usr/local/bin” with pacman.
Last edited by mpan (2024-09-08 18:07:40)
Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!
Offline
Why not simply mount with your file manager? It’s not 1990s anymore, you almost never need to invoke `mount` manually or elevate privileges.
If those are internal drives udisks will still ask you for admin permissions.
One could use a noauto fstab entry, paired w/ x-systemd.automount the device will automagically be mounted when you access he mountpoint but in general
@P2erut this smells like a giat https://en.wikipedia.org/wiki/XY_problem - what are you actually trying to achieve?
Offline
If those are internal drives udisks will still ask you for admin permissions.
Udisks consults Polkit and a permission may be granted to this this without elevating privileges (action "org.freedesktop.udisks2.filesystem-mount").
Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!
Offline
If those are internal drives udisks will still ask you for admin permissions.
<!-- mount a device considered a "system device" -->
<action id="org.freedesktop.udisks2.filesystem-mount-system">
<description>Mount a filesystem on a system device</description>
<message>Authentication is required to mount the filesystem</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>Offline
Why not simply mount with your file manager? It’s not 1990s anymore, you almost never need to invoke `mount` manually or elevate privileges.
If those are internal drives udisks will still ask you for admin permissions.
One could use a noauto fstab entry, paired w/ x-systemd.automount the device will automagically be mounted when you access he mountpoint but in general
@P2erut this smells like a giat https://en.wikipedia.org/wiki/XY_problem - what are you actually trying to achieve?
Just to write mountdrives in run box and execute the terminal command i wrote earlier without asking me for root password
Offline
Yes, but *why* do you want to pursue the "mountdrives" approach?
Of course it's trivial to put that script somewhere into your $PATH, add a sudoers entry and even have it sudo itself, but if you've to ask how to do this there's an INCREDIBLY high chance that you're trying to solve a problem that doesn't even exist, but have googled some mount commands and are now trying to ask bitwise to fill the gaps.
What is your *ultimate* goal here, not the immediate one you've decided is gonna be the solution. Cause it's very likely not.
Offline
Yes, but *why* do you want to pursue the "mountdrives" approach?
Of course it's trivial to put that script somewhere into your $PATH, add a sudoers entry and even have it sudo itself, but if you've to ask how to do this there's an INCREDIBLY high chance that you're trying to solve a problem that doesn't even exist, but have googled some mount commands and are now trying to ask bitwise to fill the gaps.What is your *ultimate* goal here, not the immediate one you've decided is gonna be the solution. Cause it's very likely not.
Just to mount the SSD and HDD because i can't access them when it's not mounted, so instead typing
sudo mount /dev/sda2 /mnt/ssd && sudo mount /dev/sdb1 /mnt/hddit's easier to run a gui run box and type mountdrives and the drives are magically mounted (without imputing root password)
And no, i don't want to mount the drives with a gui file manager, because i do everything in the terminal.
Offline
And no, i don't want to mount the drives with a gui file manager, because i do everything in the terminal.
And what speaks against an fstab entry that mounts them on access?
And if anything does, have you check whether "udisksctl mount -b /dev/sda" allows you to mount the drive? (It will unless it's considered a system partition in which case: what speaks against an fstab entry?)
Offline
Pages: 1