0

Is there a way too find if a drive is in /etc/fstab, without root? I want to know if I can run just sudo mount /dev/sdx and it will get the mountpoint from /etc/fstab, without running the command and before running sudo.

I found there's mount --fake (on GNU) but it requires sudo.

  • 7
    Is there anything preventing you from reading /etc/fstab/? My experience is that usually the permissions on it are 644. – Thegs Oct 22 '19 at 21:16
1

Usually /etc/fstab is world-readable, so you can just cat /etc/fstab and see if it's there.

The partitions may be listed in /etc/fstab by LABEL, UUID, PARTLABEL, or PARTUUID instead of by the device path. In this case, you might not be sure if any of the entries correspond to /dev/sdx or not. Running blkid /dev/sdx should show you this information about the partition, if you have permission. (Non-root users may need to be in the disk group, or whatever group owns /dev/sdx.) If you don't have such permission, you can still see what device e.g. UUID=aa1a69af-0bad-48b8-a659-95f1daceaceb corresponds to by ls -l /dev/disk/by-uuid.

| improve this answer | |
0
$ stat -c '%a %A %n' /etc/fstab

is echoing:

644 -rw-r--r-- /etc/fstab

at least on Linux Mint 19.2 based on Ubuntu Bionic.


Every user on the system can read the fstab file (wiki).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.