diff --git a/README.md b/README.md
index fae76eb..1d8e0b3 100644
--- a/README.md
+++ b/README.md
@@ -68,10 +68,12 @@ reboot
## Customize Rootfs (Docker + Kernel Modules)
Use `customize.sh` to build a writable rootfs with Docker and kernel modules
-preloaded so Docker works out of the box.
+preloaded so Docker works out of the box. Pass the base rootfs as a positional
+argument; the output defaults to `docker-` in the same directory
+unless you pass `--out`.
```
-./customize.sh rootfs-docker.ext4 --size 6G --docker
+./customize.sh ./rootfs.ext4 --size 6G --docker
```
Options:
@@ -80,6 +82,7 @@ Options:
- `--initrd`: initrd path (default: `./wtf/root/boot/initrd.img-6.8.0-94-generic`).
- `--modules`: kernel modules directory (default: `./wtf/root/lib/modules/6.8.0-94-generic`).
- `--docker`: install Docker packages into the image.
+- `--out`: output rootfs path (default: `docker-`).
After boot, enable NAT and validate Docker:
```
diff --git a/customize.sh b/customize.sh
index 1b40abb..91a373e 100755
--- a/customize.sh
+++ b/customize.sh
@@ -7,7 +7,7 @@ log() {
usage() {
cat <<'EOF'
-Usage: ./customize.sh [--size ] [--base-rootfs ] [--kernel ] [--initrd ] [--docker] [--modules ]
+Usage: ./customize.sh [--out ] [--size ] [--kernel ] [--initrd ] [--docker] [--modules ]
Creates a copy of rootfs.ext4, optionally resizes it, boots a VM using the
copy as a writable rootfs, then applies base configuration and packages.
@@ -46,18 +46,19 @@ BR_IP="172.16.0.1"
CIDR="24"
DNS_SERVER="1.1.1.1"
+BASE_ROOTFS=""
OUT_ROOTFS=""
SIZE_SPEC=""
INSTALL_DOCKER=0
MODULES_DIR="$DIR/wtf/root/lib/modules/6.8.0-94-generic"
while [[ $# -gt 0 ]]; do
case "$1" in
- --size)
- SIZE_SPEC="${2:-}"
+ --out)
+ OUT_ROOTFS="${2:-}"
shift 2
;;
- --base-rootfs)
- BASE_ROOTFS="${2:-}"
+ --size)
+ SIZE_SPEC="${2:-}"
shift 2
;;
--kernel)
@@ -81,8 +82,8 @@ while [[ $# -gt 0 ]]; do
exit 0
;;
*)
- if [[ -z "$OUT_ROOTFS" ]]; then
- OUT_ROOTFS="$1"
+ if [[ -z "$BASE_ROOTFS" ]]; then
+ BASE_ROOTFS="$1"
shift
else
log "unknown option: $1"
@@ -93,7 +94,7 @@ while [[ $# -gt 0 ]]; do
esac
done
-if [[ -z "$OUT_ROOTFS" ]]; then
+if [[ -z "$BASE_ROOTFS" ]]; then
usage
exit 1
fi
@@ -102,6 +103,12 @@ if [[ ! -f "$BASE_ROOTFS" ]]; then
log "base rootfs not found: $BASE_ROOTFS"
exit 1
fi
+
+if [[ -z "$OUT_ROOTFS" ]]; then
+ base_dir="$(dirname "$BASE_ROOTFS")"
+ base_name="$(basename "$BASE_ROOTFS")"
+ OUT_ROOTFS="${base_dir}/docker-${base_name}"
+fi
if [[ ! -f "$KERNEL" ]]; then
log "kernel not found: $KERNEL"
exit 1
diff --git a/make-rootfs.sh b/make-rootfs.sh
index cf01c38..3d7b3a4 100644
--- a/make-rootfs.sh
+++ b/make-rootfs.sh
@@ -62,8 +62,8 @@ if [[ -z "$BASE_ROOTFS" ]]; then
fi
fi
-log "building $OUT_ROOTFS from $BASE_ROOTFS"
-exec "$DIR/customize.sh" "$OUT_ROOTFS" \
- --size "$SIZE_SPEC" \
- --base-rootfs "$BASE_ROOTFS" \
- --docker
+ log "building $OUT_ROOTFS from $BASE_ROOTFS"
+ exec "$DIR/customize.sh" "$BASE_ROOTFS" \
+ --out "$OUT_ROOTFS" \
+ --size "$SIZE_SPEC" \
+ --docker