29 lines
937 B
Bash
Executable File
29 lines
937 B
Bash
Executable File
#!/usr/bin/env sh
|
|
# mkfs-root.sh — format/seed the target root for the chosen filesystem
|
|
# Usage: mkfs-root.sh [ext4|btrfs|xfs|zfs|f2fs]
|
|
. "$(dirname "$0")/common.sh"
|
|
|
|
FS="${1:-ext4}"
|
|
|
|
# Keru builds to a plain directory staged by Kama; the filesystem choice is
|
|
# applied at install/flash time. This script writes the fstab + initramfs
|
|
# config so the built system knows how to mount its own root.
|
|
ROOT="${ROOT:-/tmp/keru/root}"
|
|
case "$FS" in
|
|
ext4) FSTYPE=ext4; MK="mkfs.ext4" ;;
|
|
btrfs) FSTYPE=btrfs; MK="mkfs.btrfs" ;;
|
|
xfs) FSTYPE=xfs; MK="mkfs.xfs" ;;
|
|
zfs) FSTYPE=zfs; MK="zpool" ;;
|
|
f2fs) FSTYPE=f2fs; MK="mkfs.f2fs" ;;
|
|
*) die "unsupported filesystem: $FS" ;;
|
|
esac
|
|
info "target filesystem: $FSTYPE ($MK)"
|
|
|
|
# drop fstab template
|
|
mkdir -p "$ROOT/etc"
|
|
cat > "$ROOT/etc/fstab" <<EOF
|
|
# Keru generated fstab — root filesystem: $FSTYPE
|
|
# /dev/ROOT / $FSTYPE rw,relatime 0 1
|
|
EOF
|
|
info "wrote fstab for $FSTYPE"
|