Bilder von einem USB-Stick wiederherstellen
Situation
Eine Person, welche nicht weiter genannt wird, sicherte ihre Bilder auf USB-Sticks. Leider war der Person nicht (mehr) bekannt, das ein USB-Stick keine sichere Lösung ist, sondern eine sehr schlechte als Datensicherung.
D.h. der USB-Stick war für Otto-Normalo nicht mehr lesbar und die Bilder weg.
Image des Sticks erstellen
Im ersten Schritt habe ich ein Image des defekten Sticks erstellt. Zum einen ist ein suchen und wiederherstellen von lokaler Festplatte schneller und ich muss nicht weiter am “defekten” USB-Stick hantieren.
sudo dd if=/dev/sdb of=sdb.img bs=4M oflag=sync status=progress
Der zweiter Schritt ist das scannen des Images mit photorec. Das Programm ist im Paket testdisk enthalten.
sudo photorec sdb.img
Wiederherstellung mit photorec
Auswahl Image / Abbild
PhotoRec 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
PhotoRec is free software, and
comes with ABSOLUTELY NO WARRANTY.
Select a media and choose 'Proceed' using arrow keys:
>Disk sdb.img - 1992 MB / 1900 MiB (RO)
>[Proceed ] [ Quit ]
Note:
Disk capacity must be correctly detected for a successful recovery.
If a disk listed above has an incorrect size, check HD jumper settings and BIOS
detection, and install the latest OS patches and disk drivers.
Auswahl Partition / Disk
PhotoRec 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
Disk sdb.img - 1992 MB / 1900 MiB (RO)
Partition Start End Size in sectors
No partition 0 0 1 242 55 5 3891200 [Whole disk]
> 1 * FAT16 >32M 0 0 33 242 55 5 3891168
>[ Search ] [Options ] [File Opt] [ Quit ]
Start file recovery
Auswahl Dateisystem
PhotoRec 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
1 * FAT16 >32M 0 0 33 242 55 5 3891168
To recover lost files, PhotoRec needs to know the filesystem type where the
file were stored:
[ ext2/ext3 ] ext2/ext3/ext4 filesystem
>[ Other ] FAT/NTFS/HFS+/ReiserFS/...
Wiederherstellungsziel
PhotoRec 7.2, Data Recovery Utility, February 2024
Please select a destination to save the recovered files to.
Do not choose to write the files to the same partition they were stored on.
Keys: Arrow keys to select another directory
C when the destination is correct
Q to quit
Directory /home/cane/tmp/2026-08-14
>drwxr-xr-x 1000 1000 110 14-Aug-2026 20:17 .
drwxr-xr-x 1000 1000 180 14-Aug-2026 15:43 ..
-rw-r--r-- 0 0 1992294400 14-Aug-2026 15:45 sdb.img
Mit C bestätigen
Fertig
PhotoRec 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
Disk sdb.img - 1992 MB / 1900 MiB (RO)
Partition Start End Size in sectors
1 * FAT16 >32M 0 0 33 242 55 5 3891168
389 files saved in /home/user/tmp/2026-08-14/recup_dir directory.
Recovery completed.
You are welcome to donate to support and encourage further development
https://www.cgsecurity.org/wiki/Donation
Die Fotos liegen nun im auswählten Ordner unter recup_dir bereit.
Wiederhergestellte Dateien passend benennen
Mit einem LLM wurde noch ein Skript generiert und minimal angepasst, welches aus den Metadaten das Datum ausgelesen und die Dateien in das Format 2017-06-08_20-31-21.jpg umbenennt.
#!/usr/bin/env bash
set -euo pipefail
DIR="${1:-.}"
command -v exiftool >/dev/null 2>&1 || {
echo "Fehlt: exiftool" >&2
exit 1
}
cd "$DIR"
shopt -s nullglob
files=(*.{jpg,jpeg,JPG,JPEG,png,PNG,webp,WEBP,heic,HEIF,heif,TIFF,tif,TIFF,TIF,bmp,BMP})
shopt -u nullglob
for f in "${files[@]}"; do
echo Datei: $f
dt="$(exiftool -s -s -s \
-DateTimeOriginal -DateTime -CreateDate \
-d '%Y:%m:%d %H:%M:%S' \
"$f" 2>/dev/null | head -n1 || true)"
[[ -z "$dt" ]] && continue
ext="${f##*.}" # Endung einmal übernehmen
year="${dt:0:4}"
mon="${dt:5:2}"
day="${dt:8:2}"
hour="${dt:11:2}"
min="${dt:14:2}"
sec="${dt:17:2}"
new_base="${year}-${mon}-${day}_${hour}-${min}-${sec}"
new="${new_base}.${ext}"
# Wenn Zieldatei schon existiert: umbenennen mit _1 (ggf. _2, _3, ...)
if [[ -e "$new" && "$new" != "$f" ]]; then
i=1
while [[ -e "${new_base}_$i.${ext}" ]]; do
((i++))
done
new="${new_base}_$i.${ext}"
fi
[[ "$new" == "$f" ]] && continue
echo mv -n -- "$f" ../date/"$new"
mv -n -- "$f" ../date/"$new"
done