9front - general discussion about 9front
 help / color / mirror / Atom feed
From: sl@9front.org
To: 9front@googlegroups.com
Subject: mkusb
Date: Mon, 7 May 2012 03:44:16 +0000	[thread overview]
Message-ID: <4d9c26e53ce8a3673377c6f581cd7f2a@sp.inri.net> (raw)

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
}

             reply	other threads:[~2012-05-07  3:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-07  3:44 sl [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d9c26e53ce8a3673377c6f581cd7f2a@sp.inri.net \
    --to=sl@9front.org \
    --cc=9front@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).