Cannot mount USB drive

Having issues with your DietPi installation or found a bug? Post it here.
User avatar
MichaIng
Site Admin
Posts: 3534
Joined: Sat Nov 18, 2017 6:21 pm

Re: Cannot mount USB drive

Post by MichaIng »

Okay, at least now fsck.ext4 is correctly invoked, previously it showed fsck.ext2. The read-only is on a different level, because fsck doesn't require a filesystem to be mounted at all. [sda] Write Protect is on sounds like the drive itself is somehow write protected, but not sure if this is still due to filesystem or partition table corruption :?.

Can you try:

Code: Select all

hdparm -r0 /dev/sda
fsck /dev/sda1
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

MichaIng wrote: Tue Oct 12, 2021 2:27 pm Okay, at least now fsck.ext4 is correctly invoked, previously it showed fsck.ext2. The read-only is on a different level, because fsck doesn't require a filesystem to be mounted at all. [sda] Write Protect is on sounds like the drive itself is somehow write protected, but not sure if this is still due to filesystem or partition table corruption :?.

Can you try:

Code: Select all

hdparm -r0 /dev/sda
fsck /dev/sda1
Thanks, I read somewhere that if the drive is failing or encounters errors, the system marks it as read-only. Anyway, here is the rather strange result of your suggestion :(
root@DietPi:~# root@DietPi:~# hdparm -r0 /dev/sda

/dev/sda:
setting readonly to 0 (off)
readonly = 0 (off)
root@DietPi:~# fsck /dev/sda1
fsck from util-linux 2.33.1
e2fsck 1.44.5 (15-Dec-2018)
fsck.ext4: Read-only file system while trying to open /dev/sda1
Disk write-protected; use the -n option to do a read-only
check of the device.
root@DietPi:~#
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

Also,
root@DietPi:~# cat /var/log/messages
Oct 12 23:35:54 DietPi kernel: [ 6568.733260] EXT4-fs (sda1): INFO: recovery required on readonly filesystem
root@DietPi:~#
User avatar
trendy
Posts: 397
Joined: Tue Feb 25, 2020 2:54 pm

Re: Cannot mount USB drive

Post by trendy »

Try to do the filesystem check on the Ubuntu. Remember not to mount the stick upon connecting it.
User avatar
MichaIng
Site Admin
Posts: 3534
Joined: Sat Nov 18, 2017 6:21 pm

Re: Cannot mount USB drive

Post by MichaIng »

What I know is that a mounted filesystem is re-mounted as read-only, when critical filesystem errors are found, but I didn't see this kind of write-protection yet that blocks all kind of writes outside of the mount. hdparm -r allows to set/unset a device-level read-only flag, but obviously that either was not the case of reverted directly.

Yes makes sense to try it on a different system. Next would be to try rewriting the partition table, if not prevented for the same reason.
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

Thanks everyone. Well the result is the same. Ubuntu also recognizes the USB as in need of repair but it can neither mount it nor can it remove the read-only flag :( Seems like quite a few people had this issue but with little success. Most cases just ended up formatting the USB.
Is there any way I can salvage the data from it? Or is there a possibility of a backup of userdata might be in Dietpi?
Thank you and looking for suggestions.
User avatar
trendy
Posts: 397
Joined: Tue Feb 25, 2020 2:54 pm

Re: Cannot mount USB drive

Post by trendy »

You could try to make a dump of the usb stick with dd.
Then try to mount the image as a loop device and copy what you can salvage.
User avatar
MichaIng
Site Admin
Posts: 3534
Joined: Sat Nov 18, 2017 6:21 pm

Re: Cannot mount USB drive

Post by MichaIng »

Good idea, probably a loop device does not suffer from such read-only flag. Whether it can then be mounted is another question, but probably it can be repaired (fsck) then.
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

Thanks everyone, so I have managed to make a couple of images of the said USB. The USB itself is a write off I guess. I mounted the image in Ubuntu but it wont let me do anything probably due to ownership. I then mounted the same image to dietpi and copied the files from dietpi-userdata folder to another USB device, albeit with some copying errors. In the end however, the apps with their user data on the USB (Sonarr, Radarr, NzbGet, Jellyfin, etc) still cannot be accessed, though unlike before, they are running and not inactive.
Is there a way to fix those? Or the files within the image? The image still mounts as a read-only device (just like the USB it came from) if I remember correctly.
Many thanks for your help and time.
User avatar
MichaIng
Site Admin
Posts: 3534
Joined: Sat Nov 18, 2017 6:21 pm

Re: Cannot mount USB drive

Post by MichaIng »

Check the logs of the services which are not accessible and whether they are listening to network ports as expected:

Code: Select all

journalctl -u sonarr -u radarr -u jellyfin -u nzbget
ss -tulpn
Post Reply