Linux flash read only file system

How to fix read-only usb drive?

I have read-only usb drive and could not fix it. I have read some articles about it and tried to fix but I couldn’t. I unmounted drive and used dosfsck to check and repair MS-DOS filesystems, because it is FAT filesystem and run:

1. where did the USB come from: some USBs -are- read only. Often when those are commercial those USB are hardware locked. 2. Some USB have a hardware lock on the outside.

4 Answers 4

If the USB was once writable and is now no longer, this suggests 3 things in my mind:

  1. A hardware switch on the device has been toggled. If this is the case, the simple fix would be to find that hardware switch (they can be really subtle), and toggle it.
  2. An «unclean» unmount occurred, such as pulling the USB out of the slot before the OS finished writing data to it To save the life of devices, and to improve performance, writes to most storage mediums are buffered — including USB drives. In essence, this means then unless you tell the operating system to eject/unmount the USB drive, you have no guarantee that all data has been written. Further, most filesystems have flags to indicate when they’ve been mounted and unmounted: always tell the OS you’re going to remove the drive («eject», «unmount», «turn off») before you pull it out of the slot. Consequently, if simply checking and fixing the filesystem does not work, then you could try the ham-fisted approach of copying your data temporarily somewhere else, reformatting your USB drive, and then copying your data back. By reformatting, you’re completely overwriting what was there, so the OS/filesystem will have no recollection the USB drive/filesystem was readonly before the format. One detail on repairing the filesystem. Make sure it’s not mounted first. Your set of commands implies it’s mounted. So: sudo umount /dev/sdb1 sudo dosfsck -a /dev/sdb1
  3. The USB disk itself is dying, and the embedded firmware is protecting you from losing any data. If the USB uses flash-based storage, it’s possible that you have written to the device enough times that it is now unable to write anymore. Writing to flash-based is a destructive process, and each sector can only take so many rewrites. Many drives will «hide» this fact, by internally having much larger storage (say 16G of total write space), but only present to the OS as a smaller amount (say 2G). As each sector begins to wear out, the firmware will automatically move the data to a new unused sector. After too many writes, however, there will be no more usable storage, and smart firmware implementations will lock the drive to prevent data loss. At that point, your only option would be to copy the data to a new flash drive.
Читайте также:  Alt linux ntp сервер

If there is nothing on the drive you need to keep, use «gparted» to create a new filesystem on the drive, create a new partition and format it to your format of choice (I guess you want fat32 ?). If it mounts read only, you need to change the permissions of the mount point.

With dosfsck still getting error «open: Read-only file system». It is a new drive, I just pull it out too early.

Simple solution: plug the flash drive into a computer that operates on Windows. Windows will detect the error and instruct you to scan and repair it. The drive will then work on Ubuntu in the usual way.

Long list of permissions, arcane begging invocations at Linux altar, or 30 seconds on my Windows laptop. An easy choice. Thank you, Bob A.

A thumb drive has, perhaps only recently, some means of turn itself readonly for some days as you burn there something — maybe just to preserve its life as a flash memory further.

That unit isn’t bricked at all, and you may wish to set the readonly flag to zero earlier.

Please look at hdparm —security-help from your device.

You may want to run SOME of them if not ALL; try to figure out the correct sequence.

hdparm --security-mode m --user-master m --security-freeze device; hdparm --security-mode m --user-master m --security-set-pass null device; hdparm --security-mode m --user-master m --security-unlock null device; hdparm --security-mode m --user-master m --security-disable null device; hdparm --security-mode m --user-master m --security-erase null device; hdparm --security-mode m --user-master m --security-erase-enhanced null device; 

To fully disable the readonly feature of your device. I was successful with this on a USB 2.0 64G multilaser ™ pen drive here in Brazil a month ago.

The Ubuntu utility called «DISKS» is very powerful. It can sometimes fix this fault. I’ve had success with it a couple of times. Plug in the usb drive. Open DISKS. On the left it will list the drives it can see. In the main window it will show the partitions on each drive. Select the usb drive from the list on the left. It will open in the main window and show it as one partition (unless you’ve changed this). Under the window there are 2 icons, one can be used to mount and unmount the drive and the other (Gear Wheels) can be used for a wide range of maintenance operations. Underneath this there are 4 items of information about the drive — Size, Device, UUID, Contents. These will help you make sure you have selected the right drive. Click the Gear Wheels and on the sub-menu look about 7 items down for «Repair Filesystem». You’ll get a warning but continue. If DISKS can fix the drive it may create a number of FSCK files on the drive. When it has finished it will list the FSCK files it has created. You have to open a console and delete these files with sudo rm -rf FSCK* Once you’ve done this to tidy up the drive you are done. DISK will have removed the flag that made the file system read-only. Eject the usb drive and then remove it from the slot. It should now behave normally, if you are lucky.

Читайте также:  Sstp vpn server linux

You must log in to answer this question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Read Only usb stick that won’t let me do anything to it

Somehow I messed up and accidentally made my usb stick into a read only file system. I have tried a bunch of things to delete the files, including the basic ( rm -f myfile ) and attempting to allow writing ( sudo chmod +w myfile ) and then deleting, but none of this seems to work. Any ideas on what I can do. I don’t have anything on the usb stick that I need, but I don’t want to throw away an otherwise perfectly good piece of equipment. How can I make it work? Am I going about this completely the wrong way?

The following link and links from it with more details may help you or at least explain what is the problem, askubuntu.com/questions/402236/…

5 Answers 5

Commands like rm and chmod are done on a mounted file-system. So if the file-system is read only those do not work. What you need to do is to mount the file-system as writeable.

Some USB sticks have a switch on the stick to mount them read-only. Maybe that is the reason. It could also just be broken or damaged due to not correctly umounting it.

Before you do anything: copy the files over from the stick.

If it is not a hardware switch unplug and plug the USB stick and issue a

This will show you any panic messages. If you are seeing alot of them related to the USB stick and if it is a FAT partition you can use dosfsck to fix it.

You can find out how it is mounted with

Читайте также:  Optimus manager linux mint

to fix an MS-DOS partition table or sudo mkfs.vfat /dev/sd to format the disc. Where is a letter and digit you got with the mount command.

You can also use gparted to format it by the way.

Источник

Fix read only file system usb [closed]

Questions describing a problem that can’t be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers.

sudo fdisk -l Device Boot Start End Sectors Size Id Type /dev/sdc1 * 2048 7864319 7862272 3.8G b W95 FAT32 
sudo mkfs.fat -F 32 /dev/sdc1 mkfs.fat 3.0.28 (2015-05-16) mkfs.fat: unable to open /dev/sdc1: Read-only file system 

How can I fix this? PS: Let’s assume the USB is not write-protected by design, such as with a manual switch.

The command mount (probably as root) is the one to use to change mounted filesystem state, not mkfs .

Is this a sandisk usb? Some have a hardware ‘safety lock’ that locks the usb to read-only in the event of a usb power fluctuation. I had one that did this and had to be returned, though they replaced it FOC.

Is it plugged into a USB 3.0 socket (the blue kind)? I have a 4 GB flash drive that mounts as read-only when connected to USB 3.0, but I can write to it when I use the older USB sockets on the same computer (running Xubuntu 16.04).

we have same distro but unfortunately my laptop does not have any USB 2.0 socket.I will try it on another laptop .Thanks

1 Answer 1

  1. Make sure you are performing filesystem management actions with escalated privileges. Most systems do not let users modify filesystems.
  2. Ensure the device isn’t already mounted. As root, execute lsblk and look for any filesystems using /dev/sdc1 . If it is mounted you will have to unmount prior to formatting with mkfs.
  3. Make sure the device is not a read-only UFD. Though uncommon, these do exist . usually as hand-outs from vendor booths with product sheets or other vendor info on them.

Quick walkthrough of steps

  1. Verify you are performing all tasks as root. Best way is to simply open a shell as root: In a terminal, execute sudo -i is usually the easiest way.
  2. Unmount the device with umount /dev/sdc1 (may give error info if it is not mounted, no worries if this happens)

VVV WARNING THIS WILL DESTROY ALL DATA ON THE DEVICE VVV

  1. Format the device mkfs.vfat /dev/sdc1 (you can force 32bit size if you wish, but mkfs will select whatever fits best for the size of the volume)

If this does not work, you may want to wipe the device, recreate the partition with fdisk, and try again:

Again, this will destroy any remaining data. You have been warned.

Источник

Оцените статью
Adblock
detector