USB drives stuck in read-only mode

NoXsmoke Posted messages 267 Status Member -  
steph810 Posted messages 1865 Registration date   Status Member Last intervention   -

Good evening,

About a year ago, while I was copying files to and from one of my USB drives on my computer (I use MX Linux), my drive suddenly became read-only. I couldn't delete or add files, but I still had access to everything.

I tried everything. I tried formatting it with the little integrated software in MX, with GParted, through the command line, on Windows (why not). Each time it told me that I didn't have the rights. I also tried rewriting the partition table with TestDisk, and it told me that I didn’t have the rights either. I came to the conclusion that the drive had a physical defect (even though I still found it strange to have access to absolutely all the files on it).

And then, no later than today, it happened again with another USB drive. I have exactly the same problem, also after sorting what was on it. It can't be a coincidence, so I think the issue is caused by my computer.

Upon closer inspection, I see that the owner 'Aime' (my username) has read and write permissions, the group "Aime" has read-only access, and others also have only read-only access. So my hypothesis is that my computer no longer recognizes me as Aime and that full rights have only been granted to Aime, so I cannot delete any files, on any computer I use (I tried on another Linux, on Windows).

I feel a bit lost and would really like this curse to stop (for the survival of my other functioning drives).

I'll add one last thing that may or may not be related: I have another problem with this computer: I can't access the BIOS. I’ve already made a post here:

https://forums.commentcamarche.net/forum/affich-37784594-impossible-d-acceder-a-l-uefi

If anyone sees a link (or if they manage to solve this other problem).

Thank you very much and have a good evening!


12 answers

  1. fabul Posted messages 42122 Registration date   Status Moderator Last intervention   6 061
     

    Hello,

    For your USB key

    You can try to wipe it using Active@ KillDisk Freeware.

    If that doesn't help, tell me more about your key (Brand, Model, Size) * If applicable.

    And create a report (With the key connected) using ChipGenius (With Windows).

    Right-click in the ChipGenius window, then left-click on "Ok", and then use Ctrl + V to paste the text into your next reply here.

    Note: It may be perceived as a virus when it is not one at all.

    Disable your antivirus real-time protection while performing this operation, or add the files to exceptions.

    https://www.cjoint.com/c/LIepeZzEuZs

    -

    For the BIOS, you may need to hold F2 before the power button.

    Please report it on your other topic if resolved and how.

    0
  2. fabul Posted messages 42122 Registration date   Status Moderator Last intervention   6 061
     

    I redirected your topic to the USB Drive / Memory Card forum, but since you have questions about rights in a Linux-based system, I can redirect it again.

    0
  3. NoXsmoke Posted messages 267 Status Member 32
     

    Yes, I put it on the Linux forum because I think it's a system problem. And also because since I don't have Windows, I can't install the software you're talking about.

    Similarly, what you tell me about antivirus doesn't really concern me since there are no antivirus programs on Linux.

    And I have obviously tested all the key combinations for the BIOS (if you read the article I redirected you to, I explain that pressing the key to enter the BIOS takes me to a black screen with a dash).

    Thanks anyway.


    0
  4. fabul Posted messages 42122 Registration date   Status Moderator Last intervention   6 061
     

    If the problem concerns the hardware, the firmware of the USB key, it can be repaired under Windows.

    You can try KillDisk for Linux.

    0
  5. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 940
     

    Hello,

    1) Right after mounting the USB stick, can you copy and paste the result of the following command to be typed in a terminal:

    sudo dmesg | tail

    2) When you mount your USB stick, can you copy and paste the result of the mount command (or mount | grep media if it is mounted under /media) and only report the line that corresponds to your USB stick?

    mount mount | grep media

    3) Also report the results of:

    whoami groups

    4) Report the content of the file /etc/fstab.

    cat /etc/fstab

    5) Finally, let us know if you observe this behavior with another USB stick.

    With all this information, we should be able to understand where the problem lies (at least, if it is a Linux-related issue)

    Good luck

    0
  6. NoXsmoke Posted messages 267 Status Member 32
     
    sudo dmesg | tail [sudo] Password for Aime: [ 9448.053062] usbcore: registered new interface driver usb-storage [ 9448.062445] usbcore: registered new interface driver uas [ 9449.071682] scsi 1:0:0:0: Direct-Access Kingston DataTraveler 3.0 PMAP PQ: 0 ANSI: 6 [ 9449.082089] scsi 1:0:0:0: Attached scsi generic sg0 type 0 [ 9449.098993] sd 1:0:0:0: [sda] 242417664 512-byte logical blocks: (124 GB/116 GiB) [ 9449.099274] sd 1:0:0:0: [sda] Write Protect is on [ 9449.099277] sd 1:0:0:0: [sda] Mode Sense: 45 00 80 00 [ 9449.099593] sd 1:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 9452.124984] sda: sda1 [ 9452.145192] sd 1:0:0:0: [sda] Attached SCSI removable disk 

    Response from mount:

    /dev/sda1 on /media/Aime/KINGSTON type vfat (ro,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2) 

    Response from whoami:

    Aime

    Response from groups:

    Aime lp dialout cdrom floppy sudo audio dip video plugdev users netdev lpadmin vboxsf scanner sambashare

    Response from cat /etc/fstab:

    # Pluggable devices are handled by uDev, they are not in fstab UUID=f669c63a-2cf7-4d6a-97ff-f09dc7a1450d / ext4 discard,noatime 1 1 UUID=b7c48a0f-0387-4407-890e-fa1d82ad9526 /home ext4 discard,noatime 1 0 UUID=8b7722e6-59a0-416b-8b79-d368be11c9af swap swap discard 0 0 UUID=3E5C-DE3D /boot/efi vfat noatime,dmask=0002,fmask=0113 0 0 

    These are the results for the first of the USB drives that caused this issue, but as mentioned earlier, I now have a second one that has the same problem.

    Thank you!

    0
  7. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 940
     

    Hello,

    As shown in the response from mount, the flash drive is mounted as read-only (ro). It should be mounted as read-write (rw). I'm not sure how you proceeded with the mount, but that's where the problem lies.

    The output from the dmesg command seems to indicate that the drive is in write protect on mode. This likely explains why the drive is mounted with the ro option instead of rw.

    Several explanations are possible:

    • the drive has a physical switch that specifies whether the drive is read-only or not (see this link): you just need to flip that switch, then unplug and replug your drive;
    • the drive has a similar software system: this site discusses how to do this with diskpart (on Windows), but on Linux you can manage with hdparm (see this link);
    • apparently, BitLocker could also explain this issue (see this link), let us know if you're using it.

    Good luck

    0
  8. steph810 Posted messages 1865 Registration date   Status Member Last intervention   152
     

    Hello,

    Protection https://en.wikipedia.org/wiki/Host_protected_area

    I don't know if you've tried to set it to rw with hdparm:

    Disk or USB info

     df -TH lsblk -S sudo hdparm -I /dev/sda

    Status info

     sudo hdparm -r /dev/sda 

    To set it to rw just enter for example /dev/sda

     sudo hdparm -r0 /dev/sda

    Set to ro Read Only

     sudo hdparm -r1 /dev/sda 
    0
  9. NoXsmoke Posted messages 267 Status Member 32
     

    Hello,

    No, I don't have a physical switch, I don't use BitLocker either.

    Switching USB ports doesn't work (on any computer for that matter) and I also want to point out that it's impossible for me to format the key (since the sites recommended by @mamiemando mentioned this as a solution) all due to this read-only issue.

    The hdparm command gives the correct response:

    readonly = 0 (off) 

    But it doesn't change anything about the problem (the same thing happens to one of the users on the Ask Ubuntu forum)...


    0
  10. jns55
     

    Hello,

    Have you tried deleting the partition table and then creating a new one using the gparted utility? Be careful not to select the wrong device, make sure it's really your USB key based on its capacity.

    If this method doesn’t work either, it’s good for the trash.

    0
    1. steph810 Posted messages 1865 Registration date   Status Member Last intervention   152
       

      Hey, do you know the firmware using the version number?

      0
  11. NoXsmoke Posted messages 267 Status Member 32
     

    I tried to format it with gparted (if that's what you meant jns55) and it still says that I don't have the rights.

    I didn't understand your question steph810


    0
    1. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 940
       

      Did you start gparted with sudo? Do you have the same problem with other USB keys/drives?

      0
    2. jns55
       

      I tried to format it with gparted

      Here, it's not about formatting but replacing the partition table.

      In the Device menu, select your USB key (that's where you shouldn't confuse it with your hard drive) and then choose the option "create a new partition table", select the type "msdos", then you will get a warning message that all the data contained will be lost, confirm the operation. Your USB key is now completely empty (all space is now unallocated), you then need to create a fat32 partition using gparted that occupies all the available space so that it can be used again.

      Once again, if it doesn't work this way, your USB key is ripe for the trash.

      0
    3. NoXsmoke Posted messages 267 Status Member 32 > mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention  
       

      No, he tells me that I cannot create a new partition because the key is read-only...

      I will have tried everything...

      Thank you both!

      0
    4. steph810 Posted messages 1865 Registration date   Status Member Last intervention   152 > NoXsmoke Posted messages 267 Status Member
       

      Have you tried to repair it?

       sudo dosfsck -a /dev/sda1 

      and check the logs when you try to read it again.

      Unplug it, open a terminal, and enter this command:

       udevadm monitor 

      Once it's running, plug it back in and check the log.

      0
    5. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 940 > NoXsmoke Posted messages 267 Status Member
       

      Can you confirm if the same problem occurs with other disks / USB drives? Do you have the same issue with another computer and/or another operating system (like Windows)? The goal would be to confirm that the problem is indeed related to the drive.

      0
  12. steph810 Posted messages 1865 Registration date   Status Member Last intervention   152
     

    Have you tried with Windows and diskpart?

    diskpart list disk

    Don't get it wrong, locate your drive (for example, disk2)

    select disk 2 attribute disk

    To remove:

    attribute disk clear readonly

    To lock !!!!!!!:

    attribute disk set readonly
    0
    1. steph810 Posted messages 1865 Registration date   Status Member Last intervention   152
       

      RE:

      I just did the guinea pig, check it out.

      Command:

      mount -l

      Identify your drive, then

      mount -o remount,rw /dev/sdbxx

      and do it again:

      mount -l

      to check that it’s taken into account, and try to modify your files.

      0
    2. NoXsmoke Posted messages 267 Status Member 32 > steph810 Posted messages 1865 Registration date   Status Member Last intervention  
       

      Hello,

      Thank you for the tutorial. It always tells me:

       Unable to mount /dev/sdb1 read/write, it is write-protected.
      0
    3. steph810 Posted messages 1865 Registration date   Status Member Last intervention   152 > NoXsmoke Posted messages 267 Status Member
       

      What does this command return (by replacing xy with the appropriate value).

       stat /dev/sdxy
      0
    4. NoXsmoke Posted messages 267 Status Member 32 > steph810 Posted messages 1865 Registration date   Status Member Last intervention  
       
      File : /dev/sda1 Size : 0 Blocks : 0 I/O Blocks : 4096 block special file Device : 5h/5d Inode : 1440 Links : 1 Type of device : 8,1 Access : (0660/brw-rw----) UID : ( 0/ root) GID : ( 6/ disk) Access : 2024-02-03 11:15:09.536322879 +0100 Modify : 2024-02-03 11:15:09.536322879 +0100 Change : 2024-02-03 11:15:09.536322879 +0100 Create : - 
      0
    5. steph810 Posted messages 1865 Registration date   Status Member Last intervention   152 > NoXsmoke Posted messages 267 Status Member
       

      Are you sure you have all the permissions on the machine?

      0