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

* Re: mkusb
  2012-05-07  3:44 mkusb sl
@ 2012-05-07  5:25 ` Jens Staal
  2012-05-07  7:36 ` mkusb cinap_lenrek
  2012-05-07  8:07 ` mkusb cinap_lenrek
  2 siblings, 0 replies; 6+ messages in thread
From: Jens Staal @ 2012-05-07  5:25 UTC (permalink / raw)
  To: 9front

2012/5/7  <sl@9front.org>:
> NAME
>        mkusb - create a bootable USB device
>

Nice!

I was recently trying to boot the 9front.iso with syslinux since my
CD/DVD drive on my new laptop apparently reads the CD wrong
(complaints about corrupt file system during boot). This did
unfortunately not work (no idea why - syslinux does not give any
messages as far as I can see why it does not try to boot the iso).
Otherwise that would have been a very nice way to make bootable USBs.

Now I probably should try to make a bootable USB with this tool from a
9front instance running in a VM I guess :)

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

* Re: mkusb
  2012-05-07  3:44 mkusb sl
  2012-05-07  5:25 ` mkusb Jens Staal
@ 2012-05-07  7:36 ` cinap_lenrek
  2012-05-07 20:04   ` mkusb sl
  2012-05-07  8:07 ` mkusb cinap_lenrek
  2 siblings, 1 reply; 6+ messages in thread
From: cinap_lenrek @ 2012-05-07  7:36 UTC (permalink / raw)
  To: 9front

small suggesttion to the whipe part:

dev = /dev/sdXX
...

# remove sd partitions
awk '/^part/{if($2!="data"){print "delpart "$2}}' $dev/ctl >$dev/ctl

somehow, that code got garbled. theres dev/mbr and stuff that all
do not make any sense.

for the prep stuff... why not just create a single big dos partition
with disk/fdisk? or just check if its already formated with fat32
and just install the bootloader/kernel and copy the iso? (basicly
just disk/mbr and disk/format to install pbs)

we dont really need a plan9 partition table for this. 9bootfat is
perfectly capable of just sitting in a random dos partition.

the real problem i see is that disk/format doesnt format fat32.

i dont see how this script is usb related at all. all you need for
usb boot is make a fat filesystem with bootloader+kernel in it
on a harddrive.

--
cinap

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

* Re: mkusb
  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  8:07 ` cinap_lenrek
  2012-05-08  1:21   ` mkusb sl
  2 siblings, 1 reply; 6+ messages in thread
From: cinap_lenrek @ 2012-05-07  8:07 UTC (permalink / raw)
  To: 9front

there should be a generic way of making a harddrive bootable.
then we could just use this from the installer instead of
/rc/bin/inst/bootsetup and also use it to make usb drives
bootable.

something like:

mkbootfat [-b] /dev/sdXX

the -b switch would try to make everything from scratch:
	- whipe
	- install mbr
	- make single dos partition (fdisk)
	- format the dos partition

normal procedure is like:
	- look for 9fat and dos partitions, let the user select one if multiple
      choices are present.
	- install pbs on dos partition (disk/format -b)
	- mount and copy 9bootfat+kernel+plan9.ini to dos partition
	- make dos partition active and optionally install mbr if not already done

--
cinap

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

* Re: mkusb
  2012-05-07  7:36 ` mkusb cinap_lenrek
@ 2012-05-07 20:04   ` sl
  0 siblings, 0 replies; 6+ messages in thread
From: sl @ 2012-05-07 20:04 UTC (permalink / raw)
  To: 9front

> i dont see how this script is usb related at all. all you need for
> usb boot is make a fat filesystem with bootloader+kernel in it
> on a harddrive.

Of course you're right. This started as a blunt tool for myself,
then I thought it might be useful for others.

Some of it is poorly thought out.

-sl

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

* Re: mkusb
  2012-05-07  8:07 ` mkusb cinap_lenrek
@ 2012-05-08  1:21   ` sl
  0 siblings, 0 replies; 6+ messages in thread
From: sl @ 2012-05-08  1:21 UTC (permalink / raw)
  To: 9front

> there should be a generic way of making a harddrive bootable.
> then we could just use this from the installer instead of
> /rc/bin/inst/bootsetup and also use it to make usb drives
> bootable.
>
> something like:
>
> mkbootfat [-b] /dev/sdXX
>
> the -b switch would try to make everything from scratch:
>	- whipe
>	- install mbr
>	- make single dos partition (fdisk)
>	- format the dos partition
>
> normal procedure is like:
>	- look for 9fat and dos partitions, let the user select one if multiple
>      choices are present.
>	- install pbs on dos partition (disk/format -b)
>	- mount and copy 9bootfat+kernel+plan9.ini to dos partition
>	- make dos partition active and optionally install mbr if not already done

This seems by far the best approach. I've repaired my hack of convenience,
but will aim for something general enough to be called by the installer.

-sl

^ 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).