Back in 2014, my wedding photographer sent me some pictures he took and were not worth printing on a USB key. Last week, I tried to take a look at these pictures but most them were now corrupted.
Following the tips from this answer, I tried the following to fix the USB drive:
$ sudo dosfsck -w -r -l -a -v -t /dev/sdc1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "MSDOS5.0"
Media byte 0xf8 (hard disk)
512 bytes per logical sector
8192 bytes per cluster
38 reserved sectors
First FAT starts at byte 19456 (sector 38)
2 FATs, 32 bit entries
7918080 bytes per FAT (= 15465 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 15855616 (sector 30968)
1979497 data clusters (16216039424 bytes)
63 sectors/track, 255 heads
112 hidden sectors
31702928 sectors total
FATs differ but appear to be intact. Using first FAT.
Write 7917996 bytes at 7937536:Operation not permitted
After some more investigation, I realized the USB key was set to read-only, probably by its hardware although I couldn't find any switch anywhere.
So I created a disk image of the USB key on my filesystem, and ran the command again:
$ sudo dosfsck -w -r -l -a -v -t /dev/loop12p1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "MSDOS5.0"
Media byte 0xf8 (hard disk)
512 bytes per logical sector
8192 bytes per cluster
38 reserved sectors
First FAT starts at byte 19456 (sector 38)
2 FATs, 32 bit entries
7918080 bytes per FAT (= 15465 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 15855616 (sector 30968)
1979497 data clusters (16216039424 bytes)
63 sectors/track, 255 heads
112 hidden sectors
31702928 sectors total
FATs differ but appear to be intact. Using first FAT.
Write 7917996 bytes at 7937536:Operation not permitted
Same result.
When this disk image is mounted, I can read the following when using mount
:
$ mount
(truncated output)
/dev/loop12p1 on /media/mick/A & M type vfat (ro,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)
And I'm pretty much stuck now. How can I work around this read-only constraint, either on the disk image or on the USB key itself?
PS: if you wonder "why didn't you create a backup of these pictures somewhere dummy?" I think I did. But I need to remember where I put it. ♂️
mkdir $HOME/mystuff; cp --recursive '/media/A & M/' $HOME/mystuff/
– waltinator May 18 '20 at 16:44