Advanced Namespace Tools blog

24 December 2017

Creating a 9front-ANTS live+install CD image part 1

This has been a long time coming, but the moment has finally arrived - I've finally made a customized version of the 9front .iso which provides a live version of most of the ANTS environment and also can create a full ANTS install to disk. I'm not sure exactly why I waited so long to do this. Perhaps the profusion of build/install options already present in the build script in the repo, as well as trying to support the original Bell Labs and 9legacy distributions along with 9front made me feel like I didn't want to try to juggle yet more configuration infrastructure.

As time has gone on though, I have come to feel more and more strongly that 9front is Plan 9 and Plan 9 is 9front, and I really don't need to worry about anything other than trying to provide the most uasbility I can for any 9front users who are interested in what I'm doing. There is a lot that could be said about the historical/social factors that seem to have prevented some long-term Plan 9 users from unifying around 9front and endorsing it as the "official" continuation of the OS, but this isn't the place to write about those topics. This blog is about the code. As I prepare to release this 9front-ANTS cd image publicly, I want to make it clear that I am offering this as a contribution toward the 9front effort as a kind of testing ground for new ideas and experiments. For anyone new to Plan 9, or considering what version to try, I would recommend mainline 9front from 9front.org. Cinap, Aiju, and the other 9front developers, resource providers, and users all deserve a lot of credit and thanks for carrying Plan 9 forward.

The Forbidden Fileserver

Making your own version of the 9front iso is easy and documented in the FQA. The absolute simplest thing I could have done would have been to add the 9ants kernel to the /386 directory, change the references to 9pc in the install scripts located in /rc/bin/inst to 9ants, and add a couple ANTS-specific variables to the plan9.ini created by the inst/bootsetup script. This would have been adequate, but I wanted to make an install CD that created something closer to the full ANTS environment that I use. That means summoning the Forbidden Fileserver - Fossil.

ANTS is fully compatible with cwfs and hjfs as well, and those options remain available in the installer and you will still get the use of the full ANTS environment if you prefer them. I myself use hjfs fairly frequently, and cwfs occaisionally, and like them both a lot. So, why fossil? There are two reasons - one, I run many of my servers on small-sized Vultr instances where the hard drive is a 25gb slice of an SSD. That is too small to make use of a daily snapshotting system without the deduplicative compressed storage that Venti provides. Even just 25gb feels ample for a fossil+venti development/testing setup as long as you don't need to store lots of large files like multimedia. You can also setup a single larger instance to provide Venti service to many smaller fossil servers. The second, related reason is the power of rootscores. A venti-backed Fossil can almost instantly be re-initialized to provide any root that you have stored by using fossil/flmt -v rootscore. This makes working with a multiplicity of namespaces quick and convenient.

So, in the first install script, configfs, we offer an option for fossil and set it as default:

prompt -d fossil 'File system' fossil cwfs64x hjfs

In the prepdisk script which subdivides the Plan9 partition, we make use of autopartitioning logic which was thoughtfully left in the code and not pruned as part of removing fossil from 9front:

case fossil
	echo -a 9fat -a nvram -a fossil -a arenas -a isect

The "mountfossil" script

The major change needed is a "mountfossil" script in analogy with those for cwfs and hjfs. Rather than trying to update the old Labs script, I wrote a new one, borrowing liberally from the mountcwfs script and the "build vultrfossil" option of the ANTS build script. I originally tried to make it extra-convenient by automating the partition selection via a variable exported from the partdisk script, but I decided this wasn't optimal because it deviated from the pattern established by how mountcwfs handled it, as well as being more fragile in the case of nonstandard partitioning and/or different uses of the install cd than just clean installs.

To assist the mountfossil script, we have a few premade config files for fossil and venti, just without the specific drive identifiers. We create usable versions this way:

echo fsys main config $fs >/tmp/initfossil.conf
cat initfossil.conf >>/tmp/initfossil.conf
echo fsys main config $fs >/tmp/fossil.conf
cat fossil.conf >>/tmp/fossil.conf
echo index main >/tmp/venti.conf
echo arenas $fsarenas >>/tmp/venti.conf
echo isect $fsisect >>/tmp/venti.conf
cat venti.conf >>/tmp/venti.conf

To actually create and configure the fossil and venti, we need to navigate their interdependence gracefully. The trick is to start the fossil with a non-venti dependent configuration, and then write a different config that will not take effect until it is restarted on reboot. This way, there is no need to start venti during the install and the fossil can be populated with a copy of the distribution without it immediately trying to dump it to venti right when the install cd is being rebooted:

fossil/flfmt $fs
fossil/conf -w $fs /tmp/initfossil.conf
fossil/fossil -f $fs
mount -c /srv/fossil /n/fossil
fossil/conf -w $fs /tmp/fossil.conf
venti/fmtarenas arenas $fsarenas
venti/fmtisect isect $fsisect
venti/fmtindex /tmp/venti.conf
venti/conf -w $fsarenas /tmp/venti.conf

Other inst/ants changes

In the bootsetup script, we need to add a line to specify Venti service if the fileserver is fossil. We use #S rather than /dev here because some slightly crufty venti-related logic in the ANTS plan9rc script keys off it:

if(~ $fstype fossil)
	echo 'venti='$fsarenas |sed 's/\/dev/#S/'

The independent ANTS boot namespace runs a cpu listener on port 17060 (you can enter the standard namespace from this namespace via rerootwin -f boot) and can be fed a password via a plan9.ini variable. I added a small "pwsetup" inst script to do this:

switch($1){
case checkdone
	if(~ $#password 1)
		pwsetup=done
	if not
		pwsetup=ready
	export pwsetup
case go
	echo
	echo 'Setup Password'
	echo
	prompt 'Password: '
	password=$rd
	export password
}

Other than that, there were just a few obvious substitutions of 9ants for 9pc, and adding the ants tools.tgz to the 9fat. With these scripts in place and the necessary files available when the .iso is created, it was able to install ANTS successfully to a clean hard drive. Next blog entry: converting the CD to a live ANTS environment.