Subject: Default filesystem sizes
To: None <tech-install@netbsd.org>
From: David Brownlee <abs@anim.dreamworks.com>
List: tech-install
Date: 06/20/1999 09:44:15
	The default root and swap sizes vary significantly between sysinst
	using ports: (the code is duplicated with small alterations - some
	check the map will fit, some do not, etc):

		root		swap
alpha		128		min(32,RAM) * 2, (double if X selected)
arm32		24+2*RAM	min(32,RAM) * 2, (double if X selected)
bebox		20+2*RAM	min(16,RAM) * 2, (double if X selected)
i386		20+2*RAM	min(16,RAM) * 2, (double if X selected)
mac68k		(Looks to be taken from mac partition map)
macppc		32		min(32,RAM) * 2, (double if X selected)
pc532		20+2*RAM	min(16,RAM) * 2, (double if X selected)
pmax		32		min(32,RAM) * 2, (double if X selected)
sparc		32		min(32,RAM) * 2, (double if X selected)
vax		16		min(16,RAM) * 2, (double if X selected)

	Since we default to not having a separate /var partition, we really
	ought to look at scaling up the root partition, ideally based on
	disk size. Also we probably want to err on the side of oversizing
	root and swap on larger disks.

	I've come up with a perl script to demonstrate the new setup:

		First, ensure we can fit the min for root and /usr.
		Fit as much of ram*2 for swap as possible
		Try to allow extra ram on root for crashdump
		Split the remainder: 	1/32 to swap (clip at 8*ram)
		   			1/16 of remainder to root
					Rest to usr

	There are some values on a per port basis, but the equations
	stay the same.

	What do people think?

#!/usr/bin/env perl
#
# distroot	Space used in root filesystem by base install
# distusr	Space used in usr filesystem by base install
# distusrx	Space used in usr filesystem by base install + X
# minfree	Min free space needed in root and usr
# minram	Assume at least this much ram for swap calculations
# ram		Ram in machine
# avail		Space available to NetBSD
# root,swap,usr	Space allocated to each partition
# usex		Are we installing X (default 0 = no)

# Some constants
$^W=1;
$meg=1024*1024;
$minfree=8;

# MD sizes
$distroot=12;
$distusr=50;
$distusrx=70;
$minram=16;

if (@ARGV !=3)
    { 
    print "Usage: diskpart ram disksize x\n (x = 0/1)\n";
    exit(3);
    }

$ram=$ARGV[0];
$avail=$ARGV[1];
$usex=$ARGV[2];

#### First, ensure we can fit the min for root and /usr.
#
$root=	$distroot+$minfree;
$usr=	($usex?$distusrx:$distusr)+$minfree;
$avail-=($root+$usr);

if ($ram < $minram)
    { $ram=$minram; }

if ($avail < 0)
    {
    print "Unable to fit root and /usr into available space\n";
    print "Use interactive setup (and pray)\n";
    exit;
    }

#### Fit as much of ram*2 for swap as possible
#
if ($avail < $ram*2)
    {
    $swap=$avail;
    $avail=0;
    }
else
    {
    $swap=$ram*($usex?2:1);
    $avail-=$swap;
    }

#### Try to allow extra ram on root for crashdump
#
printf " root=%-5d  swap=%-5d  /usr=%-5d  avail=%-5d\n",$root,$swap,$usr,$avail;

if ($avail < $ram)
    {
    $root+=$avail;
    $avail=0;
    }
else
    {
    $root+=$ram;
    $avail-=$ram;
    }

printf " root=%-5d  swap=%-5d  /usr=%-5d  avail=%-5d\n",$root,$swap,$usr,$avail;

#### Split the remainder:  1/32 to swap (clip at 8*ram)
#			   1/16 of remainder to root
#			   Rest to /usr
#
$val=int($avail/32);
if ($swap+$val > $ram*8)
    { $val = $ram*8 - $swap; }
$swap+=$val;
$avail-=$val;

$val=int($avail/16);
$root+=$val;
$avail-=$val;

$usr+=$avail;
$avail=0;

printf " root=%-5d  swap=%-5d  /usr=%-5d  avail=%-5d\n",$root,$swap,$usr,$avail;