Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm having trouble with a MicroSD USB drive. Or rather with the MicroSD card itself I guess.
I'm running Ubuntu 7.10. The card is formatted as FAT16 (and it's out of the question to use anything else). Reading from it and writing to it works fine up to a certain point. Then suddenly I only get read access any more no matter what I do. Plugging it in and out or remounting doesn't change a thing. It only works again once I reformat. That's pretty annoying because I have to copy all the data back to it each time.
Is there any way to fix this without reformatting? Btw read/write is still working in Windows.
How much stuff are you getting written to it before it becomes read-only? FAT16 has a limit to the number of files/folders that can exist on the root of a disk. The limit is 512, based on names 13 characters and smaller. So if you use long filenames more than 13 characters long the limit can easily become 256 or fewer.
Ok, this is snippet from my syslog file. So it looks like some clusters aren't alright. Is there a way to repair them instead of reformating each time? And how can I find out what triggers the problem?
I think I can rule out the possibility of writing too many/too long files. It's only one file with 8+3 characters.
Code:
Dec 3 13:02:42 yoda kernel: [ 7389.272971] usb 2-2: new high speed USB device using ehci_hcd and address 5
Dec 3 13:02:42 yoda kernel: [ 7389.411019] usb 2-2: configuration #1 chosen from 1 choice
Dec 3 13:02:42 yoda kernel: [ 7389.411508] scsi6 : SCSI emulation for USB Mass Storage devices
Dec 3 13:02:42 yoda kernel: [ 7389.411610] usb-storage: device found at 5
Dec 3 13:02:42 yoda kernel: [ 7389.411612] usb-storage: waiting for device to settle before scanning
Dec 3 13:02:42 yoda NetworkManager: <debug> [1196683362.290456] nm_hal_device_added(): New device added (hal udi is '/org/freedesktop/Hal/devices/usb_de
vice_5e3_715_000000009407').
Dec 3 13:02:42 yoda NetworkManager: <debug> [1196683362.349048] nm_hal_device_added(): New device added (hal udi is '/org/freedesktop/Hal/devices/usb_de
vice_5e3_715_000000009407_if0').
Dec 3 13:02:42 yoda NetworkManager: <debug> [1196683362.552286] nm_hal_device_added(): New device added (hal udi is '/org/freedesktop/Hal/devices/usb_de
vice_5e3_715_000000009407_usbraw').
Dec 3 13:02:47 yoda kernel: [ 7394.405273] usb-storage: device scan complete
Dec 3 13:02:47 yoda kernel: [ 7394.407513] scsi 6:0:0:0: Direct-Access Generic STORAGE DEVICE 9407 PQ: 0 ANSI: 0
Dec 3 13:02:47 yoda kernel: [ 7394.489855] sd 6:0:0:0: [sda] 1939456 512-byte hardware sectors (993 MB)
Dec 3 13:02:47 yoda kernel: [ 7394.492573] sd 6:0:0:0: [sda] Write Protect is off
Dec 3 13:02:47 yoda kernel: [ 7394.492579] sd 6:0:0:0: [sda] Mode Sense: 03 00 00 00
Dec 3 13:02:47 yoda kernel: [ 7394.492581] sd 6:0:0:0: [sda] Assuming drive cache: write through
Dec 3 13:02:47 yoda kernel: [ 7394.498864] sd 6:0:0:0: [sda] 1939456 512-byte hardware sectors (993 MB)
Dec 3 13:02:47 yoda kernel: [ 7394.501567] sd 6:0:0:0: [sda] Write Protect is off
Dec 3 13:02:47 yoda kernel: [ 7394.501572] sd 6:0:0:0: [sda] Mode Sense: 03 00 00 00
Dec 3 13:02:47 yoda kernel: [ 7394.501575] sd 6:0:0:0: [sda] Assuming drive cache: write through
Dec 3 13:02:47 yoda kernel: [ 7394.501579] sda: sda1
Dec 3 13:02:47 yoda kernel: [ 7394.504266] sd 6:0:0:0: [sda] Attached SCSI removable disk
Dec 3 13:02:47 yoda kernel: [ 7394.504298] sd 6:0:0:0: Attached scsi generic sg0 type 0
Dec 3 13:02:47 yoda NetworkManager: <debug> [1196683367.443276] nm_hal_device_added(): New device added (hal udi is '/org/freedesktop/Hal/devices/usb_de
vice_5e3_715_000000009407_if0_scsi_host').
Dec 3 13:02:47 yoda NetworkManager: <debug> [1196683367.446374] nm_hal_device_added(): New device added (hal udi is '/org/freedesktop/Hal/devices/usb_de
vice_5e3_715_000000009407_if0_scsi_host_scsi_device_lun0').
Dec 3 13:02:47 yoda NetworkManager: <debug> [1196683367.471321] nm_hal_device_added(): New device added (hal udi is '/org/freedesktop/Hal/devices/usb_de
vice_5e3_715_000000009407_if0_scsi_host_scsi_device_lun0_scsi_generic').
Dec 3 13:02:47 yoda NetworkManager: <debug> [1196683367.550512] nm_hal_device_added(): New device added (hal udi is '/org/freedesktop/Hal/devices/storag
e_serial_Generic_STORAGE_DEVICE_000000009407_0_0').
Dec 3 13:02:47 yoda NetworkManager: <debug> [1196683367.675216] nm_hal_device_added(): New device added (hal udi is '/org/freedesktop/Hal/devices/volume
_uuid_474E_ACED').
Dec 3 13:02:48 yoda hald: mounted /dev/sda1 on behalf of uid 1000
Dec 3 13:02:56 yoda kernel: [ 7403.350725] FAT: Filesystem panic (dev sda1)
Dec 3 13:02:56 yoda kernel: [ 7403.350731] fat_free_clusters: deleting FAT entry beyond EOF
Dec 3 13:02:56 yoda kernel: [ 7403.350734] File system has been set read-only
Dec 3 13:05:01 yoda /USR/SBIN/CRON[7726]: (root) CMD ( if [ -d /var/lock/mrtg ]; then if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then env LANG=C
/usr/bin/mrtg /etc/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi else mkdir /var/lock/mrtg; fi)
Dec 3 13:10:01 yoda /USR/SBIN/CRON[7816]: (root) CMD ( if [ -d /var/lock/mrtg ]; then if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then env LANG=C
/usr/bin/mrtg /etc/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi else mkdir /var/lock/mrtg; fi)
I'm wondering if the error is also present in Windows, but the OS happily keeps on writing to the drive. Perhaps this is worth a look (check the logs in the Computer Management Console).
More than likely the error is there and this means you have a hardware problem. If the error is really only in Linux that makes it seem like there is a driver problem, but I seriously doubt Linux would have trouble with a flash drive.
Looks to me like the error is in the FAT file system. I will point out that Windows is notorious for ignoring errors in its filesystems unless those errors rise to the level of keeping Windows from working.
So this could be a case of Linux keeping you out of trouble that Windows would cheerfully get you into...dunno, not sure.
You need to google that error message, but it looks to me like you are out of File allocation table space, or else the bounds of your FAT table are messed up. I suggest you run chkdsk on this flash drive from Windows and let it clean things up.
I suppose there is a Linux tool to check and repair FAT, but I don't use FAT (except in my flash drives) so I don't know. Generally, I just plug my flash drives into an XP system if they need maintenance.
Looks like the files are sometimes not written completely.
This can happen if you do not wait long enough after unmounting or "Safely Removing" the drive / card before you physically remove it.
I have a lot of RAM, which linux uses for disk & memory card cache. Sometimes when I ask to "Safely Remove" a USB stick, it may take up to 40 seconds to finish writing the cache to the external device.
@shadowsnipes:
Yes, if I run mount it is still mounted while the cache is written, but some of the GUIs (Eg my KDE 3.5.2) "Safely Remove" the desktop icon before the cache has been written.
So I have learned to look at the little flashing light on the USB stick, or manually check with mount that it has indeed been unmounted before I unplug it. No problems since
Yea, I don't always trust GUIs so I always check with the mount command as well
Same here. I always use the mount/umount commands to handle mine. I wouldn't even know if I have a gui tool for it 'cause I've never been interested enough to find out. If I issue the umount command on a disk that still has to write the cache, the prompt doesn't return until it's finished. That's when I know it's safe to remove. Watching the LED works, too, if you don't forget to watch it. However, I've seen serveral that don't have an LED indicator. IMO, that's poor design.
The above thread was very useful as I am facing the same problem and am running dosfsck to repair my USB drive. Thanks. I googled for what it tries to fix to understand the output and ran it with -v option, but didn't get much information. Can anyone elaborate on what:
File size is 111 bytes, cluster chain length is 0 bytes.
Truncating file to 0 bytes.
and
Contains a free cluster (5523521). Assuming EOF.
signifies?
Does the USB hard drive have an internal table which keeps track of the clusters used and if the table entries are not in sync with the data on the disk, at that time these errors are detected?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.