LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   USB flash drive (Pen drive) mounts read only (https://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?

Hern_28 05-03-2007 12:49 PM

Permissions
 
Does the drive let you write to it if you log in as root?

tecksk8er001 05-03-2007 04:34 PM

I am having a similar problem with USB on my FC5 computer.
The difference is that my flash drives wont mount!
the link to my thread is below:
http://www.linuxquestions.org/questi...d.php?t=551071

blackhole54 05-04-2007 04:33 AM

xenmaster,

If the actual file system on your drive is FAT, take a look at post #10 on this thread and decide if it might be relevant to your situation. As I understand it, fs=floppyfss means your actual file system is either FAT or ext2. If the speculation on this thread is correct and you are using FAT, a reformat might be your only option. If you have room somewhere, you could back up your files somewhere, reformat and copy them back. If your drive actually has an ext2 file system, then I don't know what your problem might be. But then I don't think a umask for the disk would make any sense for ext2.

xenmaster 05-07-2007 08:01 AM

Hern_28,

logging in as root or not doesn't matter at all. It is not to do with permissions, but with some basic filesystem attribute, or something.

blackhole45,

the volume was factory formatted as fat32. I haven't changed that. I don't think the problem lies in too many files on the volume, but I could be wrong. There are no directories that contain huge amounts of files, however.

I cannot back up my files as of yet. I was planning to buy a NAS (Network Attached Storage) harddisk for that purpose. Things got delayed a bit because I want to have one fast external harddisk that I can use in windows and in linux and one possibly slower (network) harddisk that can be used for backup in both windows and linux. At present however, my external usb harddisk (Western Digital My Book Premium Edition), which did work fine with another win98se computer in combination with a usb2/firewire add-on card, refuses to work in windows 98se on this computer, through usb1.1 or through the usb2 add-on-card, and only works in linux through usb1.1, and then only read-only. So instead of having usb2 and firewire access to this drive, I now have none, and only partial usb1.1 access in linux. I cannot even backup my data to this drive so that I can install windows xp to check whether it will work in winxp. I am stuck. I bought this particular drive because it would work in windows 98, which it does, but which it doesn't now and here. I could find no information on its compatibility with linux, but there seemed to be usb harddisk support in linux and so I just took the chance, but now I'm left with a semi-defect product, as regards linux. On someone else's Ubuntu/Gnome desktop, it also became read-only. So now it is unusable. I will need to find some other means to backup my harddisk so that I can repartition and install winxp. Maybe I will get lucky and the My Book will be writable long enough so that I can pull it off in linux. One way out is to go ahead and buy that network harddisk, so that I can back up, but if I'm unlucky, that will mean I'm left without any speedy data-storage, only 100Mbit and usb1.1. If speedy external storage is beyond my system, I may need to go for an internal harddisk that I can build into a NAS at some later time, or for a NAS drive that I can take the drive out of. But at present I am confined to IDE unless I buy a SATA controller. But first I will need to try another USB2 controller, to see if speedy access is possible, but that is useless if linux won't budge anyway! This is becoming a complex figure, and just because of the usb2 controller not working, the failure of win98se, and the read-only-ness of linux.

So. Reformatting my drive is not yet an option because I have no backup and I want to wait with buying backup until I know what the complete picture will be; will my My Book work with Linux, will it work in Windows XP, will a different USB controller change the face of this situation, etc.

My first target is to back up through other means and then install winxp and see what comes next.

xenmaster 05-07-2007 08:18 AM

Somebody had me take a look at /var/log/messages by way of a tail. Although I had previously checked /var/log/messages to see if anything useful came up, and hadn't found anything, this time i got this log:

Code:

May 7 15:12:24 linux kernel: FAT: Filesystem panic (dev sda1)
May 7 15:12:24 linux kernel: invalid access to FAT (entry 0xffffffff)
May 7 15:12:24 linux kernel: File system has been set read-only

I guess a reformat might do the trick...

[edit]
If I try to connect to my usb2 controller (Sweex 4 port usb 2.0 & 2 port firewire pci card, with "VIA Technologies, Inc.: Unknown device 3028 (rev 61)") , I get the following:

Code:

May  7 17:15:12 linux kernel: uhci_hcd 0000:00:0c.0: host controller halted, very bad!
May  7 17:15:12 linux kernel: uhci_hcd 0000:00:0c.0: HCRESET not completed yet!
May  7 17:15:12 linux kernel: uhci_hcd 0000:00:0c.0: HC died; cleaning up
May  7 17:15:12 linux kernel: hub 3-0:1.0: hub_port_status failed (err = -19)
May  7 17:15:12 linux kernel: hub 3-0:1.0: connect-debounce failed, port 1 disabled
May  7 17:15:12 linux kernel: hub 3-0:1.0: cannot disable port 1 (err = -19)

Very bad! Suffice to say, it doesn't work.

blackhole54 05-07-2007 10:39 PM

xenmaster,

I just did some googling, and FWIW, several people are saying that when the vfat driver detects an error on the filesystem it remounts it read-only. I don't know if that is authoritative. You could try running fsck on it. But I would do so only as a last resort because you might end up making things worse. I think you would also need to find a way to keep it from automounting to do this since you should not fsck a partition that is mounted.

Good luck.

xenmaster 05-08-2007 09:18 AM

usb 2.0 victory
 
blackhole54,

Yes, I believe you are right. The driver encounters an error, and mounts read-only. I will need a backup, format, and restore, to fix this. I might try fsck, but only after I have done a backup ;). Strangely enough, in windows there is no problem.

I have tried to put windows Scandisk on the job, but Scandisk crashes whenever I select the external HDD.

Yesterday I bought a new USB 2.0 controller, and HOERA it works in linux, too! I now have usb 2.0 access to the drive in linux (still read-only of course) and usb 2.0 and Firewire access in Windows. (In linux the firewire driver exists due to some timeout).

What solution do you use when you want to have a portable HDD solution with >4GB files that is cross-platform? Fat32 has that 4GB limitation. NTFS is readable in linux and MacOS. The new NTFS-3G driver (http://www.ntfs-3g.org/) promises write support in linux. What is wisdom here? I could also create a second partition on the drive in NTFS for DVD-images, alongside the primary FAT32 partition for music and divx and the rest. What will linux do when it encounters two partitions on the external HDD? Will it mount as "/media/My Book_2"?

greetings, xen.

btw I can manually umount the filesystem. So running fsck is not a problem.

blackhole54 05-08-2007 09:52 PM

Quote:

Originally Posted by xenmaster
What solution do you use when you want to have a portable HDD solution with >4GB files that is cross-platform? Fat32 has that 4GB limitation. NTFS is readable in linux and MacOS. The new NTFS-3G driver (http://www.ntfs-3g.org/) promises write support in linux. What is wisdom here? I could also create a second partition on the drive in NTFS for DVD-images, alongside the primary FAT32 partition for music and divx and the rest. What will linux do when it encounters two partitions on the external HDD? Will it mount as "/media/My Book_2"?.

I have read reports of a MS Windows driver that can handle ext2/ext3. I have not used it and don't recall what it is called off the top of my head. You might look into it. Likewise, I have read about ntfs-3g, but have not used it.

I don't know what will happen if you add a second partition, but it is my understanding that Linux should handle it.

xenmaster 05-09-2007 09:21 AM

Yeah I've used the windows 2000/xp ext2 driver some while ago and it was reliable, but had a weird quirk, it would continually refresh my explorer window. A friend of mine also uses an ext2 driver but with his setup sometimes files couldn't be read ("access denied"), this was annoying. But I want to be able to go someone else who undoubtedly has a windows pc and use my external hdd just the same. So ext2/3 is not an option.

Thanx for your thought, anyway.

kalleanka 07-02-2007 01:28 PM

nice info in this thread. I got like three sticks and ten card laing around since they are full and useless. As I understand a lot of people do have this problem and there is two solutions as I see it, first to change the usb driver so it mounts it as rw even if there is some file problems or second try to solve the file problems and remount and this automated. I will reformat my disks now.

Thanks for the info so I understood the problem.


All times are GMT -5. The time now is 05:26 PM.