LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-23-2018, 08:46 AM   #1
hangar35
LQ Newbie
 
Registered: Aug 2018
Posts: 7

Rep: Reputation: Disabled
Mount an external write-protected disk with bad geometry on Ubuntu Server 16.04


I have this problem:

I can not mount an external usb disk formatted in ext3, where the blocks exceed the disk size, bad geometry message. Unfortunately I can not modify the disk doing the resize and I wanted to know if there is a possibility to mount it just to read some files.

Here the syslog:
Code:
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.226640] usb 3-11.4.2: new high-speed USB device number 7 using xhci_hcd
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327197] usb 3-11.4.2: New USB device found, idVendor=13fd, idProduct=0840
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327202] usb 3-11.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327204] usb 3-11.4.2: Product: External
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327206] usb 3-11.4.2: Manufacturer: Generic
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327208] usb 3-11.4.2: SerialNumber: 333735535054513154202020
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327621] usb-storage 3-11.4.2:1.0: USB Mass Storage device detected
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327815] scsi host12: usb-storage 3-11.4.2:1.0
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.327119] scsi 12:0:0:0: Direct-Access     Generic  External         1.14 PQ: 0 ANSI: 4
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.328017] sd 12:0:0:0: Attached scsi generic sg3 type 0
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.328102] sd 12:0:0:0: [sdd] 1953525167 512-byte logical blocks: (1.00 TB/932 GiB)
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.328384] sd 12:0:0:0: [sdd] Write Protect is on
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.328387] sd 12:0:0:0: [sdd] Mode Sense: 23 00 80 00
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.328662] sd 12:0:0:0: [sdd] No Caching mode page found
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.329069] sd 12:0:0:0: [sdd] Assuming drive cache: write through
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.361692]  sdd: sdd1
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.361700] sdd: p1 size 1953523120 extends beyond EOD, enabling native capacity
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.363982]  sdd: sdd1
Aug 16 16:34:28 CINE-SERVER4 test-usb-mount.sh[17219]: Error mounting /dev/sdd1: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error mounting /dev/sdd1 at /media/root/f4b0f1a8-06ef-4a4e-a595-da8d3a0042f9: Command-line `mount -t "ext3" -o "uhelper=udisks2,nodev,nosuid" "/dev/sdd1" "/media/root/f4b0f1a8-06ef-4a4e-a595-da8d3a0042f9"' exited with non-zero exit status 32: mount: /dev/sdd1 is write-protected, mounting read-only
Aug 16 16:34:28 CINE-SERVER4 test-usb-mount.sh[17219]: mount: wrong fs type, bad option, bad superblock on /dev/sdd1,
Aug 16 16:34:28 CINE-SERVER4 test-usb-mount.sh[17219]:        missing codepage or helper program, or other error
Aug 16 16:34:28 CINE-SERVER4 test-usb-mount.sh[17219]:        In some cases useful info is found in syslog - try
Aug 16 16:34:28 CINE-SERVER4 test-usb-mount.sh[17219]:        dmesg | tail or so.
Aug 16 16:34:28 CINE-SERVER4 kernel: [87901.632812] EXT4-fs (sdd1): mounting ext3 file system using the ext4 subsystem
Aug 16 16:34:28 CINE-SERVER4 kernel: [87901.633108] EXT4-fs (sdd1): bad geometry: block count 244190390 exceeds size of device (244190389 blocks)
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.363988] sdd: p1 size 1953523120 extends beyond EOD, truncated
Aug 16 16:34:23 CINE-SERVER4 kernel: [87897.365384] sd 12:0:0:0: [sdd] Attached SCSI disk
 
Old 08-23-2018, 01:15 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,978

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
I think I'd try some form of dd or such first on this to get an image if possible. Then I'd play with that image. I used to use ranish a long time ago and it may fix it. Might see what testdisk would say about this.

With an image you can play with things if you create a backup of the image. An image can be mounted like a disk.
 
Old 08-24-2018, 08:09 AM   #3
hangar35
LQ Newbie
 
Registered: Aug 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thank you for the reply.
I could try to get an image, but my problem is that my customer has to mount and umount it continuously, files are saved from a windows system that strangely has no problem to mount it, probably with some additional driver.So I was looking for some way to mount it even in read only to allow copying of files.
 
Old 08-24-2018, 08:57 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
There are Windows ext drivers but if the drive's main purpose is to backup a Windows computer NTFS would be my preferred filesystem.

Quote:
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327197] usb 3-11.4.2: New USB device found, idVendor=13fd, idProduct=0840
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327202] usb 3-11.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327204] usb 3-11.4.2: Product: External
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327206] usb 3-11.4.2: Manufacturer: Generic
Aug 16 16:34:22 CINE-SERVER4 kernel: [87896.327208] usb 3-11.4.2: SerialNumber: 333735535054513154202020
Is this a drive from a well known manufacture like Western Digital or Seagate etc? If so then more information on the hardware is required. It could be that whatever hardware USB bridge you are using may not be passing the SCSI commands correctly.
 
Old 08-24-2018, 09:04 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
You can use dmsetup to create a virtual device that is zero-padded to a size to keep the ext4 driver happy.

First, get the actual size of partition sdd1 in 512-byte sectors. Call that PSIZE. Then
Code:
echo -e "0 $PSIZE linear /dev/sdd1 0 \n $PSIZE 8 zero" | dmsetup create padded
That will create a device /dev/mapper/padded consisting of /dev/sdd1 padded with 4096 bytes of zeros. You should be able to mount /dev/mapper/padded. Use "dmsetup remove padded" when you are done.

I suggest resizing that filesystem to fit in its current partition.
Code:
resize2fs /dev/mapper/padded ${PSIZE}s
Note the "s" suffix applied to $PSIZE to indicate 512-byte sectors. You'll need to "fsck /dev/mapper/padded" first. Be sure that data is backed up. Shrinking a filesystem is inherently hazardous in the best of situations, and this is definitely not in that category.
 
2 members found this post helpful.
Old 08-24-2018, 09:09 AM   #6
hangar35
LQ Newbie
 
Registered: Aug 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
@michaelk

The Drive is from
Initio Corporation

And the chip is:
INIC-1618L SATA

lsusb:

Quote:
Bus 002 Device 002: ID 8087:8002 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:800a Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 005: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge
Bus 004 Device 003: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 004 Device 002: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 005: ID 0557:2419 ATEN International Co., Ltd
Bus 003 Device 003: ID 0557:7000 ATEN International Co., Ltd Hub
Bus 003 Device 004: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 003 Device 002: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 
Old 08-24-2018, 09:23 AM   #7
hangar35
LQ Newbie
 
Registered: Aug 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
@rknichols

Your answer sounds very close to my solution.
I'm sorry but I'm a developer and as a system administrator I hurts badly. Help me a little more, "get the actual size of partition sdd1 in 512-byte sectors"; How do I find the size? what command should I run to get it?
 
Old 08-24-2018, 10:11 AM   #8
hangar35
LQ Newbie
 
Registered: Aug 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
@rknichols

Googling around i find how to get the size with blockdev --getsz, and your answer solve my problem.Many many thanks
 
Old 08-24-2018, 01:21 PM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Glad you got it worked out. FYI, the quickest way to get partition sizes is by looking in /proc/partitions. The sizes there are in 1KB blocks, so you need to double them to get 512-byte sectors.
 
Old 08-24-2018, 08:38 PM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
I love that dmsetup solution - you've mentioned it before, but I so rarely need it I forget it. Thanks.
BTW "blockdev --getsz ..." will work for both devices and partitions.
 
Old 03-06-2020, 12:07 PM   #11
hgoles
LQ Newbie
 
Registered: Mar 2020
Posts: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
I love that dmsetup solution - you've mentioned it before, but I so rarely need it I forget it. Thanks.
BTW "blockdev --getsz ..." will work for both devices and partitions.
Thanks, with a padded device I was able to fix my issue.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Couldn't mount any external hard Disk on Ubuntu 12.04. Tchiarot Linux - Software 13 07-11-2014 02:22 PM
Can't mount mirrored array -- bad geometry jbruyet Linux - Software 1 06-10-2013 01:11 PM
disk suddenly full and write protected osc~ Slackware 17 07-08-2007 09:18 AM
unmount write protected disk pradi_net Linux - Hardware 1 05-18-2004 02:48 PM
HELP! Error from mount: drive is write-protected... won't mount writeable. system Linux - General 2 12-27-2001 09:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 08:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration