Formatting a Flash Drive

Tim Chase blinux.list at thechases.com
Thu Jan 13 12:41:18 UTC 2011


On 01/13/2011 02:10 AM, RiverWind wrote:
> I can not understand for the life of me how the flash drive
> all of a sudden became a "read only" media, let alone how to
> remedy the matter.

My first thought is that the drive is mounted under/by a 
different user.  If you run under the user "riverwind", and the 
drive was mounted under the "root" account instead of your user 
account, it would display exactly this read-only behavior.

To find out you can do the following:

  bash[1]$  mount

This give you a list of mounted devices and where they're 
mounted.  You're interested in the one that's mounted where  your 
drive is.  Usually this is something like /media/usb0 on a Debian 
system, though I don't know where it ended up.

You can then go into the directory containing that mount-point 
and take a listing.  Assuming as mentioned above that your drive 
is mounted at /media/usb0 then you want to

   bash[2]$ cd /media
   bash[3]$ ls -lFd usb0

This will do a long/wide ("-l") listing of that directory for the 
mount-point.  The fields of interest are the owner information 
and the permissions.  In a world where the drive was mounted by 
your user, you should likely find "riverwind riverwind" (your 
username and primary group which most distros create as your 
name).  However my suspicion is that you'll note "root root" 
("root" is the owning username and "root" is the owning group). 
That alone isn't enough to prevent you from accessing it, but 
(depending on your settings) might be enough to prevent you from 
writing/changing to the media (including deleting).

You can then look at the permissions column to see what 
permissions that folder grants.  My guess is that you'll find 
"drwxr-xr-x" which means that, if it's not owned by your user, 
that you (part of "other", the last 3 characters) can read files 
("r") and list directory contents ("x"), but not write changes 
(the penultimate character is a "-" instead of a "w").

Including the output of that "ls" command in a reply would help 
if the following resolution ideas don't work.


THAT SAID. (Sorry, I tend to ramble)

To fix you need to get that drive remounted under your user.  A 
couple options might work for you depending on how interested you 
are in the dirty details.  The fastest/easiest solution might be 
to shut down the computer, remove the drive, start up the 
computer, log in, and then re-insert the drive.  Hopefully that 
will cause it to notice that you're logged in and should be the 
one to "own" the drive.

Personally, I abhor rebooting, so the technical solution to that 
would be to un-mount the drive as superuser:

   bash[4]$ sudo umount /media/usb0

Once that completes, you can either try re-mounting it yourself 
as your non-root user:

   bash[5]$ mount /media/usb0

or if you get a "you don't have permission to mount that here" 
message (per your /etc/fstab which would also be helpful to 
include in an email if you're willing and still having trouble), 
you can safely pull out the drive and re-insert it (hoping that 
it properly detects you as the user this time instead of root).

There's a delicate interplay between your /etc/fstab file which 
tells where/who/how things get mounted, and your hotplug/dbus/hal 
which may try to do the auto-mounting for you.  How this works 
varies between distros, so I'm not sure I can help much more.

Hope this gets you further towards your goals.

-tim





More information about the Blinux-list mailing list