Search This Blog

20130221

No write access to USB drive - Crunchbang Linux

Warning: this Linux problem is written for intermediate and advanced Linux users.

Note to intermediate users: please RTFM before attempting to use any app as described in this problem.

Disclaimer: This blog article is for information only. I take no responsibility for its misuse by any Linux user who chooses to act based on the information presented.


Identifying the Problem


Recently I solved a problem involving my USB flash drive.

While working on Linux, I learned a lot about the apps used in solving the write access problem associated with it. This solution consisted of creating an entry in the file system table for the flash drive.

While it may be mounted using the file manager, this fix prevents unmounting of the flash drive.

The file manager accesses the flash drive preventing its unmounting, which is fixed by exiting the file manager.

After exiting, the flash drive may be safely unmounted before removing the flash drive.

Device and Media Descriptions


Device and media names:
  • /dev/sdc1 : device label for USB flash drive
  • /media/usb2 : media name for mounted flash drive
Apps used:
  • man: used to read thoroughly descriptions of the following apps and files
  • pmount, pumount : to mount and unmount the drive safely; use only as user
  • mount: to check the list of mounted media; DO NOT USE TO DISMOUNT media.
  • blkid: to list the mounted media's UUIDs.
  • chown: use to assign owner rights to user.
  • chgrp: use to assign group rights to user.
  • lsof: use on device name for USB flash drive.
  • gksu: command run to temporarily assign root access to user; used with gedit to edit fstab.
File changed:
  • fstab: file system table used to mount devices such as hard disk drives and removable media.
Note: I recommend that the manual for fstab be read carefully. Graphic apps
  • gedit: used to edit fstab
  • thunar: file manager

Problem

Usbmount mounts my USB flash drive as root. As a result of this, I have no write access to it using thunar. Remounting the flash drive allows me to mount and unmount it but still no write access. Description of problem Yesterday I reformatted my USB flash drive as a Linux partition on my PC running Crunchbang . After formatting, it was disconnected and then connected to the PC. Once I checked the flash drive, the following issue arose: I had no write access to it. As well, I couldn't unmount the drive. During the debugging process, I noted that when the flash drive is first connected to the PC, usbmount mounts it as root. When I remounted the flash drive using both pumount and pmount, I could mount and unmount it but still had no write access. According to what mount tells me, the flash drive is assigned as a device named "sdc1" — /dev/sdc1 — and is mounted as a media device named "usb2" — /media/usb2.

Solution

Using gedit, I edited fstab by adding a line containing the UUID of the flash drive. Disconnected and connected the flash drive. Also gave owner and group rights to user for /media/usb2. Linux now allows write access to /media/usb2. To unmount drive, exit from thunar and unmount using pumount. Description of solution With chown and chgrp, assigned owner and group right to user for /media/usb2. To solve the usbmount issue on my PC, I edited /etc/fstab using blkid to find the UUID for /media/usb2. To ensure that Linux mounts only the flash drive, its UUID is used to identify it rather than /dev/sdc1 or /media/usb2. Use of lsof on flash drive determined that thunar has access to it. After exiting from thunar, pumount is used to unmount flash drive. Once the flash drive is unmounted, it can be removed from the PC.

No comments: