You are not logged in.

#1 2017-07-09 08:21:24

buntolo
Member
Registered: 2011-10-11
Posts: 202

Read only filesystem on usb stick

I've a 1 gb USB stick I've failed to install archlinux onto, due to space. This is NOT the arch install media, but a drive I've tried to install arch on using pacstrap with cachedir,

Now I can't format it as it's read only but according to hdparm it's not. I've tried gparted, dd, mkfs, gdisk without success. The USB stick has no physical switch.

% LC_ALL=C sudo dd if=/dev/zero of=/dev/sdc1
dd: failed to open '/dev/sdc1': Read-only file system

% sudo mount -t ext4 /dev/sdc1 /mnt/discocane      :(
mount: /dev/sdc1 is write-protected, mounting read-only

% sudo mount -t ext4 /dev/sdc1 /mnt/discocane -o archio,remount
mount: cannot remount /dev/sdc1 read-write, is write-protected

% sudo hdparm -r0 /dev/sdc                         :(

/dev/sdc:
 setting readonly to 0 (off)
 readonly      =  0 (off)

Last edited by buntolo (2017-07-09 08:49:12)

Offline

#2 2017-07-09 08:35:12

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Read only filesystem on usb stick


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-07-09 08:48:34

buntolo
Member
Registered: 2011-10-11
Posts: 202

Re: Read only filesystem on usb stick

I wasn't clear: this USB stick is NOT the arch install media, that's another one, it's the drive I've tried to install arch on. Basically I ran pacstrap on it.

I've tried without success to execute that command hoping it would help:

% LC_ALL=C sudo wipefs --all /dev/sdc               :(
wipefs: error: /dev/sdc: probing initialization failed: Read-only file system

Last edited by buntolo (2017-07-09 08:50:55)

Offline

#4 2017-07-09 10:16:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Read only filesystem on usb stick

The wipefs error is odd - but I'm not familiar with it and can't really help there.  But note that that's the only relevant error you've posted in this thread.  All the commands in your first post were fairly nonsensical.  You claimed to have taken steps that may have created a new partition table, but you've really not told us what those steps were or what errors they gave.

Just create a new partition dable on /dev/sdc (not /dev/sdc1) with fdisk, and report any errors.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2017-07-09 12:04:57

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: Read only filesystem on usb stick

Does lsblk list the device with "RO" of 1? Maybe it has some read-only "lock"? Also check if any relevant output shows up in `dmesg` when the drive is plugged in.

Offline

#6 2017-07-10 05:44:33

buntolo
Member
Registered: 2011-10-11
Posts: 202

Re: Read only filesystem on usb stick

Trilby wrote:

The wipefs error is odd - but I'm not familiar with it and can't really help there.  But note that that's the only relevant error you've posted in this thread.  All the commands in your first post were fairly nonsensical.  You claimed to have taken steps that may have created a new partition table, but you've really not told us what those steps were or what errors they gave.

Just create a new partition dable on /dev/sdc (not /dev/sdc1) with fdisk, and report any errors.

I've found reports of people who solved a similar issue by zeroing their usb stick or remounting it and then using gparted to wipe them. The last command is just to show the missing read only status.

% LC_ALL=C sudo gdisk
[sudo] password for archio: 
GPT fdisk (gdisk) version 1.0.1

Type device filename, or press <Enter> to exit: /dev/sdc
NOTE: Write test failed with error number 30. It will be impossible to save
changes to this disk's partition table!

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): 
tom.ty.89 wrote:

Does lsblk list the device with "RO" of 1? Maybe it has some read-only "lock"? Also check if any relevant output shows up in `dmesg` when the drive is plugged in.

Yes, it shows it as read only, it seems to be inconsistent with hdparm:

% LC_ALL=C lsblk                                    :(
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238.5G  0 disk 
|-sda1   8:1    0   512M  0 part /boot
|-sda2   8:2    0    25G  0 part /
|-sda3   8:3    0    15G  0 part /var
|-sda4   8:4    0   194G  0 part /home
`-sda5   8:5    0     4G  0 part [SWAP]
sdb      8:16   0 238.5G  0 disk 
|-sdb1   8:17   0   450M  0 part 
|-sdb2   8:18   0   100M  0 part 
|-sdb3   8:19   0    16M  0 part 
`-sdb4   8:20   0 237.9G  0 part 
sdc      8:32   1   984M  1 disk 
`-sdc1   8:33   1   982M  1 part 

% LC_ALL=C dmesg | tail
[82893.185736] usb-storage 3-6:1.0: USB Mass Storage device detected
[82893.186926] scsi host6: usb-storage 3-6:1.0
[82894.189514] scsi 6:0:0:0: Direct-Access              USB DISK 2.0     PMAP PQ: 0 ANSI: 0 CCS
[82894.458660] sd 6:0:0:0: [sdc] 2015232 512-byte logical blocks: (1.03 GB/984 MiB)
[82894.458936] sd 6:0:0:0: [sdc] Write Protect is on
[82894.458940] sd 6:0:0:0: [sdc] Mode Sense: 23 00 80 00
[82894.459104] sd 6:0:0:0: [sdc] No Caching mode page found
[82894.459112] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[82894.695575]  sdc: sdc1
[82894.696845] sd 6:0:0:0: [sdc] Attached SCSI removable disk

Last edited by buntolo (2017-07-10 05:45:25)

Offline

#7 2017-07-10 07:38:35

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: Read only filesystem on usb stick

If I would have to guess, it's just the way of the controller in the drive telling you that it's dead. (The more common way being "no medium found".)

It's listed as RO=1 in lsblk because the scsi disk driver (sd) is notified that the drive is write protected, as you can see in dmesg, through the WP bit in the MODE SENSE response from the drive.

SBC-4 rev. 13 wrote:

If the medium is write-protected (i.e., due to mechanisms outside the scope of this standard), or the software write protect (SWP) bit in the Control mode page (see SPC-5) is set to one, then the device server shall set the WP bit to one when returning a DEVICE-SPECIFIC PARAMETER field in response to a MODE SENSE command. If the medium is not write-protected and the SWP bit is set to zero, then the device server shall set the WP bit to zero when returning a DEVICE-SPECIFIC PARAMETER field in response to a MODE SENSE command.

You can check the WP bit and the SWP bit (whether it is changeable) with sdparm:

sdparm -a /dev/sdX
sdparm -a -6 /dev/sdX

Edit: it is possible to make sd ignore the WP bit of a thumb drive by using the "no wp detect" quirk of usb-storage. You may want to try it for fun (i.e. really, just don't consider this drive safe to use anymore, not even as an installation medium):

options usb-storage quirks=$vid:$pid:w

Put this in for example /etc/modprobe.d/nowp.conf. You might need to regenerate the initramfs with mkinitcpio -P before rebooting. $vid:$pid of the drive can be checked with lsusb.

P.S. There is no point using hdparm on ordinary USB thumb drives, since hdparm are essentially useful on (S)ATA drives only. Though some modern USB thumb drives are actually (S)ATA drive with a USB/(S)ATA bridge where hdparm may be found useful, it is definitely not the case of your 1GB antique.

Last edited by tom.ty89 (2017-07-10 08:01:32)

Offline

#8 2017-07-10 10:58:52

buntolo
Member
Registered: 2011-10-11
Posts: 202

Re: Read only filesystem on usb stick

So this stick is dead for sure, right?

% sudo sdparm -a /dev/sdc
    /dev/sdc:           USB DISK 2.0      PMAP
Read write error recovery mode page:
  AWRE          0  [cha: n, def:  0, sav:  0]
  ARRE          0  [cha: n, def:  0, sav:  0]
  TB            0  [cha: n, def:  0, sav:  0]
  RC            0  [cha: n, def:  0, sav:  0]
  EER           0  [cha: n, def:  0, sav:  0]
  PER           0  [cha: n, def:  0, sav:  0]
  DTE           0  [cha: n, def:  0, sav:  0]
  DCR           0  [cha: n, def:  0, sav:  0]
  RRC           48  [cha: y, def: 48, sav:255]
  COR_S         0  [cha: n, def:  0, sav:  0]
  HOC           0  [cha: n, def:  0, sav:  0]
  DSOC          0  [cha: n, def:  0, sav:  0]
  LBPERE        0  [cha: n, def:  0, sav:  0]
  MWR           0  [cha: n, def:  0, sav:  0]
  WRC           0  [cha: n, def:  0, sav:  0]
  RTL           0  [cha: n, def:  0, sav:  0]
Write parameters (MMC) mode page:
  BUFE          1  [cha: y, def:  1, sav:  1]
Power condition mode page:
  PM_BG         0  [cha: n, def:  0, sav:  0]
  STANDBY_Y     0  [cha: n, def:  0, sav:  0]
  IDLE_C        0  [cha: n, def:  0, sav:  0]
  IDLE_B        0  [cha: n, def:  0, sav:  0]
  IDLE          1  [cha: y, def:  1, sav:  1]
  STANDBY       1  [cha: y, def:  1, sav:  1]
  ICT           0  [cha: n, def:  0, sav:  0]
  SCT           0  [cha: n, def:  0, sav:  0]
Power consumption mode page:
  ACT_LEV       0  [cha: n, def:  0, sav:  0]
  PC_ID         0  [cha: n, def:  0, sav:  0]
SAT ATA Power condition mode page:
  APMP          0  [cha: n, def:  0, sav:  0]
  APM           0  [cha: n, def:  0, sav:  0]
CD/DVD (MM) capabilities and mechanical status (MMC) mode page:
  D_RAM_R       0  [cha: n, def:  0, sav:  0]

Offline

#9 2017-07-10 14:57:35

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: Read only filesystem on usb stick

I don't know. Maybe half-bricked is a better word for this case, since you can still mount the filesystem (read-only) on its first partition. But the reason for its state might be that the controller knows/thinks it's dying.

As I've listed, you can try sdparm with -6 as well. On some drives it gives more proper result (i.e. the control mode page might be found). Btw I think I missed the fact that you need -l to check the WP bit. So you can try:

sdparm -6 -a -l /dev/sdX

These are really all the things I can think of. If it doesn't have a changeable SWP bit then I personally don't know how to fix it. Wouldn't bother anyway.

Though I would try to workaround it with the no wp detect quirk to see what happen if I try to get something written to it forcefully. For me a stick in such state could be a fun thing to play with tongue

Last edited by tom.ty89 (2017-07-10 14:58:25)

Offline

Board footer

Powered by FluxBB