Skip to content

Instantly share code, notes, and snippets.

@ph0llux
Last active May 7, 2022 18:24
Show Gist options
  • Save ph0llux/6969329b060d393e199442dc0787dc9a to your computer and use it in GitHub Desktop.
Save ph0llux/6969329b060d393e199442dc0787dc9a to your computer and use it in GitHub Desktop.
Generate an image with testdata
#!/bin/bash
MOUNTDIR="/tmp/example01";
ISO_MOUNTDIR="/tmp/isofile";
ISO_DOWNLOAD_FILE="https://cdimage.debian.org/cdimage/archive/11.2.0/amd64/iso-dvd/debian-11.2.0-amd64-DVD-1.iso"
USER="ph0llux";
PWD=$(pwd);
#create the example image and mount it.
dd if=/dev/zero of=example01.dd count=10485760 bs=2048 status=progress;
mkfs.ext4 example01.dd;
mkdir $MOUNTDIR;
sudo mount example01.dd $MOUNTDIR;
sudo chown $USER -R $MOUNTDIR;
mkdir -p $ISO_MOUNTDIR
# download and extract example data.
wget $ISO_DOWNLOAD_FILE -O $MOUNTDIR/isofile.iso
sudo mount -o loop $MOUNTDIR/isofile.iso $ISO_MOUNTDIR
cp -rv $ISO_MOUNTDIR/* $MOUNTDIR
sudo umount $ISO_MOUNTDIR
sudo umount $MOUNTDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment