SparkyLinux Forums

Software & hardware support => Hardware => Topic started by: nemomen on December 27, 2020, 11:04:54 AM

Title: <SOLVED> Read-only USB stick.
Post by: nemomen on December 27, 2020, 11:04:54 AM
Hello Sparkers,
I have used one of my pen-drive many times without any problems.
Once I noted it had turned to a read-only status, not the folders and/or the files, but the device itself. I have no viruses according to my best knowledge, although it is always updated.
I did not find any working solutions to solve the problem under Windows, none of them worked so far.
Does anyone has any idea how could I clean the read-only attribute under Linux/SparkyLinux?
I have already tried to use the GParted with no result.
I use SparkyLinux Nibiru 5.13 Xfce 64-bit.
Thanks in advance and happier New Year for you all.
nemomen
Title: Re: Read-only USB stick.
Post by: paxmark1 on December 28, 2020, 06:51:50 AM
Gparted is a whole level up - that is partitioning.   "man chmod"  probably do not need  "man chown"

Command line     "ls -al"   your permissions will be at the beginning   as

drwxr-xr-x 2 paxmark paxmark      4096 Dec 27 23:27  .                                                             │
drwxr-xr-x 7 paxmark paxmark     16384 Dec 27 23:27  ..                                                            │
-rw-r--r-- 1 paxmark paxmark  19933700 Nov 13  2019 'St Olaf.Choir-Ehre.sei.Gott.in.der.Höhe.mkv'                  │
-rw-r--r-- 1 paxmark paxmark 115114772 Dec 24 21:18 'St.Olaf.Choir-Night.Silence-Silent.Night- Nidarosdomens.jentek│
or.mkv'                                                                                                            │
-rw-r--r-- 1 paxmark paxmark  89418541 Feb 20  2019  St.Olaf.Christmas.Fest-2018-Wake.Awake.For.Night.Flying.mkv   │
-rw-r--r-- 1 paxmark paxmark  77434151 Dec 16 11:02 'Wartburg Christmas.Wartburg.2020-Night.Wonder.mkv'


The rw-r--r--    probably what you want.   which is 644   if you want to type less

chown is how you fix it.   

https://www.redhat.com/sysadmin/audit-permissions-find
How to search a directory and subdirectories

find . -perm -644                                             
.                                                                                                     
./Wartburg Christmas.Wartburg.2020-Night.Wonder.mkv     
./St Olaf.Choir-Ehre.sei.Gott.in.der.Höhe.mkv                       
./St.Olaf.Christmas.Fest-2018-Wake.Awake.For.Night.Flying.mkv 
./St.Olaf.Choir-Night.Silence-Silent.Night- Nidarosdomens.jentekor.mkv


Read is 4   Write is 2 X (execute - do) is 1   RWX =7   programs.   RW 6   R (read only) is 4.   
You can find 444's which will not write - so no copy via

find . -perm -444

To fix directories and subdirectores search "Recusrsive chmod"

Title: Re: Read-only USB stick.
Post by: bin on December 28, 2020, 07:45:46 AM
The most likely reason is that it has reached the end of its useful life.

These things are not expensive but it pays to but good quality if possible.
Title: Re: Read-only USB stick.
Post by: nemomen on December 28, 2020, 04:07:56 PM
Dear Paxmark1 and bin!
Thanks for yr quick responds.
I have not used the chmod command too often, by this reason I could not be taken a master of using it, so thanks for yr suggestions. I'm gonna try it a.s.a.p.
It seems to me the device would be reached its useful life, the only problem, that is all data stored on it are very sensitive, so I do not want to destroy anyway. Luckily those data were backup yet.
Nothing are made for eternal use.
Happier New Year for you two and for all the Sparkers!
nemomen
Title: Re: Read-only USB stick.
Post by: moreno on January 05, 2021, 02:19:31 PM
May I ask which USB stick are you using for the process? I'm recently using a 32gb Corsaire Voyager but I wanna buy a Kanguru because I heard they work better. I'm not sure if it matters which stick you use but one of my friends suggested me to use a different one so yesterday I have ordered one to my property in Cyprus. Hope it works this time.
Title: Re: Read-only USB stick.
Post by: nemomen on January 07, 2021, 01:04:01 PM
Hello Sparkers,
it's me. The mystery making user.
When I run the followings under Windows, I found:
WINDOWS ADMINISTRATOR COMMAND LINE:
Microsoft Windows [Version 10.0.18363.418]
(c) 2019 Microsoft Corporation.
C:\Windows\system32>diskpart
Microsoft DiskPart version 10.0.18362.1
Copyright (C) Microsoft Corporation.
On computer: xxx
DISKPART> list disk
  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          xxx GB      0 B
  Disk 1    Online           14 GB      0 B
DISKPART> select disk 1
Disk 1 is now the selected disk.
DISKPART> attributes disk clear readonly
Disk attributes cleared successfully.
DISKPART> attributes disk
Current Read-only State : Yes
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No
It is interesting, if the diskpart shows disk attributes cleared successfully, how it show the diskpart attributes disk current read-only state: yes. And the USB-Stick has been remained read-only.
When I run some commands under SparkyLinux Nibiru 5.13 Xfce 64-bit as follows, I found:
LINUX:
~$ sudo df -h
[sudo] password:
/dev/sdb         15G  4,0G   11G  28% /media/user/xxx
~$ ls -l /dev/sdb
brw-rw---- 1 root disk 8, 16 jan    4 16:49 /dev/sdb
~$ sudo chmod u=rwx /dev/sdb
~$ ls -l /dev/sdb
brwxrw---- 1 root disk 8, 16 jan    4 16:49 /dev/sdb
~$ sudo chgrp user /dev/sdb
~$ ls -l
drwxr-xr-x  2 user user  xxx jan    1 13:43 Desktop
drwxr-xr-x 84 user user  xxx jan    4 16:08 Documents
drwxr-xr-x  2 user user  xxx dec   31 18:38 Pictures
drwxr-xr-x 22 user user  xxx jan    4 16:27 Downloads
drwxr-xr-x  2 user user  xxx dec   31 17:44 Public
drwxr-xr-x  2 user user  xxx dec   31 17:44 Sablons
drwxr-xr-x  2 user user  xxx jan    4 16:31 Videos
drwxr-xr-x  2 user user  xxx jan    4 16:47 Music
~$ ls -l /dev/sdb
brwxrw---- 1 root user 8, 16 jan    4 16:49 /dev/sdb
~$ df -h
/dev/sdb         15G  4,0G   11G  28% /media/user/xxx
~$ ls -l /dev/sdb
brwxrw---- 1 root user 8, 16 jan    4 16:49 /dev/sdb
~$ sudo umount /dev/sdb
~$ sudo mkfs.vfat /dev/sdb
mkfs.fat 4.1 (2017-01-24)
mkfs.vfat: unable to open /dev/sdb: Read-only file system
~$
Although I think, the permissions are in order, the formatting has no result by read-only file system.
And the problem is solved anyway, because of when I run:
~$ sudo lsblk
[sudo] xxx password:
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   1  14,4G  1 disk /media/user/xxx
~$ sudo sudo badblocks -v /dev/sdb
done                                                 
Pass completed, 14721408 bad blocks found. (14721408/0/0 errors)
the whole USB-Stick has full of bad blocks. But comparing to the previous status I am satisfied, as previously the USB-Stick was full of sensitive data and in read-only, after the last command running, the whole USB-Stick has been changed from visible, but read-only to invisible. When I forced to show any of the contained items, it shows some Chinese (?) symbols only. They are not being able to open, the USB-Stick is not configurable.
It could be taken a result, as the sensitive data invisible.
My only idea: thanks for the World's largest scrap maker, incl.WaaP.
Happier New Year for you all.

Title: Re: Read-only USB stick.
Post by: nemomen on January 07, 2021, 01:17:45 PM
Dear Moreno,
the USB-Stick of the subject is a Kingston DataTraveler G4 16GB one. I have no idea what's going on, this is the first time when I had any problem with Kingston. I use an other Kingston DataTraveler G4 16GB one without any problem.
But be honest: I have a new Adata UV150 (from Taiwan) as replacement of the USB-Stick of the subject (with no problem until so far), Energizer 32GB (not in use), and some other Kingston DataTraveler ) (different sizes), Kingston GT50; 100 G3. If it is possible, I always use Kingston, and hardware are not made in China/PRC.
I hope I could support you anyway.
Happier New Year, no coronavirus!
nemomen