ccmach13

This is to document the flash drive installation of our system on an HP Proliant Microserver. Note: On this platform sd0 is the hard drive, sd1 is the flash drive.

  • Performing a simple install
  • Graphical User Interface
  • Setting up Anonymous FTP Services
  • Database Server Setup and Operation
  • Programming
  • Database Administration
  • Concurrent Versions System (CVS)

  • Performing a simple install

    OpenBSD’s new installer is designed to install and configure OpenBSD in a very usable default configuration with very little user intervention.

    The OpenBSD Installation Guide is here.


    Starting the install

    Whatever your means of booting is, it is now time to use it. During the boot process, the kernel and all of the programs used to install OpenBSD are loaded into memory. When your boot is successful, you will see a lot of text messages scroll by. Then, you will see the following:

      ...
      root on rd0a swap on rd0b dump on rd0b
      erase ^?, werase ^W, kill ^U, intr ^C, status ^T
    
      Welcome to the OpenBSD/i386 5.1 installation program.
      (I)nstall, (U)pgrade or (S)hell? i ↵
    

    And with that, we reach our first question. We are assuming you are choosing “(I)nstall” here.


    The Install Questions

    Now we start getting the questions that will define how the system is set up. You will note that in most cases, all the questions are asked up front, then the installation takes place.

      At any prompt except password prompts you can escape to a shell by
      typing '!'. Default answers are shown in []'s and are selected by
      pressing RETURN.  You can exit this program at any time by pressing
      Control-C, but this can leave your system in an inconsistent state.
    
      Choose your keyboard layout ('?' or 'L' for list) [default] 
    

    In most cases, the default keyboard layout is appropriate.

      System hostname? (short form, e.g. 'foo') dimron  ↵
    

    This value, along with the DNS domain name, will be saved in the file /etc/myname which is used during normal boot to set the hostname of the system.

      Available network interfaces are: fxp0 vlan0.
      Which one do you wish to configure? (or 'done') [fxp0] 
    

    After selecting the device you wish to configure, you will now configure it.

      IPv4 address for fxp0? (or 'dhcp' or 'none') [dhcp] 
      Issuing hostname-associated DHCP request for fxp0.
      DHCPDISCOVER on fxp0 to 255.255.255.255 port 67 interval 1
      DHCPOFFER from 192.168.1.250 (08:00:20:94:0b:c8)
      DHCPREQUEST on fxp0 to 255.255.255.255 port 67
      DHCPACK from 192.168.1.250 (08:00:20:94:0b:c8)
      bound to 192.168.1.199 -- renewal in 43200 seconds.
    

    DHCP will configure the IP address, subnet mask, default gateway, DNS domain name and DNS servers.

      IPv6 address for fxp0? (or 'rtsol' or 'none') [none] 
      Available network interfaces are: fxp0 vlan0.
      Which one do you wish to configure? (or 'done') [done] 
      Using DNS domainname example.org
      Using DNS nameservers at 192.168.1.252
      Do you want to do any manual network configuration? [no] 
    
      Password for root account? (will not echo) PaSsWoRd ↵
      Password for root account? (again) PaSsWoRd ↵
    

    Use a secure password for the root account.

      Start sshd(8) by default? [yes] 
    

    Usually, you will want sshd(8) running.

      Start ntpd(8) by default? [no] 
      NTP server? (hostname or 'default') [default] 
    
      Do you expect to run the X Window System? [yes] 
    

    Answering “y” here will modify /etc/sysctl.conf to include the line machdep.allowaperture=2

      Do you want the X Window System to be started by xdm(1)? [no] 
    
      Setup a user? (enter a lower-case loginname, or 'no') [no] postgres  ↵
    

    Note that if you wish to create the user, enter the user’s name, not “y” or “yes”.


    Setting up disks

    First, the OpenBSD slice of the hard disk is defined using fdisk(8), then that slice is subdivided into OpenBSD partitions using disklabel(8).

    OpenBSD’s new installer attempts to make your disk layout tasks easier by having a sane default for “general” use.

      Available disks are: sd0 sd1
      Which one is the root disk? (or 'done') [sd0] 
      Use DUIDs rather than device names in fstab? [yes] no  ↵
      Disk: sd0	geometry: 30401/255/63 [488397168 Sectors]
      Offset: 0	Signature: 0xAA55
                  Starting         Ending         LBA Info:
       #: id      C   H   S -      C   H   S [       start:        size ]
      -------------------------------------------------------------------------------
       0: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
       1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
       2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
       3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused     
      Use (W)hole disk or (E)dit the MBR? [whole] 
      Setting OpenBSD MBR partition to whole sd0...done.
    

    Note that this disk has a pre-existing partition on it — using “whole” disk will remove it!.

    Now we will break up our OpenBSD fdisk partition into OpenBSD disk partitions using disklabel:

      Setting OpenBSD MBR partition to whole sd0...done.
      The auto-allocated layout for sd0 is:
      #                size           offset  fstype [fsize bsize  cpg]
        a:          1024.0M               64  4.2BSD   2048 16384    1 # /
        b:           199.0M          2097216    swap                   
        c:         40960.0M                0  unused                   
        d:          2822.9M          2504768  4.2BSD   2048 16384    1 # /tmp
        e:          4295.0M          8286112  4.2BSD   2048 16384    1 # /var
        f:          2048.0M         17082240  4.2BSD   2048 16384    1 # /usr
        g:          1024.0M         21276544  4.2BSD   2048 16384    1 # /usr/X11R6
        h:          5426.7M         23373696  4.2BSD   2048 16384    1 # /usr/local
        i:          1699.7M         34487520  4.2BSD   2048 16384    1 # /usr/src
        j:          2048.0M         37968576  4.2BSD   2048 16384    1 # /usr/obj
        k:         20367.4M         42162880  4.2BSD   2048 16384    1 # /home
      Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? [a] 
    

    The installer has presented us with its proposed “Auto layout” for OpenBSD partitions on our disk, which we are going to accept.
    The installer now creates those partitions and creates file systems on them using newfs and mounts them for installation:

      /dev/rsd0a: 1024.0MB in 2097152 sectors of 512 bytes
      6 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/rsd0k: 20367.4MB in 41712448 sectors of 512 bytes
      101 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/rsd0d: 2822.9MB in 5781344 sectors of 512 bytes
      14 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/rsd0f: 2048.0MB in 4194304 sectors of 512 bytes
      11 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/rsd0g: 1024.0MB in 2097152 sectors of 512 bytes
      6 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/rsd0h: 5426.7MB in 11113824 sectors of 512 bytes
      27 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/rsd0j: 2048.0MB in 4194304 sectors of 512 bytes
      11 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/rsd0i: 1699.7MB in 3481056 sectors of 512 bytes
      9 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/rsd0e: 4295.0MB in 8796128 sectors of 512 bytes
      22 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
      /dev/sd0a on /mnt type ffs (rw, asynchronous, local)
      /dev/sd0k on /mnt/home type ffs (rw, asynchronous, local, nodev, nosuid)
      /dev/sd0d on /mnt/tmp type ffs (rw, asynchronous, local, nodev, nosuid)
      /dev/sd0f on /mnt/usr type ffs (rw, asynchronous, local, nodev)
      /dev/sd0g on /mnt/usr/X11R6 type ffs (rw, asynchronous, local, nodev)
      /dev/sd0h on /mnt/usr/local type ffs (rw, asynchronous, local, nodev)
      /dev/sd0j on /mnt/usr/obj type ffs (rw, asynchronous, local, nodev, nosuid)
      /dev/sd0i on /mnt/usr/src type ffs (rw, asynchronous, local, nodev, nosuid)
      /dev/sd0e on /mnt/var type ffs (rw, asynchronous, local, nodev, nosuid)
    


    Choosing installation media and file sets

    Here you get a chance to choose your installation media.

      Let's install the sets!
      Location of sets? (disk ftp http or 'done') [disk] 
      Is the disk partition already mounted? [no] 
      Available disks are: sd0 sd1
      Which one is the contains the install media? (or 'done') [sd1] 
      Pathname to the sets? (or 'done') [5.1/i386] 
      Select sets by entering a set name, a file name pattern or 'all'. De-select
      sets by prepending a '-' to the set name, file name pattern or 'all'. Selected
      sets are labelled '[X]'.
          [X] bsd           [X] etc51.tgz     [X] xbase51.tgz   [X] xserv51.tgz
          [X] bsd.rd        [X] comp51.tgz    [X] xetc51.tgz
          [X] bsd.mp        [X] man51.tgz     [X] xshare51.tgz
          [X] base51.tgz    [X] game51.tgz    [X] xfont51.tgz
      Set name(s)? (or 'abort' or 'done') [done] 
    

    And now, we start our install:

      bsd          100% |*************************************|  8810 KB    00:05
      bsd.rd       100% |*************************************|  6271 KB    00:03
      bsd.mp       100% |*************************************|  ???? KB    ??:??
      base51.tgz   100% |*************************************| 55415 KB    00:26
      etc51.tgz    100% |*************************************|   519 KB    00:00
      comp51.tgz   100% |*************************************| 60165 KB    00:28
      man51.tgz    100% |*************************************|  9497 KB    00:06
      game51.tgz   100% |*************************************|  2567 KB    00:02
      xbase51.tgz  100% |*************************************| 11028 KB    00:06
      xetc51.tgz   100% |*************************************| 63902       00:00
      xshare51.tgz 100% |*************************************|  4511 KB    00:04
      xfont51.tgz  100% |*************************************| 38869 KB    00:17
      xserv51.tgz  100% |*************************************| 25113 KB    00:15
      Location of sets? (cd disk ftp http or 'done') [done] 
    

    Again, we just take the default, we are done installing files.

      What timezone are you in? ('?' for list) [Canada/Mountain] 
    

    Note that the installer will quite often guess correctly for your time zone, and you can then just hit “Enter”.

      Saving configuration files...done.
      Generating initial host.random file...done.
      Making all device nodes...done.
    
      CONGRATULATIONS! Your OpenBSD install has been successfully completed!
      To boot the new system, enter 'reboot' at the command prompt.
      When you login to your new system the first time, please read your mail
      using the 'mail' command.
    
      # reboot ↵
    


    First boot!

    OpenBSD is now installed on your system and ready for its first boot!


    Graphical User Interface

    Motif refers to both a graphical user interface (GUI) specification and the widget toolkit for building applications that follow that specification under the X Window System on Unix and other POSIX-compliant systems. It was the standard toolkit for the Common Desktop Environment and thus for Unix. After many years as proprietary software, it is available as of 2012 as free software under the GNU Lesser General Public License (LGPL).


    Starting X

    Log in to a console as normal, then run startx.

    OpenBSD/i386 (inron.tampabay.rr.com) (ttyC0)
    login: root ↵
    Password: PaSsWoRd ↵
    Last login: Sat...
    . . .
    You have mail.
    # startx ↵
    . . .
    


    Text Editor

    NEdit is a fast, compact Motif/X11 plain text editor, for most popular Unix systems. Features significant support for programmers including syntax highlighting, macro language, and streamlined keyboard navigation. Mature and stable.

    # pkg_add -v /mnt/5.1/packages/i386/nedit ↵
    


    Window Manager

    The Motif Window Manager (MWM) is part of the Motif Graphic User Interface (GUI).
    To make it your default window manager for X edit /etc/X11/xinit/xinitrc.

    # cd /etc/X11/xinit ↵
    # nedit & ↵
    

    Open the file /etc/X11/xinit/xinitrc
      Find the line: fvwm || xterm
      Change it to: mwm || xterm


    Setting up Anonymous FTP Services

    Anonymous FTP allows users without accounts to access files on your computer via the File Transfer Protocol. This will give an overview of setting up the anonymous FTP server, and its logging, etc.


    Adding the FTP account

    To start off, you need to have an ftp account on your system. First:

    # echo /usr/bin/false >> /etc/shells ↵
    

    After this, you are ready to add the ftp user:

    # adduser ↵
    Use option ``-silent'' if you don't want to see all warnings and questions.
    
    Reading /etc/shells
    Check /etc/master.passwd
    Check /etc/group
    
    Ok, let's go.
    Don't worry about mistakes. There will be a chance later to correct any input.
    Enter username []: ftp ↵
    Enter full name []: anonymous ftp ↵
    Enter shell csh false ksh nologin sh [ksh]: false ↵
    Uid [1002]: 
    Login group ftp [ftp]: 
    Login group is ``ftp''. Invite ftp into other groups: guest no 
    [no]: 
    Login class authpf daemon default staff [default]: 
    Enter password []: 
    Set the password so that user cannot logon? (y/n) [n]: y ↵
    
    Name:        ftp
    Password:    ****
    Fullname:    anonymous ftp
    Uid:         1002
    Gid:         1002 (ftp)
    Groups:      ftp
    Login Class: default
    HOME:        /home/ftp
    Shell:       /usr/bin/false
    OK? (y/n) [y]: 
    Added user ``ftp''
    Copy files from /etc/skel to /home/ftp
    Add another user? (y/n) [y]: n ↵
    Goodbye!
    

    Remove the dot files created by adduser:

    # rm -R /home/ftp/.* ↵
    


    Directory Setup

    Along with the user, this created the directory /home/ftp. This is what we want, but there are some changes that we will have to make to get it ready for anonymous ftp. Note that all these directories should be owned by ”root”. Here is a listing of what the directories should look like after their creation.

    # pwd ↵
    /home
    # ls -laR ftp ↵
    total 5
    dr-xr-xr-x  5 root  ftp    512 Jul  6 11:33 .
    drwxr-xr-x  7 root  wheel  512 Jul  6 10:58 ..
    dr-x--x--x  2 root  ftp    512 Jul  6 11:34 etc
    dr-xr-xr-x  2 root  ftp    512 Jul  6 11:33 pub
    
    ftp/etc:
    total 43
    dr-x--x--x  2 root  ftp    512 Jul  6 11:34 .
    dr-xr-xr-x  5 root  ftp    512 Jul  6 11:33 ..
    -r--r--r--  1 root  ftp    316 Jul  6 11:34 group
    -r--r--r--  1 root  ftp  40960 Jul  6 11:34 pwd.db
    
    ftp/pub:
    total 2
    dr-xr-xr-x  2 root  ftp  512 Jul  6 11:33 .
    dr-xr-xr-x  5 root  ftp  512 Jul  6 11:33 ..
    

    You can copy the ftp directory from our distribution:

    # mount /dev/sd1a /mnt ↵
    # cd /mnt/dist/home ↵
    # cp -rp ftp /home ↵
    # cd /home ↵
    # umount /mnt ↵
    


    Starting up the server and logging

    Open the file /etc/inetd.conf.
      Find the line: #ftp stream tcp nowait root /usr/libexec/ftpd ftpd -US
      Change it to: ftp stream tcp nowait root /usr/libexec/ftpd ftpd -llUSA

    ftp             stream  tcp     nowait  root    /usr/libexec/ftpd       ftpd -llUSA
    


    Database Server Setup and Operation

    PostgreSQL is an object-relational database management system (ORDBMS) based on POSTGRES, Version 4.2, developed at the University of California at Berkeley Computer Science Department.

    The PostgreSQL Server Setup and Operation Documentation is here.

    # pkg_add -v /mnt/5.1/packages/i386/postgresql-server ↵
    


    The Database Super User Account

    # user mod -G _postgresql postgres ↵
    # chown -R postgres:_postgresql /var/postgresql ↵
    

    As with any server daemon that is accessible to the outside world, it is advisable to run PostgreSQL under a separate user account.


    Creating a Database Cluster

    # cd / ↵
    # su postgres ↵
    $ mkdir /var/postgresql/data ↵
    $ initdb -D /var/postgresql/data -U postgres ↵
    $ exit ↵
    # 
    

    initdb will attempt to create the directory you specify if it does not already exist.


    Starting the Database Server

    On OpenBSD, add the following lines to the file /etc/rc.local:

    if [ -x /usr/local/bin/pg_ctl -a -x /usr/local/bin/postgres ]; then
    	su postgres -c '/usr/local/bin/pg_ctl start \
    	-D /var/postgresql/data \
    	-l /var/postgresql/data/logfile -s'
    	echo 'postgresql '
    fi
    


    Programming

    PHP is a server-side scripting language designed for Web development but also used as a general-purpose programming language.

    # pkg_add -v /mnt/5.1/packages/i386/php-5.3.10 ↵
    # ln -s /var/www/conf/modules/php.conf /var/www/conf/modules.sample/php-5.3.conf ↵
    


    Database Support

    # pkg_add -v /mnt/5.1/packages/i386/php-pgsql-5.3.10 ↵
    # ln -fs /etc/php-5.3/pgsql.ini /etc/php-5.3.sample/pgsql.ini ↵
    

    $conn_string = “host=localhost port=5432 dbname=inron user=postgres”;


    Starting the Web Server

    To start the Apache Web Server at boot edit the file /etc/rc.conf:
      Find the line: httpd_flags=NO
      Change it to: httpd_flags=””


    Database Administration

    phpPgAdmin is a web application, written in PHP, for managing PostgreSQL databases. It is a web-based client which leverages PHP scripting and the PostgreSQL database to provide a convenient way for users to create databases, create tables, alter tables and query their own data using industry-standard SQL.

    # pkg_add -v /mnt/5.1/packages/i386/phpPgAdmin ↵
    
    # cd /var/www/phpPgAdmin ↵
    # ln -s ../phpPgAdmin /var/www/htdocs/phpPgAdmin ↵
    

    Edit /var/www/htdocs/phpPgAdmin/conf/config.inc.php file and modify the ‘servers’ entries to fix: $conf[‘servers’][0][‘host’] = ‘localhost’;


    Create a User

    # su postgres ↵
    $ createuser brit ↵
    $ Shall the new role be a superuser? (y/n) y ↵
    $ psql template1 ↵
    psql (9.1.2)
    
    Type "help" for help.
    
    template1=# ALTER USER brit PASSWORD 'PaSsWoRd'; ↵
    ALTER ROLE
    template1=# \q ↵
    $ exit ↵
    # 
    

    The user can login on a client browser, for example: http://192.168.1.143/phpPgAdmin/index.php



    Concurrent Versions System (CVS)

    CVSweb is a WWW interface for CVS repositories with which you can browse a file hierarchy on your browser to view each file’s revision history in a very handy manner.

    # pkg_add -v /mnt/5.1/packages/i386/cvsweb ↵
    


    Directories

    In order to make CVSweb operate in a chroot environment, it is necessary to copy all of the relevant tools, libraries, and perl modules that CVSweb employs into /var/www.
    First, create the basic directory structure:

    # cd /var/www ↵
    # mkdir tmp usr ↵
    

    Needs to be writeable for the www user

    # chown www:www tmp ↵
    
    # cd /var/www/usr ↵
    # mkdir -p {bin,lib,libdata/perl5,libexec} ↵
    
    # cd /var/www/usr/libdata/perl5 ↵
    # mkdir -p {File,IPC,Time,warnings,`machine`-openbsd/5.12.2} ↵
    

    The “annotate” function requires this empty file:

    # cd /var/www/dev ↵
    # touch null ↵
    

    Now, the required binaries:

    # cd /var/www/usr/bin ↵
    # cp -p /usr/bin/{co,cvs,diff,perl,rcsdiff,rlog,uname} . ↵
    

    Next, the libraries that the binaries are linked to:

    # cd /var/www/usr/lib ↵
    # cp -p /usr/lib/lib{c,crypto,gssapi,krb5,m,perl,util,z}.so* . ↵
    

    Now, the run-time link-editor:

    # cd /var/www/usr/libexec ↵
    # cp -p /usr/libexec/ld.so . ↵
    

    And finally, the perl modules:

    # cd /var/www/usr/libdata/perl5 ↵
    # cp -p /usr/libdata/perl5/{Carp,Exporter,Symbol,base,integer}.pm . ↵
    # cp -p /usr/libdata/perl5/{strict,warnings,vars,constant}.pm . ↵
    # cp -p /usr/libdata/perl5/File/Basename.pm ./File/ ↵
    # cp -p /usr/libdata/perl5/IPC/Open{2,3}.pm ./IPC/ ↵
    # cp -p /usr/libdata/perl5/Time/Local.pm ./Time/ ↵ 
    # cp -p /usr/libdata/perl5/warnings/register.pm ./warnings/ ↵
    
    # cd /var/www/usr/libdata/perl5/`machine`-openbsd/5.12.2 ↵
    # cp -p /usr/libdata/perl5/`machine`-openbsd/5.12.2/{Config,Cwd}.pm . ↵
    # cp -p /usr/libdata/perl5/`machine`-openbsd/5.12.2/Config_{git,heavy}.pl . ↵
    


    Configuration

    The cvsweb program itself and cvsweb.conf both assume Apache is not running in a chroot environment, so we need to change some default paths so they are relative to /var/www.

    In /var/www/cgi-bin/cvsweb:

    for (“$mydir/cvsweb.conf”, ‘/var/www/conf/cvsweb/cvsweb.conf’) {
    for (“$mydir/cvsweb.conf”, ‘/conf/cvsweb/cvsweb.conf’) {

    In /var/www/conf/cvsweb/cvsweb.conf:

    Change CVSrepositories to reflect the location of the directories which contain CVSROOT. This example shows a local repository NFS mounted over loopback into /var/www/cvs, since the directory must be relative to
    /var/www, we use /cvs.

    @CVSrepositories = (
    ‘local’ => [‘Local Repository’, ‘/home/cvs’], (default)
    ‘local’ => [‘Local Repository’, ‘/cvs’], (chroot)

    And the same idea for $mimetypes:

    $mime_types = ‘/var/www/conf/mime.types’; (default)
    $mime_types = ‘/conf/mime.types’; (chroot)

    And finally:

    # cvs -d /var/www/cvs init
    

    Test on a client example:
    http://192.168.1.143/cgi-bin/cvsweb/

    Prototype Applications