How Do You Test the “mount -a” Command to Verify Sufficient Permissions on a Linux VM?

Problem scenario
You want to test "mount -a" to verify your user has sufficient permissions. You cannot add a physical device to the Linux server. How do you confirm "mount" will work?

Solution
Create a directory to be a mount point:
sudo mkdir /aaa
Find a block device to mount. One way would be to run this: sudo cat /proc/partitions
Once found, run this: sudo mount /dev/dm-2 /aaa

Run this command: sudo mount -l | grep aaa
Then the ouput will be something like this: /dev/mapper/foobar on /aaa type ext4 (rw, …)
Copy the /dev/mapper/foobar /aaa ext4 entries (all three). Back up the /etc/fstab file to /etc/fstab.bak
Update the /etc/fstab to have the three entries recently identified as the last line. For example, the last line will look something like this:
/dev/mapper/foobar /aaa ext4

Unmount the newly mapped partition by using a command like this: sudo umount /dev/dem-2
Now run sudo mount -a
Run this command: sudo mount -l | grep aaa

Leave a comment

Your email address will not be published. Required fields are marked *