# HG changeset patch # User John Floren # Date 1320187935 25200 # Node ID 125d8d35ad609d4b2b967b4f1510ae4f58852ef0 # Parent 03c575d34cbb4bbd08337d6f2b5f8af3d861953a runusb: Simple proto file to copy in the full tree with appropriate permissions plan9.ini: Tweaked to help boot from flash drives libboot.a8: This shouldn't be in the repo mkfile: Shouldn't die if we can't copy over gone.fishing, it's just not important! mknixboot: a script to help build a bootable Nix USB stick (not done yet). These changes were made while I tried to get Nix booting from a USB stick. So far I've been able to boot 9pcf and mk install in /sys/src as well as build a kernel. For my next trick, booting into a Nix kernel (I hope). R=nixiedev, rminnich CC=nix-dev http://codereview.appspot.com/5323064 diff -r 03c575d34cbb -r 125d8d35ad60 sys/lib/sysconfig/proto/runusb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/lib/sysconfig/proto/runusb Tue Nov 01 15:52:15 2011 -0700 @@ -0,0 +1,86 @@ +# fossil file system for installing from usb + +# files like NOTICE +* - sys sys + +# adm owns adm +adm - adm adm + + - adm adm + +# upas owns mail +mail - upas upas + box - upas upas + glenda - glenda glenda + + - glenda glenda + fs - upas upas + lib - upas upas + + - upas upas + queue - upas upas + tmp - upas upas + +# glenda owns her home directory +usr - sys sys + glenda - glenda glenda + + - glenda glenda + +# architectures are owned by sys +386 - sys sys + + - sys sys +68000 - sys sys + + - sys sys +68020 - sys sys + + - sys sys +alpha - sys sys + + - sys sys +amd64 - sys sys + + - sys sys +arm - sys sys + + - sys sys +mips - sys sys + + - sys sys +power - sys sys + + - sys sys +power64 - sys sys + + - sys sys +sparc - sys sys + + - sys sys +sparc64 - sys sys + + - sys sys + +# everything else is owned by sys +acme - sys sys + + - sys sys +cfg - sys sys + + - sys sys +contrib - sys sys + + - sys sys +cron - sys sys + upas - upas sys + + - upas sys +# these are in #/ +#fd - sys sys +# + - sys sys +#env - sys sys +# + - sys sys +lib - sys sys + + - sys sys +lp - sys sys + + - sys sys +mnt - sys sys + + - sys sys +n - sys sys + + - sys sys +rc - sys sys + + - sys sys +sys - sys sys + + - sys sys +tmp - sys sys + + - sys sys + +# distribution metadata +dist - sys sys + replica - sys sys + kfs - sys sys + cd - sys sys + network - sys sys + plan9.proto - sys sys diff -r 03c575d34cbb -r 125d8d35ad60 sys/lib/sysconfig/usb/plan9.ini --- a/sys/lib/sysconfig/usb/plan9.ini Mon Oct 31 12:28:55 2011 -0700 +++ b/sys/lib/sysconfig/usb/plan9.ini Tue Nov 01 15:52:15 2011 -0700 @@ -1,9 +1,10 @@ -console=0 +console=cga -bootfile=sdB0!9fat!9pccpuf.gz +bootfile=sdB0!9fat!9pcf nobootprompt=local!/dev/sdXX/fossil nvram=/dev/sdXX/nvram debugboot=1 *nodumpstack=1 *noe820print=1 +*nomp=1 diff -r 03c575d34cbb -r 125d8d35ad60 sys/src/9/boot/libboot.a8 Binary file sys/src/9/boot/libboot.a8 has changed diff -r 03c575d34cbb -r 125d8d35ad60 sys/src/cmd/upas/misc/mkfile --- a/sys/src/cmd/upas/misc/mkfile Mon Oct 31 12:28:55 2011 -0700 +++ b/sys/src/cmd/upas/misc/mkfile Tue Nov 01 15:52:15 2011 -0700 @@ -9,7 +9,7 @@ install:V: mail go.fishing gone.msg gone.fishing cp mail go.fishing /rc/bin - cp gone.msg gone.fishing /mail/lib + cp gone.msg gone.fishing /mail/lib || echo 'Unable to copy gone.msg and gone.fishing to /mail/lib. This may not be important.' safeinstall:V: install diff -r 03c575d34cbb -r 125d8d35ad60 usr/glenda/mknixboot --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/glenda/mknixboot Tue Nov 01 15:52:15 2011 -0700 @@ -0,0 +1,95 @@ +#!/bin/rc +# mknixboot - make a bootable standalone plan 9 image to copy to a usb disk. +# +# due to name clashes in /srv, will only work on a machine +# without a fossil named `fossil' already running. + +rfork en +srcroot=/n/boot +syscfg=/sys/lib/sysconfig +proto=$syscfg/proto/allproto +quantum=1000000 +# size of image in $quantum-byte units. 1900 is enough for production system +# (fs, /n/boot, ~1.2GB); 900 is ample for our install image +# (sources, /n/sources/plan9, ~370MB). +size=1900 + +# by default we shall use /$objtype/9load, but you don't have to +loader=/$objtype/9load + +fn usage { + echo usage: $argv0 '[-p proto] [-r root] [-s 10⁶-bytes]' >[1=2] + exit usage +} + +fn sigint sighup sigterm { + rm -f /tmp/9load + exit note +} + +# figure out which kernel to use +switch ($objtype) { +case 386 + k=/$objtype/9pcf +case amd64 + k=/$objtype/9k8cpu +case * + echo $0: 'can''t cope with architecture' $objtype >[1=2] + exit unknown-arch +} + +# process arguments +done=0 +argv0=$0 +while (~ $done 0 && ! ~ $#* 0 && ~ $1 -*) { + switch ($1) { + case -k; k=$2; shift + case -l; loader=$2; shift + case -p; proto=$2; shift + case -r; srcroot=$2; shift + case -s; size=$2; shift + case --; done=1 # no break in rc, alas + case -*; usage + } + shift +} + +if (! ~ $#* 0) + usage + +# special case sources +if (~ $srcroot /n/*) + srcfs=`{ echo $srcroot | sed 's;^/n/([^/]+).*;\1;' } +if (~ $srcfs sources) + size=900 + +# make empty disk image file of maximum size +echo -n 'image: ' >[1=2] +dd -ibs $quantum -obs $quantum -oseek `{hoc -e $size'-1'} -count 1 -quiet 1 \ + image + +# partition it +disk/partfs image +cd /dev/sdXX + +# prep it: lay down mbr, fdisk partitions, 9 partitions +echo -n mbr+fdisk+prep... >[1=2] +disk/mbr -m /$objtype/mbr data +disk/fdisk -baw data +#disk/prep -bw -a^(9fat nvram fscfg fossil) plan9 >/dev/null +disk/prep -bw -a^(9fat nvram fossil) plan9 >/dev/null + +# populate 9fat, nvram, fsconfig +echo -n 9fat... >[1=2] +cp $loader /tmp/9load # force format to use the name `9load' +disk/format -b /$objtype/pbslba -d -r 2 9fat /tmp/9load $k \ + $syscfg/usb/plan9.ini >[2=1] | + grep -v '^(add .* at clust |Init|type |Adding file|used )' +cp /dev/zero nvram >[2]/dev/null +#cp /dev/zero fscfg >[2]/dev/null +rm -f /tmp/9load + +# fill the fossil +9fs $srcfs +echo -n load fossil... >[1=2] +exec loadfossil /dev/sdXX/fossil $srcroot $proto $syscfg/usb/fossil.conf