aaruni
The Linux Guy
My usage scenario :
I had to borrow someone's SD Card for a day, I had to delete stuff on it to make room for my stuff. I decided to take the geeky way out, and instead of just copy-paste to backup, I decided dd was a better option, since, as of my understanding, it makes a bit-by-bit clone of the source device and stores it into a neat little file. ( More about dd here : dd (Unix) - Wikipedia, the free encyclopedia ).
My Mistakes :
My SD Card was /dev/sdb . I had to run :
But I really, only wanted one partition. So, I thought making some changes to the command would be all right. What I really ran was :
The Consequences of that Mistake :
When the next day, I had to restore the SD Card, I ran :
But I was horrified by the fact that only garbage was being copied into the SD Card. I repeated the same procedure twice, just in case, getting the same result both the times.
What I Had to Do :
I should have simply mounted the iso file, and then copy-pasted the data back into the SD Card. But here's the tricky part.
The code above would give errors, because of missing filesystem in the iso. After that, I lost all heart and gave up.
Here is the correct way of solving the problem :
Run the following :
You should get output similar to this :
So, in my case, the sector size if 512, and the filesystem starts at the 2048th sector.
Modify the mount command. (the number next to offset is calculated by sector start * sector size. In my case, that's 2048*512)
And voila!
My Results :
The archive mounts just fine. Right now, I'm copying all the data back using the old fashion copy-paste method.
I had to borrow someone's SD Card for a day, I had to delete stuff on it to make room for my stuff. I decided to take the geeky way out, and instead of just copy-paste to backup, I decided dd was a better option, since, as of my understanding, it makes a bit-by-bit clone of the source device and stores it into a neat little file. ( More about dd here : dd (Unix) - Wikipedia, the free encyclopedia ).
My Mistakes :
My SD Card was /dev/sdb . I had to run :
Code:
dd if=/dev/sdb of=/path/to/iso
But I really, only wanted one partition. So, I thought making some changes to the command would be all right. What I really ran was :
Code:
dd if=/dev/sdb1 of=/path/to/iso
The Consequences of that Mistake :
When the next day, I had to restore the SD Card, I ran :
Code:
dd if=/path/to/iso of=/dev/sdb1
But I was horrified by the fact that only garbage was being copied into the SD Card. I repeated the same procedure twice, just in case, getting the same result both the times.
What I Had to Do :
I should have simply mounted the iso file, and then copy-pasted the data back into the SD Card. But here's the tricky part.
Code:
mount -o loop /path/to/iso /path/to/mountpoint
The code above would give errors, because of missing filesystem in the iso. After that, I lost all heart and gave up.
Here is the correct way of solving the problem :
Run the following :
Code:
fdisk -l /path/to/iso
You should get output similar to this :
Code:
Disk sdcard.iso: 31.5 GB, 31499223040 bytes
256 heads, 63 sectors/track, 3814 cylinders, total 61521920 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: 0x00000000
Device Boot Start End Blocks Id System
sdcard.iso1 * 2048 61521919 30759936 c W95 FAT32 (LBA)
So, in my case, the sector size if 512, and the filesystem starts at the 2048th sector.
Modify the mount command. (the number next to offset is calculated by sector start * sector size. In my case, that's 2048*512)
Code:
mount -o ro,loop,offset=1048576 /path/to/iso /path/to/mountpoint
And voila!
My Results :
The archive mounts just fine. Right now, I'm copying all the data back using the old fashion copy-paste method.