1

I would like to make USB drive to become read only for users (user with no root access) .Am using ubuntu 14.04.

2 Answers2

1

[Please be aware, that an advanced user will be able to override this method. It is enough to boot the computer into a live system with a USB/DVD boot drive or to move the USB drive to another computer.]

Mount a FAT32 partition in a pendrive with write permissions only for root

FAT32 and NTFS file systems get their permissions in linux when mounted, and they cannot be changed for individual directories and files. The crucial part of the example is the command line to mount the FAT32 partition on the USB drive.

This example assumes that the pendrive is seen as /dev/sdx. Replace x with the actual drive letter, for example b: /dev/sdx1 ---> /dev/sdb1

sudo mkdir -p /mnt/sd1  # only if you want a new mountpoint
sudo umount /dev/sdx1   # only if already mounted (but with bad permissions)

sudo mount -o rw,users,umask=022 /dev/sdx1 /mnt/sd1  # mount

ls -ld /mnt/sd1                          # check permissions

sudo bash -c "echo 'Hello World' > /mnt/sd1/hello.txt"  # test writing with sudo
cat /mnt/sd1/hello.txt                   # test reading (as user)
ls -l /mnt/sd1                           # check permissions of the content
rm /mnt/sd1/hello.txt                    # test removing (as user)
echo 'I am a user' > /mnt/sd1/user.txt   # test writing (as user)
sudodus
  • 46,324
  • 5
  • 88
  • 152
0

Number of solutions are already, Might be helfull for you

USB devices showing a read only

Vishal G
  • 151