summaryrefslogtreecommitdiffstats
path: root/target/linux/x86-2.6/image
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2006-12-07 02:51:35 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2006-12-07 02:51:35 +0000
commita1f92f4320b0e28dc07f333bd7667d9ba57e2a5b (patch)
tree6f44118215b3cc829b1ac3235876ad81de59ed24 /target/linux/x86-2.6/image
parent19021c16ffef5393aebedf009c57a86b11b996c2 (diff)
clean up x86-2.6 partitioning stuff
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@5705 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/x86-2.6/image')
-rw-r--r--target/linux/x86-2.6/image/Makefile4
-rwxr-xr-xtarget/linux/x86-2.6/image/gen_image.sh57
2 files changed, 19 insertions, 42 deletions
diff --git a/target/linux/x86-2.6/image/Makefile b/target/linux/x86-2.6/image/Makefile
index 7aa03b2d2..7e76523d9 100644
--- a/target/linux/x86-2.6/image/Makefile
+++ b/target/linux/x86-2.6/image/Makefile
@@ -56,7 +56,3 @@ define Image/Build
endef
$(eval $(call BuildImage))
-
-$(eval $(call RequireCommand,fdisk, \
- Please install fdisk \
-))
diff --git a/target/linux/x86-2.6/image/gen_image.sh b/target/linux/x86-2.6/image/gen_image.sh
index 21deeee6a..795a46b71 100755
--- a/target/linux/x86-2.6/image/gen_image.sh
+++ b/target/linux/x86-2.6/image/gen_image.sh
@@ -1,58 +1,39 @@
#!/usr/bin/env bash
# Copyright (C) 2006 OpenWrt.org
-
+set -x
[ $# == 5 ] || {
echo "SYNTAX: $0 <file> <kernel size> <kernel directory> <rootfs size> <rootfs image>"
exit 1
}
-file="$1"
-part1s="$2"
-part1d="$3"
-part2s="$4"
-part2f="$5"
+OUTPUT="$1"
+KERNELSIZE="$2"
+KERNELDIR="$3"
+ROOTFSSIZE="$4"
+ROOTFSIMAGE="$5"
+
+rm -f "$OUTPUT"
head=16
sect=63
-cyl=$(( ($part1s + $part2s) * 1024 * 1024 / ($head * $sect * 512)))
-
-dd if=/dev/zero of="$file" bs=1M count=$(($part1s + $part2s)) 2>/dev/null || exit
-fdisk -u -C $cyl -H $head -S $sect "$file" > /dev/null 2>/dev/null <<EOF
-n
-p
-1
-
-+$(($part1s * 1024))K
-n
-p
-2
+cyl=$(( ($KERNELSIZE + $ROOTFSSIZE) * 1024 * 1024 / ($head * $sect * 512)))
+# create partition table
+set `ptgen -o "$OUTPUT" -h $head -s $sect -p ${KERNELSIZE}m -p ${ROOTFSSIZE}m`
-w
-q
-EOF
-
-block() {
- echo -e 'p\nq' | fdisk -u -C $cyl -H $head -S $sect "$file" | awk -v file="$file$1" -v n="$(($2 + 2))" '
-$1 == file {
- print $n * 512
-}'
-}
-
-start="$(block 1 0)"
-end="$(block 1 1)"
-blocks="$(( ($end - $start) / 1024 ))"
+KERNELOFFSET="$(($1 / 512))"
+ROOTFSOFFSET="$(($2 / 512))"
-genext2fs -d "$part1d" -b "$blocks" "$file.kernel"
-dd if="$file.kernel" of="$file" bs=512 seek="$(($start / 512))" conv=notrunc
-rm -f "$file.kernel"
+BLOCKS="$((($ROOTFSOFFSET - $KERNELOFFSET) / 2 - 1))"
-start="$(block 2 0)"
-dd if="$part2f" of="$file" bs=512 seek="$(($start / 512))" conv=notrunc
+genext2fs -d "$KERNELDIR" -b "$BLOCKS" "$OUTPUT.kernel"
+dd if="$OUTPUT.kernel" of="$OUTPUT" bs=512 seek="$KERNELOFFSET" conv=notrunc
+dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc
+#rm -f "$OUTPUT.kernel"
which chpax >/dev/null && chpax -zp $(which grub)
grub --device-map=/dev/null <<EOF
-device (hd0) $file
+device (hd0) $OUTPUT
geometry (hd0) $cyl $head $sect
root (hd0,0)
setup (hd0)