You are not logged in.

#1 2017-08-28 13:35:05

WangYilin
Member
From: Beijing
Registered: 2016-12-15
Posts: 8

My USB-key cannot be formated, even hdparm cannot restore it.

Hello everyone!

My USB-key cannot be formated, even hdparm cannot restore it. Here is the discription and the output of some commands.

Could anybody help me format or repair this disk?  thank you very much!

DISCRIPTION:

I tried to install archlinux on my USB-key using an archlinux system in virtualbox.

I created several partition using fdisk: sde1 and sde2 as primary partition; sde3 as extended partition; sde5, sde6 and sde7 as logical partition.
sde5 was formated as swap.
I use mkfs.ext4 to format sde1 from the 2048 sector (the default start limit) and an warning appears.
I remember the warning probably says that sde1 contains a dos partition table but I forgot to copy that warning.
Then I ignored it and go on and sde1 was formated successfully (a wrong decision, maybe).
I continued to format other partitions but an error appears while formating sde6.

[root@archlinux ~]# mkfs.ext4 /dev/sde6
mke2fs 1.43.5 (04-Aug-2017)
/dev/sde6: Read-only file system while setting up superblock

After that, no matter how hard I try, the USB-key could neither be formated or restored, even by hdparm.

OUTPUT OF SOME COMMANDS:

(1) fdisk -l

[root@archlinux ~]# fdisk -l /dev/sde
Disk /dev/sde: 30.2 GiB, 32463912960 bytes, 63406080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6b40924e

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sde1           2048  2099199  2097152    1G 83 Linux
/dev/sde2        2099200 35653631 33554432   16G 83 Linux
/dev/sde3       35653632 63406079 27752448 13.2G  5 Extended
/dev/sde5       35655680 39849983  4194304    2G 83 Linux
/dev/sde6       39852032 44046335  4194304    2G 83 Linux
/dev/sde7       44048384 63406079 19357696  9.2G 83 Linux

(2) parted print

[root@archlinux ~]# parted /dev/sde
Warning: Unable to open /dev/sde read-write (Read-only file system).  /dev/sde
has been opened read-only.
Warning: Unable to open /dev/sde read-write (Read-only file system).  /dev/sde
has been opened read-only.
GNU Parted 3.2                                                            
Using /dev/sde
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: USB Flash DISK (scsi)
Disk /dev/sde: 32.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  1075MB  1074MB  primary   ext4
 2      1075MB  18.3GB  17.2GB  primary   ext4
 3      18.3GB  32.5GB  14.2GB  extended
 5      18.3GB  20.4GB  2147MB  logical   linux-swap(v1)
 6      20.4GB  22.6GB  2147MB  logical
 7      22.6GB  32.5GB  9911MB  logical

(3) hdparm --dco-restore

[root@archlinux ~]# hdparm --yes-i-know-what-i-am-doing --dco-restore /dev/sde

/dev/sde:
 issuing DCO restore command
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

PS:
I have tried hdparm -r0, the read-only was turned off, but I still receive "Read-only file system" performing fdisk or parted.


Could anybody help me repair this disk?  thank you very much!

Offline

#2 2017-08-28 14:29:23

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: My USB-key cannot be formated, even hdparm cannot restore it.

Could be that your USB stick is dying, it's quite common for them to switch to read-only mode when they're on their way out.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2017-08-28 14:44:44

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: My USB-key cannot be formated, even hdparm cannot restore it.

See the output of dmesg to see if there is any hardware problem with your key (if there is hardware problem you should see I/O errors from it). If the hardware is OK, completely wipe out the partition table with gdisk (not fdisk, gdisk being able to wipe MBR and GPT table if the key contains one):

# gdisk /dev/sdb   # Use the device that corresponds to your key
x ( Expert commands)
z (zap)

Answer Yes to the confirmation and answer Yes once again to wipe out the MBR table too. After that launch fdisk (to make a MBR table) or gdisk (to make a GPT table); repartition your drive and reformat the partitions.

Offline

#4 2017-08-29 11:14:30

WangYilin
Member
From: Beijing
Registered: 2016-12-15
Posts: 8

Re: My USB-key cannot be formated, even hdparm cannot restore it.

Thank you very much! slithery
it is surely one possibility.

Thank you very much! olive
I have tried your suggestion, but the problem still exist.
the results are as follows

CHECKING I/O

the output of dmesg related with the USB disk is displayed as follows. NO warnings and errors, It seems that the hardware is OK

......
[  198.343307] usb 1-11: new high-speed USB device number 5 using xhci_hcd
[  198.516941] usb-storage 1-11:1.0: USB Mass Storage device detected
[  198.517112] scsi host6: usb-storage 1-11:1.0
[  198.517149] usbcore: registered new interface driver usb-storage
[  198.518000] usbcore: registered new interface driver uas
[  199.743578] scsi 6:0:0:0: Direct-Access     USB      Flash DISK       1100 PQ: 0 ANSI: 4
[  199.745503] sd 6:0:0:0: [sde] Attached SCSI removable disk
[  199.749954] sd 6:0:0:0: [sde] 63406080 512-byte logical blocks: (32.5 GB/30.2 GiB)
[  199.750362] sd 6:0:0:0: [sde] Write Protect is on
[  199.750364] sd 6:0:0:0: [sde] Mode Sense: 43 00 80 00
[  199.755663]  sde: sde1 sde2 sde3 < sde5 sde6 sde7 >
[  200.526997] EXT4-fs (sde2): mounted filesystem with ordered data mode. Opts: (null)
[  200.552964] EXT4-fs (sde1): mounted filesystem with ordered data mode. Opts: (null)
......

USING GPARTED

[root@archlinux ~]# gdisk /dev/sde
GPT fdisk (gdisk) version 1.0.3

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: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.


Command (? for help): x

Expert command (? for help): z
About to wipe out GPT on /dev/sde. Proceed? (Y/N): y
Problem opening '/dev/sde' for writing! Program will now terminate.
Blank out MBR? (Y/N): y
Warning! MBR not overwritten! Error is 30!
[root@archlinux ~]# 

I googled this error 30, it is "ERROR(30): Couldn't update MFT own record: Read-only file system"
So I tried to change the Read-only state by using hdparm r0 /dev/sde, which gives

[root@archlinux ~]# hdparm -r0 /dev/sde

/dev/sde:
 setting readonly to 0 (off)
 readonly      =  0 (off)
[root@archlinux ~]#

Then I tried gpart again, got the same result as above.

ANALYSIS:
My USB-disk is somehow locked and could not be written

Do you have any further suggestions?
Thank you very much!

Offline

Board footer

Powered by FluxBB