Skip to content

Instantly share code, notes, and snippets.

@FauxFaux
Last active July 2, 2017 10:39
Show Gist options
  • Save FauxFaux/38ea20288c13eecffd30f4d4095b8e15 to your computer and use it in GitHub Desktop.
Save FauxFaux/38ea20288c13eecffd30f4d4095b8e15 to your computer and use it in GitHub Desktop.
cleanup() {
sudo umount a
rm a.img
sudo losetup -d /dev/loop0
}
set -eu
mkdir -p a
truncate -s 128k a.img
mkfs.ext4 a.img >/dev/null 2>&1
sudo losetup -P -f a.img
sudo mount /dev/loop0 a
seq 5000 | sudo tee a/b >/dev/null
sudo umount a
dd if=<(echo FAILED) of=a.img bs=100 count=1 conv=notrunc seek=500 >/dev/null 2>&1
sudo mount /dev/loop0 a
fgrep -2 FAIL a/b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment