Making a nostalgic configuration of NetBSD in virt-manager - Part2
The package system
The original Berkekey Unix did not have a package system. You got what came with the distribution. There was internet, but it only supported email and ftp. So one could download source code ( Fortran or C usually) from sites like Netlib, and compile it , like in Gentoo today only without the help of portage.
So packaging in NetBSD is not part of my nostalgic journey. It is newfangled stuff.
The NetBSD package installing software is described here
https://www.netbsd.org/docs/guide/en/chap-boot.html#chap-boot-pkgsrc
There are 19980 packages available as binaries.
You can also build packages from source.
https://www.netbsd.org/docs/pkgsrc/using.html
The package facility is called pkgsrc
, but that is not a command… the commands are pkg_add
, pkg_delete
, pkg_info
, …
Using binary packages
One has to tell NetBSD where the package server is. In a Debian-based Linux you would define that in /etc/apt/sources.list
. NetBSD does it differently. It defines an environment variable called PKG_PATH
Well, I followed the book, but that did not work
So I can ping the site. What could be wrong? Have a look with the browser
Oh, stupid me, those names in capitals OPSYS/ARCH/VERSIONS
are generics. I need NetBSD/x86_64/10.0
.
Well that is progress. It found the site. Packages are .tgz files. Looks like I need to do it as root , or maybe make some directories , like usr/pkg
OK, it works as root.
So NetBSD is like FreeBSD, in that it keeps added packages in a separate directory. FreeBSD uses /usr/local
but NetBSD uses /usr/pkg
. The merit of this is that packages do not interfere with system upgrades.
pkgin
is the recommended tool for updating packages, and can also be used for searching
Yes, NetBSD has the package a2ps
used for print formatting. It is not installed.
Quite a bit of fuss, but it did the install.
To delete a package pkgin remove PKGNAME
or pkg_delete PKGNAME
.
Version control seems to be a matter of setting the PKG_PATH environment variable.
One last thing, the definition of PKG_PATH
needs to be added to the file ~/.profile
, for each user including root, so that it is defined at each login.
Building packages from source code
If you build a package from source, you can compile code and install it the same way you would for a program written by yourself. There are no restrictions.
Most distros provide a procedure for dealing with source code packages in a standardised way. In NetBSD the build utility for source code is called pkgsrc
.
https://www.netbsd.org/docs/software/packages.html
It supports most BSD distros, and Linux, ( ie you can use pkgsrc in distros other than NetBSD). It is different to the Gentoo portage system or the FreeBSD ports system.
To get pkgsrc for the first time one can download a tar file with ftp and unpack it in the /usr directory.
# ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2025Q2/pkgsrc.tar.gz
#
# tar -xvf pkgsrc.tar.gz -C /usr
This creates a directory called /usr/pkgsrc
, which is where all the source code of packages will be stored. The ftp download took some time.
What you get in /usr/pkgsrc
is a huge directory structure with almost nothing in it except a few manifest files. You dont get any code until you compile a package from source. The pkgsrc
directory can be updated by ftp-ing a new tar file or by using CVS.
# cd /usr/pkgsrc
# cvs update -dP
Now , lets try and build a package from source.
You can browse the online package index here
https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/10.0_2025Q2/All/
We shall try to build 7-zip-24.09.tgz
Go to the 7-zip
subdirectory in pkgsrc
and type ‘make’
followed by make install
Well I did not know that would interfere, try again
# unset PKG_PATH
# make
I get pages of configure and compiler output… it hunts down all the dependencies, including make
itself. It ends like this
It says it installed the binary in /usr/pkg/bin
. I cant find it there?
Do some searching
Looks like it renamed the binary 7zz
. I cant be sure, there is no man page for either 7-zip
or 7zz
?
I can check my looking at the Makefile
Yes, it installs the binary to /usr/pkg/bin/7zz
. Confusing?
If I type 7zz
I get a 7-zip usage printout. That confirms it.
After finishing one can do
# make clean
# make clean-depends
to tidy up leftovers from the compilation.
There is more to pkgsrc
. It can be configured.
The config file is /etc/mk.conf
. It is not present in the system as installed. It allows setting the compiler name, compiler flags, linker flags, and package specific build options. A bit like USE flags in Gentoo.
Updating the system
System updates are separate from the package system. The documentation is here
https://www.netbsd.org/docs/guide/en/chap-upgrading.html
There are several methods of doing a binary upgrade
- The
sysinst
method. You start with a .iso file and invoke the installer, but choose Upgrade NeBSD
instread of install. It basically does all the install steps except partitioning.
- The
sysupgrade
method. This does an inline upgrade of a running system. It requires intervention only for changes to config files.
I have NetBSD-10.0. We are going to try an inline upgrade to NetBSD-10.1
The program sysupgrade is in pkgsrc/sysutils/sysupgrade
. It needs to be installed, so another source code install.
# cd /usr/pkgsrc/sysutils/sysupgrade
# unset PKG_PATH
# make
.... lots of compiler output
# make install
# which sysupgrade
/usr/pkg/sbin/sysupgrade
Now I reboot, do a backup, then use the sysupgrade
command
Lots of output, including some questions about overwriting config files.
There is some problem with postinstall checks
It seems all fixes passed. So reboot and see if it works.
It boots and I can login.
I had better change PKG_PATH
in .profile
to 10.1
and, test the binary package system… yes it still works.
I had better set a hostname
# hostname -s netbsdvm
The network connection still works.
I think that was a successful upgrade.
Finding packages
The list of packages available as binaries ( for my system) is here
https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/10.0_2025Q2/All/
or it can be searched with pkgin
The list of packages available as source ( for my system) is here
https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/10.0_2025Q2/All/
or one can search the directory tree in /usr/pkgsrc
.
The latter list seems to contain all the packages also available as binaries.
Things like firefox browser, thunderbird mailer and xfce DE are available .
I am happy with CTWM nostalgic WM.
Mail in BSD
Of course, one can install a modern mail agent like Thunderbird.
What I am interested in is the original BSD mail
program
It is present, but requires some configuration
- a hostname has to be set
- directories need to be added to
/var/spool/postfix
specifically maildrop
and public
and their ownership and group needs to be as shown
- the
postfix
service needs to be running
Given that, I can do
You terminate the typed message with Ctrl D
. When you say mail
it displays all unread messages. You can step through them with +
and -
.
You can pipe a message to mail
from another program, it is compartable with all text processing utilities.
That is internal mail. You can also configure it to receive network mail.
I worked with mail
for years. I believe it is still around in Linux, but have never tried. It was just interesting to go back to it, in the present context.
Virtual Memory
Unix, including SysVUnix and BSD, was one of the first operating systems to implement virtual memory … the system of dividing physical memory into pages and swapping pages between real memory and disk swap space, while all the time making it look to the user as if they had a large continuous slab of memory.
We take it for granted today, but it made multi-user systems feasable and allowed programs requiring large amounts of memory to run.
BSD still has the vmstat
utility which shows how much memory is in use and whether there is pageing activity. Some Linuxes still have it.
My NetBSD in VM has 4Gb of emulated physical ram and a swap space. Lets see if we can make it swap
cd /usr/pkgsrc/www/netscape
unset PKG_PATH
make
Compiling Netscape may make it swap
Well it has page faults but no ‘pi’ or ‘po’. So it is accessing pages already in memory, but not swapping them to disk. It has a lot of free memory. I thought compiling would take more than that?
The package is ‘netscape-20040123nb4’ . Netscape discontinued in 2007, so this must be an old package.
It seems to be downloading firefox 138.0.4? Must be some dependency there.
I reduced it to 1Gb of ram.
Lots of page faults, lots of pages freed ( it is discarding pages from finished processes) , 5 reactivated pages, but still no swapping.
Reduce it to 128Mb of ram.
At last, some real pageing activity, the ‘pi’ and ‘po’ columns are active.
It is amazing how little ram NetBSD will run in.
I remember having a 486 with 128Mb of ram , and it ran FreeBSD-1.x quite happily, including TWM and Netscape. I thought a modern BSD might need more ram than that.
I will increase the ram now, and let it finish compiling Netscape.
The Netscape browser
Why Netscape? Well, this is a nostalgia trip. Netscape is the first browser I ever used, and I used it in FreeBSD and SunOS in the 1990’s. Mozilla Firefox is a descendent of Netscape Navigator.
I abandoned the compile and installed the binary
#pkgin install netscape-200401234nb4
It installed 52 packages ( including firefox-138.04)… lots of dependencies.
It was a total letdown… it ran firefox instead. Looks nothing like the original Netscape.
Discussion
This is not a review of what NetBSD can do today… it is an attempt to wind NetBSD back to what I remember BSD was like in the 1990’s.
So dont judge NetBSD by what you see here. It is a capable modern OS.
I might try and have a look at modern NetBSD, but that is another topic.
What did I achieve from my nostalgic windback? Apart for some personal satisfaction at seeing old things, there is something to be gained from the contrast.
It was more difficult to configure things in early BSD.
I also learnt how to drive NetBSD… it was an effective way of doing that. The package system is different to any other Linux/BSD and takes some practice to get things working. The update system seems very efficient. The package and update systems are separate… not like Debian where apt
does it all. That is a BSD feature ( FreeBSD is the same). It is because BSD keeps the system away from package installs. BSD treats the utilities as part of the OS, while Linux treats utilities as just another addon package.
I have no intention of using my nostalgic creation. It was the journey, not the end point , that meant something to me.