[OmniOS-discuss] customizing rpool for iso install
Paul B. Henson
henson at acm.org
Wed Apr 17 22:51:18 EDT 2013
While the recommended way to customize rpool configuration is to utilize
a network install with kayak, putting together a complete dhcp/tftp/http
network install environment is a bit overkill for installing one box or
doing some testing.
So, instead I hacked together a little perl script (attached) that
interposes itself between the installer and the zpool creation allowing
some basic customizations while doing an iso install.
Boot the installer media, and pick option 3/shell prior to beginning the
install. Get the attached script into /tmp one way or another (light up
the network interface and suck it over with wget, for example) and make
it executable. Run it, and it will copy the zpool/zfs binaries into /tmp
and install itself in their place with an overlay mount.
Edit the script to configure what customizations you might want to make.
The first option is if you want to use less than the entire disk for the
rpool. If enabled, s0 on the installation device will be modified to the
size specified. The second option allows you to provide any arbitrary
zpool options to the zpool create (for example, to enable compression).
The last two options allow you to specify the size of swap/dump
explicitly rather than using the installer generated values.
Exit the shell and go back to the installer, and start the installation.
Proceed through as normal, and when it is done, the created rpool should
include the customizations you picked…
If there's any interest, I could add this to the installation section of
the wiki; unless it's deemed too kludgy to advertise ;).
-------------- next part --------------
#! /usr/bin/perl
$args = join(' ', @ARGV);
# uncomment to set size of s0 on install disk (in format syntax)
$rpool_size = '5gb';
# uncomment to add additional options for zpool create
$rpool_opts = '-O compression=lz4';
# uncomment to set swap size
#$swap_size = '512m';
# uncomment to set dump size
#$dump_size = '256m';
open(LOG, '>>/tmp/omnios_zpool_install.log');
print LOG "$0 $args\n";
if ($0 =~ /zpool$/) {
if ($args =~ /^create.* (\S+)/) {
$device = $1;
if ($rpool_size) {
$device =~ s/s0$//;
open(FH, '>/tmp/format.script');
print FH "p\n0\n\n\n\n$rpool_size\nlabel\nq\nq\n";
close(FH);
system("format -d $device -f /tmp/format.script > /tmp/format.out 2>&1");
}
if ($rpool_opts) {
$args =~ s/create -f/create -f $rpool_opts/;
}
}
print LOG "/tmp/zpool $args\n";
system("/tmp/zpool $args");
exit($? >> 8);
}
elsif ($0 =~ /zfs$/) {
if ($args =~ /^create/) {
if ($swap_size && $args =~ /swap$/) {
$args =~ s/-V .* rpool/-V $swap_size rpool/;
}
if ($dump_size && $args =~ /dump$/) {
$args =~ s/-V .* rpool/-V $dump_size rpool/;
}
}
print LOG "/tmp/zfs $args\n";
system("/tmp/zfs $args");
exit($? >> 8);
}
else {
system("cp /usr/sbin/zpool /tmp; cp /usr/sbin/zfs /tmp");
system("mount -F lofs $0 /usr/sbin/zpool");
system("mount -F lofs $0 /usr/sbin/zfs");
}
More information about the OmniOS-discuss
mailing list