Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Virtual disk with Fossil and Venti on Harvey

Graham MacDonald edited this page Jun 10, 2018 · 19 revisions

Creating a Harvey OS image (WIP!)

This page will show you how to set up a Harvey OS image with a Fossil/Venti disk.

We want to create a qcow2 image with 2 partitions - an ext4 Linux partition for the syslinux bootloader and the Harvey kernel, and a Plan 9 partition for all other use by Harvey.

There are several ways to build this, but we will be using a script that depends on guestfish, so the first step is to install that. The method depends on your OS, but for Fedora Linux you would run:

sudo dnf install libguestfs

Before building the image, you should have built Harvey. Assuming you've done that, you can create your qcow2 image by running:

./util/build-img.sh

This will have created a file named harvey.qcow2 in $HARVEY. This contains the partitions as described above, syslinux, and the most recent Harvey kernel you've built. Currently, if you rebuild the kernel, you need to rerun build-img.sh to replace the image. It doesn't update, so you will lose any changes you made. This process will be improved.

Then it's all ready now to boot into Harvey with our new blank disk.

Setting up Fossil + Venti from Harvey

To boot Harvey your new image:

./util/GO9PIMG

We now need to set up the plan 9 partitions. In a terminal in Harvey, enter the commands beginning with a '#'. You'll see the expected response below each command line:

# disk/prep -w -a^(nvram fossil arenas bloom isect) /dev/sdE0/plan9
nvram 1
fossil 2548768
arenas 12743843
isect 637192
bloom 637193

Doesn't matter if this numbers are not equal to yours. Now let's go to set up venti.

# venti=127.0.0.1

# venti/fmtarenas arenas0 /dev/sdE0/arenas
fmtarenas /dev/sdE0/arenas: 13 arenas, 6,524,051,456 bytes storage, 524,288 bytes for index map
# venti/fmtisect isect0 /dev/sdE0/isect
fmtisect /dev/sdE0/isect: 39,727 buckets of 215 entries, 524,288 bytes for index map

# venti/fmtindex /util/img/venti.conf
fmtindex: 13 arenas, 39,727 index buckets, 6,523,838,464 bytes storage
# venti/conf -w /dev/sdE0/arenas < /util/img/venti.conf
"WE ARE ASSUMING YOUR CONFIG IS LESS THAN 8k. IF NOT, THINGS WILL GO BADLY"
# venti/venti -c /dev/sdE0/arenas
2015/1120 23:46:17 venti: conf...venti/venti: mem 2,236,962 bcmem 4,473,924 icmem 6,710,886...init...icache  6,710,886 bytes = 66,728 entries; 4 scache
sync...announce tcp!127.0.0.1!venti...serving.

-----Below needs to be updated-----


Without it you will get dragons... continuing.

# fossil/flfmt /dev/sdE0/fossil

You can do this file from linux and putting it into your ufs root or you can use ed as we show you with venti some lines ago, do you remember?

# cat /tmp/flproto
srv -p fscons
srv fossil
fsys main config /dev/sdE0/fossil
fsys main open -AWP
fsys main

# fossil/conf -w /dev/sdE0/fossil < /tmp/flproto
# fossil/fossil -f /dev/sdE0/fossil
fsys: dialing venti at net!127.0.0.1!venti

Now we have the servers:

# ls /srv
/srv/boot
/srv/cs
/srv/dns
/srv/factotum
/srv/fossil
/srv/fscons
/srv/screenconsole
/srv/slashn

So let's go to connect to file server console and make some magic things:

# con /srv/fscons
prompt: fsys main
main: create /active/adm adm sys d775
main: create /active/adm/users adm sys 664
main: users -w
nuser 5 len 84
main: ^\ **<- this is ctrl+\**
main: >>> quit

Now you'll have:

# ls /srv
/srv/boot
/srv/cs
/srv/dns
/srv/factotum
/srv/fossil
/srv/fscons
/srv/screenconsole
/srv/slashn
# mount -c /srv/fossil /n/fossil
# ls /n/fossil
/n/fossil/adm

Nice, isn't it? let's go to copy Harvey's binaries to test the disk:

# cd /n/fossil
# mkdir amd64
# cd amd64
# dircp /root/amd64 .
# ls /root/amd64
/root/amd64/bin
/root/amd64/include
/root/amd64/lib
/root/amd64/mkfile.clang
/root/amd64/tmp

OK, let's reboot but first let's do a snapshot:

# con /srv/fscons
prompt: sn^U
main: snap -a
archive vac:128d4b0cabb0d74f54940651a3119d9fba5a6eb4

main: >>> quit

The vac line means the snapshot is done.

read tcp 192.168.28.128:49848->192.168.28.129:1522: read: connection reset by peer

Just turn off it.

Assuming you rebooted Harvey using params you saw before and connecting against your ufs server, let's go to see what we should do to mount our venti/fossil mess manually:

# cat /tmp/disk
disk/fdisk -p /dev/sdE0/data > /dev/sdE0/ctl
disk/prep -p /dev/sdE0/plan9 > /dev/sdE0/ctl
venti/venti -c /dev/sdE0/arenas
venti=127.0.0.1
fossil/fossil -f /dev/sdE0/fossil

And let's go to do it:

# ls /dev/sdE0
/dev/sdE0/ctl
/dev/sdE0/data
/dev/sdE0/raw
# disk/fdisk -p /dev/sdE0/data > /dev/sdE0/ctl
# ls /dev/sdE0
/dev/sdE0/ctl
/dev/sdE0/data
/dev/sdE0/plan9
/dev/sdE0/raw
# disk/prep -p /dev/sdE0/plan9 > /dev/sdE0/ctl
# ls /dev/sdE0
/dev/sdE0/9fat
/dev/sdE0/arenas
/dev/sdE0/bloom
/dev/sdE0/ctl
/dev/sdE0/data
/dev/sdE0/fossil
/dev/sdE0/isect
/dev/sdE0/nvram
/dev/sdE0/plan9
/dev/sdE0/raw

Conclusion: the partitions you see are in the driver not on the disk, as you are acustomed.

# venti=127.0.0.1
# venti/venti -c /dev/sdE0/arenas
2015/1120 23:37:58 venti: conf...venti/venti: mem 2,236,962 bcmem 4,473,924 icmem 6,710,886...init...icache 6,710,886 bytes = 66,728 entries; 4 scache
sync...2015/1120 23:37:59 arenas00: indexing 20416 clumps...
announce tcp!127.0.0.1!venti...serving.
# fossil/fossil -f /dev/sdE0/fossil
fsys: dialing venti at net!127.0.0.1!venti
# mount /srv/fossil /n/fossil
# ls /n/fossil
/n/fossil/adm
/n/fossil/amd64
# du -a /n/fossil | wc
    437     874   14755
# echo it is all there.

Hey, they are all there.

Now to make the disk bootable and usable as system disk, you must copy entire tree from git repo and add harvey user to fossil.

If you arrived here, thanks for your patience and enjoy! Harvey's core team is working to make all of this better and less hellish. And researching new file servers. Come and help us :-)!