The files on the USB stick affected by this accident included disk image files which I was about to move to the computer anyway shortly. If those are fragmented, the extents are insanely difficult to puzzle together and even locate through the swamp of nameless files.
However, for those who lack time or space storage to mirror their flash drives to a hard drive, I have thought of a way to minimize damage in case of data loss. I have observed that the majority of on-device data losses on flash drives affect the file system rather than files themselves.
Therefore, just create an image of the first 100 to 200 MB (which should easily contain the file system index which contains information about file names, paths, attributes such as time stamp, and fragmentation), which usually takes around 10 seconds.
Run this command: sudo dd if=/dev/mmcblk0 of=/media/path/to/output/file.100MB.img bs=1048576 count=100
, where mmcblk0
can be replaced with the device file.
Usually, external USB devices are sda
, sdb
, etc., and memory cards mmcblk0
, mmcblk1
, etc., and partitions are mmcblk0p1
, mmcblk0p2
, sda1
, sda2
, etc. .
if
and of
mean input file and output file respectively, bs=1048576
bytes are 1 Megabyte (bs
means block size). count=100
transfers 100 of the specified block size. The values can obviously be changed as desired, but this is just an example that works.
The files on the USB stick affected by [this accident](https://poal.co/s/DataLossPrevention/230171) included disk image files which I was about to move to the computer anyway shortly. If those are fragmented, the extents are **insanely** difficult to puzzle together and even locate through the swamp of nameless files.
However, for those who lack time or space storage to mirror their flash drives to a hard drive, I have thought of a way to minimize damage in case of data loss. I have observed that the majority of on-device data losses on flash drives affect the file system rather than files themselves.
Therefore, just create an image of the first 100 to 200 MB (which should easily contain the file system index which contains information about file names, paths, attributes such as time stamp, and fragmentation), which usually takes around 10 seconds.
Run this command: `sudo dd if=/dev/mmcblk0 of=/media/path/to/output/file.100MB.img bs=1048576 count=100`, where `mmcblk0` can be replaced with the device file.
Usually, external USB devices are `sda`, `sdb`, etc., and memory cards `mmcblk0`, `mmcblk1`, etc., and partitions are `mmcblk0p1`, `mmcblk0p2`, `sda1`, `sda2`, etc. .
`if` and `of` mean *input file* and *output file* respectively, `bs=1048576` bytes are 1 Megabyte (*`bs`* means *block size*). `count=100` transfers 100 of the specified block size. The values can obviously be changed as desired, but this is just an example that works.
(post is archived)