clean up x86-2.6 partitioning stuff
SVN-Revision: 5705
This commit is contained in:
parent
cf52f51b85
commit
75e5315f5f
2 changed files with 19 additions and 42 deletions
|
@ -56,7 +56,3 @@ define Image/Build
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildImage))
|
$(eval $(call BuildImage))
|
||||||
|
|
||||||
$(eval $(call RequireCommand,fdisk, \
|
|
||||||
Please install fdisk \
|
|
||||||
))
|
|
||||||
|
|
|
@ -1,58 +1,39 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Copyright (C) 2006 OpenWrt.org
|
# Copyright (C) 2006 OpenWrt.org
|
||||||
|
set -x
|
||||||
[ $# == 5 ] || {
|
[ $# == 5 ] || {
|
||||||
echo "SYNTAX: $0 <file> <kernel size> <kernel directory> <rootfs size> <rootfs image>"
|
echo "SYNTAX: $0 <file> <kernel size> <kernel directory> <rootfs size> <rootfs image>"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
file="$1"
|
OUTPUT="$1"
|
||||||
part1s="$2"
|
KERNELSIZE="$2"
|
||||||
part1d="$3"
|
KERNELDIR="$3"
|
||||||
part2s="$4"
|
ROOTFSSIZE="$4"
|
||||||
part2f="$5"
|
ROOTFSIMAGE="$5"
|
||||||
|
|
||||||
|
rm -f "$OUTPUT"
|
||||||
|
|
||||||
head=16
|
head=16
|
||||||
sect=63
|
sect=63
|
||||||
cyl=$(( ($part1s + $part2s) * 1024 * 1024 / ($head * $sect * 512)))
|
cyl=$(( ($KERNELSIZE + $ROOTFSSIZE) * 1024 * 1024 / ($head * $sect * 512)))
|
||||||
|
|
||||||
dd if=/dev/zero of="$file" bs=1M count=$(($part1s + $part2s)) 2>/dev/null || exit
|
# create partition table
|
||||||
fdisk -u -C $cyl -H $head -S $sect "$file" > /dev/null 2>/dev/null <<EOF
|
set `ptgen -o "$OUTPUT" -h $head -s $sect -p ${KERNELSIZE}m -p ${ROOTFSSIZE}m`
|
||||||
n
|
|
||||||
p
|
|
||||||
1
|
|
||||||
|
|
||||||
+$(($part1s * 1024))K
|
KERNELOFFSET="$(($1 / 512))"
|
||||||
n
|
ROOTFSOFFSET="$(($2 / 512))"
|
||||||
p
|
|
||||||
2
|
|
||||||
|
|
||||||
|
BLOCKS="$((($ROOTFSOFFSET - $KERNELOFFSET) / 2 - 1))"
|
||||||
|
|
||||||
w
|
genext2fs -d "$KERNELDIR" -b "$BLOCKS" "$OUTPUT.kernel"
|
||||||
q
|
dd if="$OUTPUT.kernel" of="$OUTPUT" bs=512 seek="$KERNELOFFSET" conv=notrunc
|
||||||
EOF
|
dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc
|
||||||
|
#rm -f "$OUTPUT.kernel"
|
||||||
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 ))"
|
|
||||||
|
|
||||||
genext2fs -d "$part1d" -b "$blocks" "$file.kernel"
|
|
||||||
dd if="$file.kernel" of="$file" bs=512 seek="$(($start / 512))" conv=notrunc
|
|
||||||
rm -f "$file.kernel"
|
|
||||||
|
|
||||||
start="$(block 2 0)"
|
|
||||||
dd if="$part2f" of="$file" bs=512 seek="$(($start / 512))" conv=notrunc
|
|
||||||
|
|
||||||
which chpax >/dev/null && chpax -zp $(which grub)
|
which chpax >/dev/null && chpax -zp $(which grub)
|
||||||
grub --device-map=/dev/null <<EOF
|
grub --device-map=/dev/null <<EOF
|
||||||
device (hd0) $file
|
device (hd0) $OUTPUT
|
||||||
geometry (hd0) $cyl $head $sect
|
geometry (hd0) $cyl $head $sect
|
||||||
root (hd0,0)
|
root (hd0,0)
|
||||||
setup (hd0)
|
setup (hd0)
|
||||||
|
|
Loading…
Reference in a new issue