LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   USB flash drive (Pen drive) mounts read only (http://www.linuxquestions.org/questions/linux-hardware-18/usb-flash-drive-pen-drive-mounts-read-only-508524/)

prabhatsoni 12-08-2006 07:01 AM

USB flash drive (Pen drive) mounts read only
 
Friends
This is driving me nuts.

I have FC5.

I have a USB flash drive of 512 MB.

When I insert this into a USB port, the drive is automatically mounted. But it mounts read only. I am not able to delete, copy, change permissions etc of any file on the disk.

It seems strange.

I have gone to the "Removable Drives and Media" in the preference menu, but nowhere any control is provided.

When I mount it by giving "mount -t vfat -o rw /dev/sdb1 /media/disk", it mounts. But again when I try to delete a file, It gives the error "read-only file system".


Surprisingly, in my home PC (with FC5) when I insert this drive I find that the I am able to delete, copy etc etc.


Any help friends ?

Also friends, can we format this flash drive ?

Thanks in advance

Prabhat Soni

dracolich 12-08-2006 08:16 AM

I use the options -o gid=100,umask=002 for mine. Others use -o users. Take your pick. Look in your /etc/fstab file for a line that pertains to the device and you can put these options in that line so they get used automatically.

blackhole54 12-08-2006 08:43 AM

Quote:

Originally Posted by prabhatsoni
When I mount it by giving "mount -t vfat -o rw /dev/sdb1 /media/disk", it mounts. But again when I try to delete a file, It gives the error "read-only file system".

Give the mount command w/o any options a see whether it says it is mounted ro. If so, check /var/log/messages to see if there are any clues to why it got mounted ro.

You also might try (as root) giving the command

mount -o remount,rw /dev/dsb1

after you have already mounted it, and see if it will change over.

Quote:

Also friends, can we format this flash drive ?
My understanding is you can partition and format just like a hard drive. But you do so at your own risk. You might want to search the internet on this topic first. But normally, you just want to use the FAT filesystem that is alread there.

EDIT: You don't have you drive set to "write protect" do you?

prabhatsoni 12-09-2006 12:47 AM

Thanks friends,

(1) I had already looked up the /etc/fstab and did not find any entry corresponding to this.

(2) I used follwing command to manually mount the drive:

Code:

mount -t vfat -o uid=500,gid=500,umask=033 /dev/sdb1 /media/disk
But it too resulted into the "read-only file system"

(3) Strangely I booted into my XP and tried to delete the files from there and found that I could not do it. Then I tried to format it from XP, and was successful.

Now I can copy the files into this drive.

Inexplicable !
Beats me !


Thanks anyway friends.


Prabhat Soni

dracolich 12-09-2006 08:16 AM

One thought comes to my mind now. How many files and directories were on the root of the drive? I've experienced limits on these drives due to the FAT filesystem, especially when using long file names.

blackhole54 12-09-2006 11:11 AM

Quote:

Originally Posted by dracolich
I've experienced limits on these drives due to the FAT filesystem, especially when using long file names.

My understanding is that FAT has a hard limit on the number of directory entries in the root directory (512?). And when you delete a file, the directory entry is not removed, it is just marked as deleted. So if you run out of room in your root directory, you are just out of luck.

I believe subdirectories don't have this limit, but like the root directory they don't remove deleted entries.

m_runwal 03-20-2007 12:16 PM

Access write for Pen Drive ?
 
how should I able to write Pen drive ?
when I try to create , delete , edit , I always get Readonly access.

I am using Fedora core 6. with pen drive auto mounted.

Help me. !

blackhole54 03-20-2007 09:05 PM

Quote:

Originally Posted by m_runwal
how should I able to write Pen drive ?
when I try to create , delete , edit , I always get Readonly access.

All I know to suggest is what I suggested to prabhatsoni in post #3. Do make sure the pen drive is not set to "write protect" (a switch on the device if it has this capability).

m_runwal 03-20-2007 11:26 PM

just a day before I was able to write in pen drive. but with the same command I couldn't.

No that is not the case. in my pen drive, it doesn't have any option or nob for write protection. and all my files are easily accessible (rwx) from windows. but it still giving me trouble for linux.

Pen drive is ok. not issue with the hardward.
Linux mounting is also ok.

As its only standalone machine. the only user of my machine is MySelf. and I logged most of the time as root. what else I have to do to write in pen drive.

whenever i try to delete the file it say "read-only" access.

Your help, will really really help me out of trouble.

Thank you

prabhatsoni 03-20-2007 11:49 PM

With me the problem was intermittant.
Not having any idea about removing "read-only access" I used the brute force approach and formatted the drive and it worked ok.

I think there is substance in what blackhole54 has said above about the hard limit on directory entries in the root of the file system. And if it is true, then we would be requiring frequent reformatting whenever the limit is reached, which would again be quite frequent considering the frequent copy-delete operations which a pen drive usually goes through.

If you will be using this flash drive only with linux then creating ext3 file system might be explored.


Prabhat Soni

m_runwal 03-21-2007 04:18 AM

Thank you.
I got the clue from you both. I have formated my pen drive with windows. ( just unsure about if I format with linux could not give problem in windows) then I got the access of my file.

one more thing. their was no as such 256 folder on my root drive. it has hardly 10 to 20 folder on root drive. I haven't counted inside folder/folder/folder. but finally my problem is solved before my deadlines.

Thanks everybody.
-----------------------------------------------------
May be someother day I could able to help others.

blackhole54 03-22-2007 01:38 AM

Quote:

Originally Posted by prabhatsoni
I think there is substance in what blackhole54 has said above about the hard limit on directory entries in the root of the file system. And if it is true, then we would be requiring frequent reformatting whenever the limit is reached, which would again be quite frequent considering the frequent copy-delete operations which a pen drive usually goes through.

My recollection is that the hard limit only applies to the root directory on a partition (or drive). If so, you could solve the problem by doing all of your work in subdirectories. But beyond finding the following link, I have not researched that for this thread, so I could be wrong. I believe I first became aware of this limitation in connection with a problem NASA had with the Mars Rover. (In this article they talk about the "DOS filesystem," but I believe they really mean a FAT filesystem.)

Quote:

Originally Posted by prabhatsoni
If you will be using this flash drive only with linux then creating ext3 file system might be explored.

Good idea if you really don't need to intereact with things that can't handle ext2/ext3. I am wondering if you really want journaling (ext3 vs ext2), but I am not sure.

Quote:

Originally Posted by m_runwal
their was no as such 256 folder on my root drive. it has hardly 10 to 20 folder on root drive. I haven't counted inside folder/folder/folder.

I am glad you solved your problem.

As far as not having much stuff in the directory, remember that (at least according to the story I just linked to) it is not how much you now have in your directory, but how much total you have had since it was created. Also, I believe I recal reading that the way long filenames (beyond "8.3 names") are implimented, they chew up some of the availabe directory space. Maybe somebody reading this thread (hint, hint) who knows the details of this stuff will post, so we can all stop guessing and going on vague memories!

dracolich 03-22-2007 07:11 PM

blackhole54, you're almost right. My sources, the M$ knowledgebase and the FAT Wiki, state that the limit only applies to the root of the drive or partition. The limit, 512, inherited from FAT16, considers only objects that each use only one directory entry. When using long filenames every 13 characters requires another entry, so a file with a name that's 42 characters long (including spaces and symbols) requires the same entry space as 4 files that use the 8.3 naming format.

My mother ran into this after saving a lot of files from the internet. She never used subdirectories (she does now) but there were only 162 (60MB of a 128MB capacity) files on the root of the drive. Most of the files were 20-30 characters long.

I, personally, ran into this with my Sandisk mp3 player. I received "disk full" errors when trying to copy files although there was still over 100MB free. The filenames were all in the format:
%artist - %album - %track - %song.mp3
I had to remove the new empty file holder, unmount, disconnect, remount, copy some files off then delete them one-by-one - unmounting, disconnecting and remounting between each - until I could create some subdirectories to move them all into.

Make note of the unmount, disconnect, remount procedure. It was slow and frustrating but it worked. In my mother's case, I had already copied all her files and use Sandisk's format tool to reformat the Cruzer to it's original state, but I believe the method I used with my mp3 player would've worked.

blackhole54 03-23-2007 01:04 AM

Thanks for the clarification, dracolich.

xenmaster 05-03-2007 12:44 PM

I've got a usb harddisk that is correctly recognized (by SuSE/KDE) and automagically mounts, but then when I try to write to the filesystem, I get "Read-only file system" errors. The filesystem is mounted rw.

This is the `mount` line:
/dev/sdc1 on /media/My_Book type subfs (rw,nosuid,nodev,sync,fs=floppyfss,umask=002,procuid,utf8=true)

I myself have put the umask=002 line into /etc/fstab. But this doesn't effect the read-only-ness of the filesystem. There is nothing I can do that makes it read-write.

Sometimes, I can write to it for a couple of commands. I do a 'touch', I mkdir a directory, I move a file. But then inevitably it becomes read-only again. On one occasion I was able to write to it an entire session. This seems to be completely random behaviour.

Does anyone have any knowlegde of the mounting process of usb devices and why it could be that it gives almost random "read-only" errors?


All times are GMT -5. The time now is 03:47 PM.