Skip to content

Instantly share code, notes, and snippets.

@gabonator
Created February 14, 2023 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabonator/ae078b636b6990e1126330b689a0f77d to your computer and use it in GitHub Desktop.
Save gabonator/ae078b636b6990e1126330b689a0f77d to your computer and use it in GitHub Desktop.
make fat12/fat16/fat32 fs image
set -e
set -x
# FAT12 - min 64KB:
# dd if=/dev/zero of=test.img count=64 bs=1K
# mkfs.vfat -v -F 12 -S 512 -s 4 test.img
# FAT16 - min 9MB:
# dd if=/dev/zero of=test.img count=9 bs=1M
# mkfs.vfat -v -F 16 -S 512 -s 4 test.img
# FAT32 - min 256MB (cannot allocate):
# dd if=/dev/zero of=test.img count=256 bs=1M
# mkfs.vfat -v -F 32 -S 512 -s 4 test.img
rm -rf temp
rm -f test.img
dd if=/dev/zero of=test.img count=64 bs=1K
fdisk test.img <<- EOM
o
n
p
1
t
c
w
EOM
mkfs.vfat -v -F 12 -S 512 -s 4 test.img
mkdir temp
guestmount -a test.img -m /dev/sda temp
echo ahoj, toto je pokus > temp/ahoj.txt
echo cau, toto je druhy pokus > temp/cau.txt
echo `date` > temp/date.txt
cat > temp/lorem.txt <<- EOM
Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod?
Tempor incididunt ut labore et dolore magna aliqua ut enim ad minim veniam quis nostrud.
Exercitation ullamco laboris nisi ut aliquip.
Ex ea commodo consequat duis aute irure dolor in reprehenderit in voluptate velit esse cillum.
Dolore eu fugiat nulla pariatur excepteur sint occaecat cupidatat non.
Proident sunt in culpa qui officia deserunt mollit anim.
Id est laborum sed ut perspiciatis unde omnis iste natus error sit.
Voluptatem accusantium doloremque laudantium totam rem aperiam eaque ipsa quae ab.
Illo inventore veritatis et quasi architecto beatae?
Vitae dicta sunt explicabo.
EOM
umount temp
# give some time to sync
sleep 2
rm -rf temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment