Skip to content

Commit

Permalink
added bootable flag toggle and more extlinux sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick committed May 15, 2012
1 parent 5a017c3 commit 156d85c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions etc/webc/install-to-disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ find_disk() {
partition_disk() {
local disk="$1"
_logs "partitioning ${disk}"
cat<<EOF | sed -e "s#DISK#${disk}#" |/sbin/sfdisk $disk
unit: sectors
DISK1 : start= 2048, Id=83, bootable
/sbin/sfdisk $disk <<EOF
,,L,*
EOF
}
verify_partition() {
Expand All @@ -45,7 +43,7 @@ verify_extlinux_mbr() {
local disk="$1"
_logs "verifying mbr on ${disk}"
a=$( md5 < /usr/lib/extlinux/mbr.bin )
b=$( dd if=$disk bs=440 count=1 2>/dev/null | md5 )
b=$( dd if=$disk bs=440c count=1 2>/dev/null | md5 )
test "$a" = "$b" && return 0
return 1
}
Expand All @@ -54,11 +52,17 @@ install_extlinux() {
local part="$2"
local disk="$3"
_logs "installing extlinux to ${dir}"
extlinux --install ${dir}
test -e ${dir}/ldlinux.sys || _err "extlinux install failed"
rm -f ${dir}/boot.txt
for d in dev proc sys; do
mount --bind /$d /mnt/root/$d
done
_logs "installing mbr to ${disk}"
dd if=/usr/lib/extlinux/mbr.bin of="$disk"
chroot /mnt/root extlinux-install $disk
chroot /mnt/root extlinux --install /boot/extlinux
for d in dev proc sys; do
umount /mnt/root/$d
done
test -e ${dir}/ldlinux.sys || _err " no ${dir}/ldlinux.sys?"
rm -f ${dir}/boot.txt

cat<<EOF >> ${dir}/linux.cfg
Expand All @@ -68,7 +72,7 @@ label fail
EOF

sed -i \
-e 's/^\(prompt\).*/\1 1/' \
-e 's/^\(prompt\).*/\1 0/' \
-e 's/^\(timeout\).*/\1 50/' \
-e 's/^\(display\).*//' \
${dir}/extlinux.conf
Expand Down Expand Up @@ -144,6 +148,7 @@ verify_extlinux_mbr $disk || {
}

_logs "umount'ing partitions"
cd /
umount /mnt/root
_logs "install complete"
if cmdline_has debug; then
Expand Down

1 comment on commit 156d85c

@kaihendry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me in Virtualbox. Great stuff. :)

Please sign in to comment.