Wednesday, 8 July 2009

Mounting the mounting mountain

Couldn't work out why we were unable to mount an EXT3 partition as a non-root user on Ubuntu *AND* write to it.

It turned out that, although /etc/fstab was OK, with the following line: -

/dev/sdb1 /media/mynewdrive ext3 defaults 0 0

and the non-root user had permission to write to the top-level mount point ( /media ) and the subdirectory ( /media/mynewdrive ), the same permissions did not extend to the file system on the drive.

The solution was to: -

a) Mount the drive as root ( sudo mount -a )
b) Change the permissions for the filesystem e.g. chmod -R 777 /media/mynewdrive

This sets the RWX permissions for the entire file system AND the mountpoints.

We were then able to unmount the drive ( sudo umount /media/mynewdrive ) and then remount it ( sudo mount -a ) and write to a file ( touch /media/mynewdrive/foobar ).

As the final acid test, we rebooted to ensure that the drive automatically mounted - according to: -


the defaults value in /etc/fstab are: -

rw
suid
dev
exec
auto
nouser
async

As with all things, DON'T DO THIS IF YOU ARE NOT SURE WHAT YOU'RE DOING or YOU'RE NOT SURE WHAT THE IMPACT WOULD BE or IT IS NOT YOUR DRIVE.

No comments:

TIL - read-only variables in Linux

 A co-worker was seeing an exception: -  line 8: TMOUT: readonly variable when trying to SCP a file from a remote Linux box. I did some digg...