Friday, February 9, 2018

linux - USB HDD Case: can't mount 2nd ext4 partition


I bought a USB 3.0 External 3.5" HDD Case.
It is based on the following chip: JMicron JMS567.


I want to use it for attaching my internal HDD which has three partitions: swap and two ext4 partitions.


For testing purposes, I took my old 200 GB HDD, which had 2 partitions: first is a little NTFS partition, and the 2nd one is an ext4 partition.


My PC is running under Linux Mint 17.2, x86_64, kernel 4.4.


When I connected the HDD case to my PC, I could access the first NTFS partition, but it was impossible to access the 2nd ext4 partition! I also tried the USB case on Arch 2017.8 (VirtualBox). The same issue!


The following is what dmesg says on mount fail:


[288553.362536]  sdd: sdd1 sdd2
[288553.362593] sdd: p2 size 384428032 extends beyond EOD, enabling native capacity
[288553.366410] sdd: sdd1 sdd2
[288553.366457] sdd: p2 size 384428032 extends beyond EOD, truncated
[288553.394656] sd 13:0:0:0: [sdd] Attached SCSI disk
[288554.138776] EXT4-fs (sdd2): bad geometry: block count 48053504 exceeds size of device (48053293 blocks)
[288555.667902] EXT4-fs (sdd2): bad geometry: block count 48053504 exceeds size of device (48053293 blocks)

I'm 100% sure that my disk has no errors! I tested it when it was connected to my PC as a regular SATA HDD!


The most funny is that under Windows 7 I installed ext2fsd driver which allows to access ext4 partitions under Windows. So, under Win 7 I can access the 2nd ext4 partition without any problems!


This is definitely a USB driver issue!


My 200 GB disk params when it was connected as a SATA drive (I set to bold those values which differ when the disk is connected via USB):


fdisk -l /dev/sdd
Disk /dev/sdd: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders, total 390721968 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
Disk identifier: 0xe1751117
Device Boot Start End Blocks Id System
/dev/sdd1 * 2048 6293503 3145728 7 HPFS/NTFS/exFAT
/dev/sdd2 6293504 390721535 192214016 83 Linux
hdparm -I /dev/sdd
/dev/sdd:
ATA device, with non-removable media
Model Number: WDC WD2000JS-00MHB0
Serial Number: WD-WMANL1143240
Firmware Revision: 02.01C03
Standards:
Supported: 7 6 5 4
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 390721968
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 190782 MBytes
device size with M = 1000*1000: 200049 MBytes (200 GB)
cache/buffer size = 8192 KBytes

The same disk, but now connected via USB HDD case:


fdisk -l /dev/sdd
Disk /dev/sdd: 200.0 GB, 200048565760 bytes
255 heads, 63 sectors/track, 24321 cylinders, total 390719855 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disk identifier: 0xe1751117
Device Boot Start End Blocks Id System
/dev/sdd1 * 2048 6293503 3145728 7 HPFS/NTFS/exFAT
/dev/sdd2 6293504 390721535 192214016 83 Linux
hdparm -I /dev/sdd
/dev/sdd:
ATA device, with non-removable media
Model Number: WDC WD2000JS-00MHB0
Serial Number: WD-WMANL1143240
Firmware Revision: 02.01C03
Standards:
Supported: 7 6 5 4
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 390719855
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 190781 MBytes
device size with M = 1000*1000: 200048 MBytes (200 GB)
cache/buffer size = 8192 KBytes

As you can see the geometry is wrong, because sector size is wrong. Maybe, there's any parameter in mount options which allows the user to set block/sector size? Or another solution?


P. S. Detailed USB chip description:


Bus 002 Device 004: ID 152d:2590 JMicron Technology Corp. / JMicron USA Technology Corp. Seatay ATA/ATAPI Bridge
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x152d JMicron Technology Corp. / JMicron USA Technology Corp.
idProduct 0x2590 Seatay ATA/ATAPI Bridge
bcdDevice 81.05
iManufacturer 1 USB to ATA/ATAPI Brid
iProduct 2 Generic USB Device
iSerial 3 00A12345AFC0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 85
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 USB Mass Storage
bmAttributes 0xc0
Self Powered
MaxPower 30mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 6 MSC Bulk-Only Transport
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 1
bNumEndpoints 4
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 98
iInterface 10 MSC USB Attached SCSI
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Command pipe (0x01)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Status pipe (0x02)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Data-in pipe (0x03)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Data-out pipe (0x04)
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 22
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000002
Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000e
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 10 micro seconds
bU2DevExitLat 32 micro seconds
Device Status: 0x0001
Self Powered

Answer



Finally! I've found the solution which allows to use a regular mount command:


sudo resize2fs -f /dev/sdd2


That's an output:


Resizing the filesystem on /dev/sdd2 to 48053293 (4k) blocks.
The filesystem on /dev/sdd2 is now 48053293 blocks long.


This command does not delete data which is very important!


After that I am able to open both partitions with standard filesystem tools!


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...