Created
March 18, 2023 10:24
-
-
Save algermissen/413689b57e806716462b4dd01e3c2be9 to your computer and use it in GitHub Desktop.
Creates a simple root filesystem layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -lt 1 ]; then | |
echo "Please provide dir to create the root file system in" | |
exit 1 | |
fi | |
ROOT=$1 | |
if [ -e "$ROOT" ] | |
then | |
echo "$ROOT already exists" | |
exit 1 | |
fi | |
mkdir -p "$ROOT"/{etc,tmp,proc,sys,dev,home,mnt,root,usr/{bin,sbin,lib},var} && chmod a+rwxt "$ROOT"/tmp | |
cat > "$ROOT"/etc/passwd << 'EOF' && | |
root::0:0:root:/root:/bin/sh | |
guest:x:500:500:guest:/home/guest:/bin/sh | |
nobody:x:65534:65534:nobody:/proc/self:/dev/null | |
EOF | |
cat > "$ROOT"/etc/group << 'EOF' && | |
root:x:0: | |
guest:x:500: | |
EOF | |
echo "nameserver 8.8.8.8" > "$ROOT"/etc/resolv.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment