Hi,
I have been trying to rescue the files from a SD card that is connected to a USB adapter, and that can not mount in the usual way because I guess it is corrupt (complains of no read-write permission even though the SD card is unlocked).
Following the instructions here:
https://blog.tinned-software.net/rescue-data-from-corrupt-sd-card/
I get:
$ sudo ddrescue -f /dev/sda SD_card_rescue.log GNU ddrescue 1.23 Press Ctrl-C to interrupt ipos: 322563 kB, non-trimmed: 0 B, current rate: 64000 B/s opos: 322563 kB, non-scraped: 0 B, average rate: 1178 kB/s non-tried: 0 B, bad-sector: 19968 B, error rate: 0 B/s rescued: 8270 MB, bad areas: 26, run time: 1h 56m 58s pct rescued: 99.99%, read errors: 78, remaining time: 0s time since last successful read: n/a Finished
However, when I try:
$ sudo losetup -f -P SD_card_rescue.img losetup: SD_card_rescue.img: failed to set up loop device: No such file or directory
Adding the full path name for the SD_card_rescue.img does not change the error.
I looked around a bit and tried the following:
https://askubuntu.com/questions/634501/cant-mount-iso-file-as-loop-device-er...
It does not per se use losetup but I still get the same error.
Any suggestions? I am on an updated F30.
Many thanks and best wishes, Ranjan
On Sun, 22 Sep 2019 08:32:19 -0500 Ranjan Maitra wrote:
Any suggestions? I am on an updated F30.
One possibility:
If you ls /dev/loop* do you see loop0, loop1, etc.? At some point linux invented dynamic /dev/loop creation and said everyone should use it, but neglected to fix all the software in the world that expected loop devices to already exist.
Here's my notes from back in the fedora 20 timeframe:
found this at work: https://bugzilla.redhat.com/show_bug.cgi?id=1019440
1. Create the file /etc/modules-load.d/loop.conf that just contains the word "loop" on a line by itself. This makes sure systemd arranges for the loop module to be loaded.
2. Create the file /etc/modprobe.d/eightloop.conf that contains the line:
options loop max_loop=8
Despite the name, that makes the min number of loop devices by 8 (which was the default kernel setting before they changed it).
3. Run (as root) "dracut --force" to rebuild the initrd with the new module options included.
4. Reboot and see 8 loop devices pre-created in /dev
Tom.
Thanks very much. I am not sure that I follow your notes, but written below is the answer to your question.
On Sun, 22 Sep 2019 09:42:22 -0400 Tom Horsley horsley1953@gmail.com wrote:
On Sun, 22 Sep 2019 08:32:19 -0500 Ranjan Maitra wrote:
Any suggestions? I am on an updated F30.
One possibility:
If you ls /dev/loop* do you see loop0, loop1, etc.? At some point linux invented dynamic /dev/loop creation and said everyone should use it, but neglected to fix all the software in the world that expected loop devices to already exist.
I get:
ls -l /dev/loop* crw-rw----. 1 root disk 10, 237 Sep 22 08:49 /dev/loop-control
Same result with sudo. I also tried
sudo rmmod loop sudo modprobe ls -l /dev/loop* crw-rw----. 1 root disk 10, 237 Sep 22 08:49 /dev/loop-control
So got the same output. Should I now try what you have written in your notes below?
Here's my notes from back in the fedora 20 timeframe:
found this at work: https://bugzilla.redhat.com/show_bug.cgi?id=1019440
- Create the file /etc/modules-load.d/loop.conf that just contains the word
"loop" on a line by itself. This makes sure systemd arranges for the loop module to be loaded.
- Create the file /etc/modprobe.d/eightloop.conf that contains the line:
options loop max_loop=8
Despite the name, that makes the min number of loop devices by 8 (which was the default kernel setting before they changed it).
- Run (as root) "dracut --force" to rebuild the initrd with the new module
options included.
- Reboot and see 8 loop devices pre-created in /dev
Many thanks again, and best wishes, Ranjan
On Sun, 22 Sep 2019 08:54:28 -0500 Ranjan Maitra wrote:
Should I now try what you have written in your notes below?
Perhaps, or the bugzilla has some other alternatives as well. Maybe you just need to be root when running the losetup command.
On Sun, 22 Sep 2019 10:23:54 -0400 Tom Horsley horsley1953@gmail.com wrote:
On Sun, 22 Sep 2019 08:54:28 -0500 Ranjan Maitra wrote:
Should I now try what you have written in your notes below?
Perhaps, or the bugzilla has some other alternatives as well. Maybe you just need to be root when running the losetup command.
No, I tried with root and did not change anything.
$ sudo losetup -f -P /home/maitra/SD_card_rescue.img losetup: /home/maitra/SD_card_rescue.img: failed to set up loop device: No such file or directory
Thanks, Ranjan
Unfortunately, I did all the suggestions in the notes provided but still get the same result.
Here is what I did:
created:
$ sudo cat /etc/modules-load.d/loop.conf loop
created:
$ sudo cat /etc/modprobe.d/eightloop.conf options loop max_loop=8
$ sudo dracut --force
Got back the prompt, and then rebooted.
$ ls /dev/loop* /dev/loop0 /dev/loop2 /dev/loop4 /dev/loop6 /dev/loop-control /dev/loop1 /dev/loop3 /dev/loop5 /dev/loop7
But still:
$ sudo losetup -f -P /home/maitra/SD_card_rescue.img losetup: /home/maitra/SD_card_rescue.img: failed to set up loop device: No such file or directory
I also tried:
$ sudo mount -o loop /home/maitra/SD_card_rescue.log /mnt/test
But now I get:
mount: /mnt/test: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
So, I looked at (as per https://askubuntu.com/questions/634501/cant-mount-iso-file-as-loop-device-er...):
$file /home/maitra/SD_card_rescue.log
and I got:
/home/maitra/SD_card_rescue.log: DOS/MBR boot sector; partition 1 : ID=0x83, start-CHS (0x0,32,33), end-CHS (0x3ec,254,63), startsector 2048, 16143277 sectors
At least the error is different here. Any further suggestions?
Many thanks, Ranjan
On Sun, 22 Sep 2019 11:18:01 -0400 Tom Horsley horsley1953@gmail.com wrote:
On Sun, 22 Sep 2019 10:07:21 -0500 Ranjan Maitra wrote:
At least the error is different here. Any further suggestions?
Fraid not.
Thanks very much for your help with this, though, Tom. Perhaps others will have other suggestions.
Best wishes, Ranjan
On September 22, 2019 8:07:21 AM PDT, Ranjan Maitra maitra@email.com wrote:
$ sudo losetup -f -P /home/maitra/SD_card_rescue.img losetup: /home/maitra/SD_card_rescue.img: failed to set up loop device: No such file or directory
That file didn't exist like it says.
$ sudo mount -o loop /home/maitra/SD_card_rescue.log /mnt/test
But now I get:
mount: /mnt/test: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
So, I looked at (as per https://askubuntu.com/questions/634501/cant-mount-iso-file-as-loop-device-er...):
$file /home/maitra/SD_card_rescue.log
and I got:
/home/maitra/SD_card_rescue.log: DOS/MBR boot sector; partition 1 : ID=0x83, start-CHS (0x0,32,33), end-CHS (0x3ec,254,63), startsector 2048, 16143277 sectors
You wrote the image to that file. Losetup on that file should work like you expect.
On Sun, 22 Sep 2019 10:17:36 -0700 Samuel Sieb samuel@sieb.net wrote:
On September 22, 2019 8:07:21 AM PDT, Ranjan Maitra maitra@email.com wrote:
$ sudo losetup -f -P /home/maitra/SD_card_rescue.img losetup: /home/maitra/SD_card_rescue.img: failed to set up loop device: No such file or directory
That file didn't exist like it says.
$ sudo mount -o loop /home/maitra/SD_card_rescue.log /mnt/test
But now I get:
mount: /mnt/test: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
So, I looked at (as per https://askubuntu.com/questions/634501/cant-mount-iso-file-as-loop-device-er...):
$file /home/maitra/SD_card_rescue.log
and I got:
/home/maitra/SD_card_rescue.log: DOS/MBR boot sector; partition 1 : ID=0x83, start-CHS (0x0,32,33), end-CHS (0x3ec,254,63), startsector 2048, 16143277 sectors
You wrote the image to that file. Losetup on that file should work like you expect.
Thanks very much! I will go through the steps again just to be sure.
While comparing with https://blog.tinned-software.net/rescue-data-from-corrupt-sd-card/
I get:
$ sudo parted -l [sudo] password for maitra: Model: USB Mass Storage Device (scsi) Disk /dev/sda: 8270MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags:
Number Start End Size Type File system Flags 1 1049kB 8266MB 8265MB primary ext4
Model: PC401 NVMe SK hynix 512GB (nvme) Disk /dev/nvme0n1: 512GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags:
Number Start End Size File system Name Flags 1 1049kB 1000MB 999MB fat32 EFI System Partition boot, esp 4 1000MB 22.5GB 21.5GB linux-swap(v1) swap 3 22.5GB 478GB 456GB 2 478GB 505GB 26.8GB ext4 5 505GB 509GB 4295MB ext4 6 509GB 512GB 2621MB ext4
-----
The first part is slightly different from on that page which reads:
$ parted -l ... Warning: Unable to open /dev/mmcblk0 read-write (Read-only file system). /dev/mmcblk0 has been opened read-only. Model: SD SL32G (sd/mmc) Disk /dev/mmcblk0: 31,9GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags:
Number Start End Size Type File system Flags 1 4194kB 31,9GB 31,9GB primary lba
--------------------------
Notably, my disk flag type is "ext4" and there are no flags. This is different from what the partition on that post is (there the disk flag type is "primary" and the flag is "lba".
Is this important?
Just to clarify, my SD is being read through an adapter because there is no SD card
Other than that, the situation is the same: I have a corrupt (I guess) SD card with pictures from a camera from a year ago.
Many thanks, Ranjan
On 9/22/19 10:51 AM, Ranjan Maitra wrote:
Notably, my disk flag type is "ext4" and there are no flags. This is different from what the partition on that post is (there the disk flag type is "primary" and the flag is "lba".
Is this important?
Unlikely.
Just to clarify, my SD is being read through an adapter because there is no SD card
Other than that, the situation is the same: I have a corrupt (I guess) SD card with pictures from a camera from a year ago.
You've already pulled the data off with ddrescue. You just used the wrong parameters. Your data is in the file called SD_card_rescue.log. You can either rename it to the name you expected or just use that file in the steps that you were trying to follow.