9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Raspberry Pi installer surrogate
@ 2014-08-12 21:41 dante
  2014-08-12 21:49 ` Jacob Todd
  0 siblings, 1 reply; 4+ messages in thread
From: dante @ 2014-08-12 21:41 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1280 bytes --]

Dear 9ers,

Here is my first contribution.

AFAIK, there is no installer yet for the Rasbperry Pi port.
Moreover, the Raspberry Pi can only boot from the one SD card (not from
USB).
This makes the classical installer design (boot from a removable
device, install on the fixed disk) impractical.

A solution would be to start with a given installation (e.g., Richard
Miller's bootable image), use an SD-to-USB adapter and clone the disk.
This has the following advantages:
- the new disk can be used at full capacity (not only 2GB or so in the
original image);
- the installation can be done without the need of an additional system
    (a PC to write the image or even a virtual machine as proposed by
9front https://code.google.com/p/plan9front/wiki/9pi)

The attached script clones a Raspberry Pi Plan9 Fossil installation to
an SD disk connected via such a USB adapter.
If the device is recognised as "sdUXX", call "piclone sdUXX".

I have no idea where this utility belongs to.
It is IMHO too specific to be placed under arm/bin.
For this reason, I attach the file in stead of sending a patch(1).
I hope it helps and it will find it's way into Plan9 (or at least to
Mr. Miller's image :-).

DISCLAIMER: There might be bugs.

Kind Regards,
Dante

[-- Attachment #2: piclone --]
[-- Type: text/plain, Size: 5510 bytes --]

#!/bin/rc
#
# This program clones a Raspberry Pi Plan9 installation onto another storage device.
# Use a USB adapter for SD cards in order to write another SD card.
# The storage device will be used at its full capacity, in contrast to the downloadable image.
# Moreover, no additional computer is required for the installation.
#
# This program makes some assumptions that are specific to the Raspberry Pi device.
# The only parameter is the name of the destination drive.
# The program will not ask for further input.
#
# NOTES
#
# You can of course use the USB adapter for SD cards to write the downloadable image.
# The bootstrap cannot access a DOS partition embedded into a Plan9 partition (9fat).
# The sd(3) driver cannot serve volumes from a partition table: we use partfs(8) instead.
# Con(1) needs a certain number of empty lines in the input in order to read all server answers.
#

fn check {
	if( ! ~ $1 '' ) {
		echo We encountered an error and must stop here.
		echo Status: $1.
		exit 13
	}
}

if(! test $#* -eq 1) {
	echo Usage: '''piclone sdUY.Z''' creates a Raspberry9 system on sdUY.Z. 
	exit
}

disk=$1
if(! test -d /dev/$disk) {
	echo No such device: $disk.
	exit
}

# Make shure there is no disk configuration left.
echo ........ Null the disk configuration.
dd -if /dev/zero -of /dev/$disk/data -count 1024 >[1=] >[2=]
check $status

# the default MBR without boot code suffices for the Pi.
echo ........ Install MBR.
disk/mbr /dev/$disk/data >[1=] >[2=]
check $status

# We need a real DOS partition.
# The Raspberry Pi boot mechanism cannot cope with the 9FAT partition embedded in the plan9 one.
echo ........ Create DOS partition for booting.
disk/fdisk -b /dev/$disk/data >[1=] >[2=] <<EOF
a p0 0 16
t p0 FAT32
A p0
w
q
EOF
check $status

echo ........ Create a Plan9 partition with default parameters.
disk/fdisk -wa /dev/$disk/data >[1=] >[2=]
check $status

# sd(3) does not serve disk partitions: use partfs(8).
if( ! test -e /dev/$disk/dos ) {
	echo ........ Start partfs to serve partitions.
	disk/partfs -d $disk /dev/$disk/data >[1=] >[2=]
	check $status
}

echo ........ Reconfigure device.
disk/fdisk -p /dev/$disk/data >/dev/$disk/ctl >[2=]
check $status

echo ........ Plan9 partition: install MBR.
disk/mbr /dev/$disk/plan9 >[1=] >[2=]
check $status

echo ........  Plan9 partition: subdivide.
disk/prep -wb -a nvram -a fossil /dev/$disk/plan9 >[1=] >[2=]
check $status

echo ........  Plan9 partition: reconfigure device.
disk/prep -p /dev/$disk/plan9 >/dev/$disk/ctl >[2=]
check $status
echo Partitions on $disk:
cat /dev/$disk/ctl

echo ........  Format DOS partition.
disk/format -d -r2 /dev/$disk/dos >[1=] >[2=]
check $status

echo ........ Format Fossil partition.
fossil/flfmt -y /dev/$disk/fossil >[1=] >[2=]
check $status

if( ! test -e /srv/dos ){
	echo ........ Start DOS server.
	dossrv >[1=] >[2=]
	check $status
}

echo ........ Start server for old Fossil partition.
cat >/env/flproto <<EOF
srv -p fscons.old
srv fossil.old
fsys main config /dev/sdM0/fossil
fsys main open -aAVP
fsys main
EOF
fossil/fossil -c '. /env/flproto' >[1=] >[2=]
check $status

echo ........ Start server for new Fossil partition.
cat >/env/flproto <<EOF
srv -p fscons.new
srv fossil.new
fsys main config /dev/$disk/fossil
fsys main open -aAVWP
fsys main
EOF
fossil/fossil -c '. /env/flproto' #>[1=] >[2=]
check $status

echo ........ Mount old DOS partition.
mount -c /srv/dos /n/dos.old /dev/sdM0/dos >[1=] >[2=]
check $status

echo ........ Mount new DOS partition.
mount -c /srv/dos /n/dos.new /dev/$disk/dos >[1=] >[2=]
check $status

echo ........ Mount old Fossil partition.
mount -c /srv/fossil.old /n/fossil.old >[1=] >[2=]
check $status

echo ........ Mount new Fossil partition.
mount -c /srv/fossil.new /n/fossil.new >[1=] >[2=]
check $status

echo ........ Create users file on new Fossil partition.

# create default
con /srv/fscons.new >[1=] >[2=] <<EOF

create /active/adm adm sys d775
EOF
check $status

# copy
cp -gux /n/fossil.old/adm/users /n/fossil.new/adm/users
check $status

con /srv/fscons.new >[1=] >[2=] <<EOF

users -r /active/adm/users


EOF
check $status

echo ........ Copy boot files.
cp -gux /n/dos.old/* /n/dos.new >[1=] >[2=]
check $status

echo ........ Copy system: please be VERY patient.
disk/mkfs  -a -s /n/fossil.old /sys/lib/sysconfig/proto/allproto  | disk/mkext -u -v -d /n/fossil.new >[2=1]  | tee /tmp/xxx
echo ........ Status: $status.

echo ........ Unmount old DOS partition.
unmount /n/dos.old >[1=] >[2=]
check $status

echo ........ Unmount new DOS partition.
unmount /n/dos.new >[1=] >[2=]
check $status

echo ........ Unmount old Fossil partition.
unmount /n/fossil.old >[1=] >[2=]
check $status

echo ........ Stop server for old Fossil partition.
con /srv/fscons.old >[1=] >[2=] <<EOF
srv -d fossil.old
srv -d fscons.old
EOF
check $status

echo ........ Unmount new Fossil partition.
unmount /n/fossil.new >[1=] >[2=]
check $status

echo ........ Stop server for new Fossil partition.
con /srv/fscons.new >[1=] >[2=] <<EOF
srv -d fossil.new
srv -d fscons.new
EOF
check $status

echo ......... Kill fossil.
kill fossil | rc >[1=] >[2=]
rm /srv/fossil.old >[1=] >[2=]
rm /srv/fscons.old >[1=] >[2=]
rm /srv/fossil.new >[1=] >[2=]
rm /srv/fscons.new >[1=] >[2=]

echo ........ Write persistent Fossil configuration.
fossil/conf -w /dev/$disk/fossil >[1=] >[2=]  <<EOF
fsys main config
fsys main open -aAV
fsys main snaptime -a none -s 60 -t 172800
fsys main
users -r /active/adm/users
EOF
check $status

echo ........ DONE

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

* Re: [9fans] Raspberry Pi installer surrogate
  2014-08-12 21:41 [9fans] Raspberry Pi installer surrogate dante
@ 2014-08-12 21:49 ` Jacob Todd
  2014-08-12 22:07   ` dante
  0 siblings, 1 reply; 4+ messages in thread
From: Jacob Todd @ 2014-08-12 21:49 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1440 bytes --]

I used dd and the 9front img.
On Aug 12, 2014 5:43 PM, "dante" <subscriptions@posteo.eu> wrote:

> Dear 9ers,
>
> Here is my first contribution.
>
> AFAIK, there is no installer yet for the Rasbperry Pi port.
> Moreover, the Raspberry Pi can only boot from the one SD card (not from
> USB).
> This makes the classical installer design (boot from a removable device,
> install on the fixed disk) impractical.
>
> A solution would be to start with a given installation (e.g., Richard
> Miller's bootable image), use an SD-to-USB adapter and clone the disk.
> This has the following advantages:
> - the new disk can be used at full capacity (not only 2GB or so in the
> original image);
> - the installation can be done without the need of an additional system
>    (a PC to write the image or even a virtual machine as proposed by
> 9front https://code.google.com/p/plan9front/wiki/9pi)
>
> The attached script clones a Raspberry Pi Plan9 Fossil installation to an
> SD disk connected via such a USB adapter.
> If the device is recognised as "sdUXX", call "piclone sdUXX".
>
> I have no idea where this utility belongs to.
> It is IMHO too specific to be placed under arm/bin.
> For this reason, I attach the file in stead of sending a patch(1).
> I hope it helps and it will find it's way into Plan9 (or at least to Mr.
> Miller's image :-).
>
> DISCLAIMER: There might be bugs.
>
> Kind Regards,
> Dante

[-- Attachment #2: Type: text/html, Size: 1836 bytes --]

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

* Re: [9fans] Raspberry Pi installer surrogate
  2014-08-12 21:49 ` Jacob Todd
@ 2014-08-12 22:07   ` dante
  2014-08-12 22:10     ` Jacob Todd
  0 siblings, 1 reply; 4+ messages in thread
From: dante @ 2014-08-12 22:07 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

You got a huge 2GB disk.
Moreover, you probably needed an additional PC.

Cheers!

On 12.08.2014 23:49, Jacob Todd wrote:
> I used dd and the 9front img.
> On Aug 12, 2014 5:43 PM, "dante" <subscriptions@posteo.eu> wrote:
> 
>> Dear 9ers,
>> 
>> Here is my first contribution.
>> 
>> AFAIK, there is no installer yet for the Rasbperry Pi port.
>> Moreover, the Raspberry Pi can only boot from the one SD card (not 
>> from USB).
>> This makes the classical installer design (boot from a removable 
>> device, install on the fixed disk) impractical.
>> 
>> A solution would be to start with a given installation (e.g., Richard 
>> Miller's bootable image), use an SD-to-USB adapter and clone the disk.
>> This has the following advantages:
>> - the new disk can be used at full capacity (not only 2GB or so in 
>> the original image);
>> - the installation can be done without the need of an additional 
>> system
>>    (a PC to write the image or even a virtual machine as proposed by 
>> 9front https://code.google.com/p/plan9front/wiki/9pi [1])
>> 
>> The attached script clones a Raspberry Pi Plan9 Fossil installation 
>> to an SD disk connected via such a USB adapter.
>> If the device is recognised as "sdUXX", call "piclone sdUXX".
>> 
>> I have no idea where this utility belongs to.
>> It is IMHO too specific to be placed under arm/bin.
>> For this reason, I attach the file in stead of sending a patch(1).
>> I hope it helps and it will find it's way into Plan9 (or at least to 
>> Mr. Miller's image :-).
>> 
>> DISCLAIMER: There might be bugs.
>> 
>> Kind Regards,
>> Dante
> 
> 
> Links:
> ------
> [1] https://code.google.com/p/plan9front/wiki/9pi



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

* Re: [9fans] Raspberry Pi installer surrogate
  2014-08-12 22:07   ` dante
@ 2014-08-12 22:10     ` Jacob Todd
  0 siblings, 0 replies; 4+ messages in thread
From: Jacob Todd @ 2014-08-12 22:10 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 225 bytes --]

On Aug 12, 2014 6:09 PM, "dante" <subscriptions@posteo.eu> wrote:
>
> You got a huge 2GB disk.
> Moreover, you probably needed an additional PC.
>
I think it's a 32gb sd card but I pxe boot from my cpu/fs.

> Cheers!

[-- Attachment #2: Type: text/html, Size: 369 bytes --]

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

end of thread, other threads:[~2014-08-12 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-12 21:41 [9fans] Raspberry Pi installer surrogate dante
2014-08-12 21:49 ` Jacob Todd
2014-08-12 22:07   ` dante
2014-08-12 22:10     ` Jacob Todd

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