Subject: Re: Default filesystem sizes
To: darrenr@reed.wattle.id.au, Manuel Bouyer <bouyer@antioche.lip6.fr>
From: David Brownlee <abs@anim.dreamworks.com>
List: tech-install
Date: 06/21/1999 19:31:12
	Hopefully I'm addressing all the feedback I've recieved on this:

	I'm going to pass on any large 'Jumpstart' like project - and
	concentrate on something quick that we can use for 1.4.1 :)

	I'd imagine very few people on this list would use anything but
	'Custom'. One size cannot fit all, but it can at least avoid
	strangling many people...

    Suggestion 2:

	Drop root and /usr altogether. In virtually every case its
	better off with one big root, root /usr, and /var, or something
	more custom.

	The disk partitioning menu would have four options

		[a] Toggle 'install with X'
		[b] Standard		(one big filesystem, plus swap)
		[c] Standard server	(/, swap, /usr, /var)
		[d] Custom 		(Uses defaults from [c]).


	Logic (the letters are stages, not partitions):

#### a) _must_ have enough for the distribution (std/std+x) plus minfree
####    (currently 8MB) in each filesystem.
#### b) If enough space, ensure swap is the size of ram (2*ram for x)
#### c) Allow enough extra space for one crashdump
#### d) Split the remainder
####	1/16 to swap (clip at 4*ram)	- will allow mfs /tmp
####	If non server
####	    rest to filesystem
####	else
####	    1/32 to root (clip at minfree+ram*2)
####	    1/16 to /var (clip at minfree+ram*4)
####	    rest to /usr

	I'm clipping at swap=4*ram, to allow for people wanting to use mfs 
	/tmp or similar. On a 128MB machine you only get that much on a
	7GB disk. a 4GB disk would give 362MB swap.

	Updated perl script attached :)

#!/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
# distvar		Space used in /var filesystem by base install
# minfree		Min free space needed in any filesystem
# minram		Assume at least this much ram for swap calculations
# ram			Ram in machine (set to max(ram,minram))
# avail			Space available to NetBSD
# root,swap,usr,var	Space allocated to each partition
# usex			Is x being used
# server		Are we configuring for one big filesystem (no usr,var)

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

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

require 'getopts.pl';

if ( ! &Getopts('sx') || @ARGV != 2 )
    { 
    print "Usage: diskpart [opt] ram disk
[opts]  -s Partition for server (separate /usr, and /var)
	-x Partition for X (larger minspace for /usr)

ram=Ram size in MB	disk=Disk size in MB
";
    exit(3);
    }

$ram=	$ARGV[0];
$avail=	$ARGV[1];
$usex=	$opt_x;
$server=$opt_s;

# Calculate some values
#
if ($usex)
    { $distusr=$distusrx; }
if ($ram < $minram)
    { $ram=$minram; }

#### a) _must_ have enough for the distribution (std/std+x) plus minfree
####    (currently 8MB) in each filesystem.
#
if ($server)
    {
    $root=	$distroot+$minfree;
    $usr=	$distusr+$minfree;
    $var=	$distvar+$minfree;
    }
else
    {
    $root=$distroot+$distusr+$distvar+$minfree;
    $usr=$var=0;
    }
$avail-=($root+$usr+$var);

if ($avail < 0)
    {
    # Could try to handle standard server too big and standard would fit
    print "Unable to fit filesystems into available space\n";
    print "Use interactive setup (and pray)\n";
    exit;
    }

#### b) If enough space, ensure swap is the size of ram (2*ram for x)
#
$val=$ram*($usex?2:1);
if ($val > $avail)
    {
    print "Warning: Reducing swap to fit\n";
    $swap=$avail;
    }
else
    { $swap=$val; }
$avail-=$swap;
&print_sizes("min");

#### c) Allow enough extra space for one crashdump
#
if ($avail < $ram)
    { $val=$avail; }
else
    { $val=$ram; }

if ($server)
    { $var+=$ram; }
else
    { $root+=$ram; }
$avail-=$ram;

&print_sizes("crashdump");

#### d) Split the remainder
####	1/16 to swap (clip at 4*ram)	- will allow mfs /tmp
####	If non server
####	    rest to filesystem
####	else
####	    1/32 to root (clip at minfree+ram*2)
####	    1/16 to /var (clip at minfree+ram*4)
####	    rest to /usr
#
$chunk=int($avail/32);

$val=$chunk*2;
if ($swap+$val > $ram*4)
    { $val = $ram*4 - $swap; }
$swap+=$val;
$avail-=$val;

if ($server)
    {
    $val=min($chunk,$ram*2);
    $root+=$val;
    $avail-=$val;

    $val=min($chunk*2,$ram*4);
    $var+=$val;
    $avail-=$val;

    $usr+=$avail;
    $avail=0;
    }
else
    { $root+=$avail; }
$avail=0;

&print_sizes("final");

exit;

sub print_sizes
    {
    my($title)=@_;
    printf("%-10s root=%-5d  swap=%-5d  /usr=%-5d  /var=%-5d  avail=%-5d\n",
				$title,$root,$swap,$usr,$var,$avail);
    }

sub min
    {
    my($a,$b)=@_;

    ($a<$b)?$a:$b;
    }
		David/absolute

                  -=-  and team B will be... Kenny.  -=-