9front - general discussion about 9front
 help / color / mirror / Atom feed
* mkusb
@ 2012-05-07  3:44 sl
  2012-05-07  5:25 ` mkusb Jens Staal
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: sl @ 2012-05-07  3:44 UTC (permalink / raw)
  To: 9front

NAME
	mkusb - create a bootable USB device

DESCRIPTION
	This script will make bootable a USB device. If the 9fat
	partition is made large enough, the entire 9front.iso may
	be copied into the root of the partition and used to boot
	a stand alone terminal.

SYNOPSIS
	mkusb [-dw] device

OPTIONS
	-d	create the bootable device
	-w	wipe the device

SEE ALSO
	prep(8), /sys/src/boot/pc/mkfile

-sl

---

#!/bin/rc

# create bootable usb

fn logprog{ 
        echo $"*
        $*
} 

fn dev{
	dev=$1
	cd /sys/src/boot/pc && mk 9bootfat mbr pbs
	dev/mbr -m mbr $dev/data
	dev/fdev -baw $dev/data
	echo
	echo 'This is dev/prep; use it to create a 9fat partition.'
	echo 'NOTE: FAT16 partitions such as 9fat are limited to 2GB.'
	echo 'When finished, type ''w'' and then ''q''.'
	echo
	dev/prep -b $dev/plan9
	dev/format -b pbs -d -r 2 $dev/9fat
	dossrv -f $dev/9fat usb.dos
	mount -c /srv/usb.dos /n/usb.9fat
	{
		echo 'bootfile=/$cputype/9pcf'
		echo 'mouseport=ask'
		echo 'monitor=ask'
		echo 'vgasize=ask'
	} >/n/usb.9fat/plan9.ini
	logprog cp 9bootfat /n/usb.9fat
	logprog mkdir /n/usb.9fat/$cputype
	logprog cp /$cputype/9pcf /n/usb.9fat/$cputype
	unmount /n/usb.9fat
	rm -f /srv/usb.dos
}

fn wipe{
	dev=$1
	echo 'echo delpart plan9 >'$"dev'/ctl'
	echo delpart plan9 >$dev/ctl >[2]/dev/null
	echo 'echo delpart 9fat >'$"dev'/ctl'
	echo delpart 9fat >$dev/ctl >[2]/dev/null
	logprog dd -if /dev/zero -of $dev/data -bs 51dev -count 4
}

fn usage{
	echo usage: $0 [ -d device ] [ -w device ] >[1=2]
	exit usage
}

if(! ~ $1 -* || ~ $#2 0)
	usage

switch($1){
case -d
	dev $2
case -w
	wipe $2
case *
	usage
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-08  1:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-07  3:44 mkusb sl
2012-05-07  5:25 ` mkusb Jens Staal
2012-05-07  7:36 ` mkusb cinap_lenrek
2012-05-07 20:04   ` mkusb sl
2012-05-07  8:07 ` mkusb cinap_lenrek
2012-05-08  1:21   ` mkusb sl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).