![]() |
| June 2001 | Get BSD | New to BSD? | Search BSD | Submit News | FAQ | Contact Us | Join Us |
|
Previous work to make a read-only mounting of root and /usr on a normal hard disk was working for Sparc and i386 in October 2000. With upgrades to -current every now and then, I noticed that with my changes to tcpdump, /etc files, cg3 and cg6 drivers, dhclient-script, miscellaneous others -- let alone the */conf/ files to hard-wire device numbers to disk and tape drives, that it was nearly impossible to keep up with the development changes.
I made the decision to make the CD with as few changes as possible from the base distribution. To allow for booting and getting IP addresses, DHCP is the only way to go. There are shell variables in dhclient-script that are passed in from dhclient. These need quotes around them in lots of places. [Security enhancement -- if I can use them to break things ...]
If one were to take the normal approach, you will find that files are changed and written in /tmp, /etc, /var, and /dev, and lastly the user home directory. The changes to scripts and programs keeps expanding as things are found. I stopped when sshd wanted to remake the DSA and RSA files.
Fortunately the memory file system exists. Unfortunately, this is buggy. You cannot union mount over the root directory (panic). If you have multiple union mounted memory file systems, strange behavior exists. If you have multiple memory file systems, the union mounted file system starts misbehaving. FreeBSD tends to give kernel panics. If you just use memory file systems with the first one union mounted, and the others as normal memory file systems, things mostly work ok, and things can be gotten around.
/etc/fstab for OpenBSD:
/dev/cd0c / cd9660 ro,noatime 0 0
swap /dev mfs rw,noatime,union,-s=12000 0 0
swap /tmp mfs rw,nodev,noexec,nosuid,noatime,-s=262144 0 0
swap /var mfs rw,-s=262144,noatime 0 0
swap /etc mfs rw,noatime,-s=131072 0 0
swap /home mfs rw,noatime,-s=262144 0 0
FreeBSD can not have the CD specified, so delete it. The /dev is union mounted, so that the shell script rc can use the console.
Since the directory /cdboot exists on the CD, make use of that as a conditional for populating the directories via untar. Create a file DISK/cdboot/mfs.tgz that contains all files to be in /etc, /var, /dev, and /home.
tar zcf mfs.tgz dev etc var home
Files changed from the base distribution: /etc/rc, dhclient-script, and for OpenBSD, the /etc/hostname.XX file was deleted and /etc/hostname.dhcp created. /etc/hostname.XX is created as a symbolic link to /etc/hostname.dhcp by script changes in /etc/rc. FreeBSD does DHCP on interfaces listed in /etc/rc.conf, via lines like: ifconfig_xl0="DHCP". I added every interface possible in the kernel, the script only uses those interfaces present.
If you have two ethernets, things are interesting -- for OpenBSD, I chose to only do the first one -- since both have the same MAC address, you can not use the same DHCP server for both interfaces. FreeBSD will have one of the dhclients will fail due to port in use.
The main changes are:
a) After mounting all file systems, if /cdboot/mfs.tgz exists, do a:
tar zxpf /cdboot/mfs.tgz -C /This populates the memory file systems of /etc, /var, /dev, /home.
b) if /etc/hostname.dhcp exists, find out what network interfaces exists, and point the first one at /etc/hostname.dhcp so that dhcp is done. (Subroutine modified from installation boot floppy.)
c) Do not remount /usr and /var. (/usr doesn't exist and /var is already mounted.)
d) Ask for the date and time. The cd9660 filesystem does not read the PC's clock, compare it with the file system date, and warn if the machines date isn't close to the file system date. As such, a manual setting of the date is required.
Diff's for /etc/rc are listed at the end.
The most time consuming part was figuring out how to create an ISO image for writing to the CD. This meant figuring out the mkisofs command -- trial and error. The .mkisofsrc file I use looks like:
APPI=i386 OpenBSD cdrom boot and run disk. "root" is "cdrom", "user" is
"user"
COPY=Copyright_2001
ABST=READ_ONLY_DISK
BIBL=By_Marshall_M_Midden
PREP=Marshall M. Midden, marshallmidden@yahoo.com
PUBL=Marshall M. Midden, 9792 Hemlock Lane, Maple Grove, MN 55369-3666
U.S.A.
SYSI=CDROM:OpenBSD-2001-01-22-current
VOLI=System runs with MFS from CD.
VOLS=This system has /etc/X11/XF86config set up for a older Dell. "cu -s 9600
-l /dev/cua00" for serial line. SNMP available. X available. Ghostview. Etc.
and the shell script for doing the mkisofs command is:
#!/bin/csh -x
set DATE=`/bin/date '+%Y-%m-%d'`
rm -f /home/m4/tmp/cd/diskimage.iso
mkisofs -a -b cdboot/boot.img -c cdboot/boot.catalog -d -D -l -L \
-o /home/m4/tmp/cd/diskimage.iso -R -T -V "${DATE}" \
/home/m4/tmp/cd/DISK/
Of note is boot.img -- a floppy boot image. See
/usr/src/distrib/i386/floppies.
boot.catalog is created by the mkisofs command. The output ISO image is in file diskimage.iso and the input directory structure to the mkisofs command is in directory DISK. (To create a floppy disk image on FreeBSD, you must add in "pseudo-device vn" to the GENERIC kernel.)
Most machines will allow a 2.88mb floppy image for the boot image on the CD. I ran into one DELL that only works for a 1.44mb floppy image. OpenBSD wants the same kernel that is loaded to be where it is mounted. FreeBSD seems to allow any FreeBSD kernel to be mounted, and a significantly different one may be loaded. Interesting differences. OpenBSD always makes a "mount" request for root be an update (in the mount command), FreeBSD handles it in the file system code. FreeBSD does not handle update for CD.
The kernel that is on the boot floppy and the root directory of the CD needs the following line added/changed (if you have only one cd named cd0c):
config bsd root on cd0c
There is no swap or dump -- it is read-only. /sys/arch/i386/conf/BIG_RO created from GENERIC. Put the include file into it. I got rid of FACK and SACK, IPV6, Multicast, LFS, KEY, etc, added NETATALK, etc. Make sure to have:
option RAMDISK_HOOKS
option MINIROOTSIZE=3560
To make it fit in a floppy image, I deleted the USB devices, RAID disks and controllers. There is a lot of flexiblity on what is kept and deleted. If you don't have pcmcia (cardbus) devices, those may be deleted.
I created the directory /usr/src/distrib/i386/floppies/BIG_RO as a copy of ramdisk_cd. In the Makefile, changed RAMDISK_CD to BIG_RO. Added to ../Makefile "SUBDIR += BIG_RO". The first time, /usr/src/distrib needs to be "make"d to get the necessary crunching files.
Copy from /usr/src/distrib/i386/floppies/BIG_RO/ the file cdrom28.fs to DISK/cdboot/boot.img. This is the boot floppy image on the CD. Copy the uncompressed and unstripped "bsd" image to DISK/bsd (the root file system of the to be created ISO disk image).
Run the mkisofs command script.
I used Windows Adaptec Easy CD Creator to write the image. Get the image to the DOS box. (Samba, ftp, or if dual booting you can use "mount -t msdos".) Cancel out of the CD Wizard and under the File tab (upper left menu), select disk image copy, and change the file type to *.iso for selecting and finding. "Disc-At-Once" (or Track-At-Once with Close CD ) is needed for the new version.
Depending on what you want to run, you will need to change the following files:
/etc/X11/XF86Config to make X work for your video card and monitor(s).
/etc/samba/smb.conf for the work group, etc.
"mkdir /var/spool/samba" to enable printing.
/var/netatalk/atalkd.conf for the ethernet interface, and network range (all).
/var/spool/lpd/lp_default/.paprc points to "LaserWriter II NTX:LaserWriter@*".
Note: /root/ATALK is run manually to bring up appletalk.
All the other stuff you wish to configure and use.
Note: I have placed the directories /etc, /var, /dev, and /home in /cdboot on the CD. The script /cdboot/MAKE.mfs makes the mfs.tgz file that populates the directories.
If OpenBSD hangs near the beginning, around device apm0, it needs to have the pcibios0 value changed. At the initial boot prompt (which times out quickly and the system starts booting), type "boot bsd -c". At the "UKC>" prompt, type: "change pcibios0", "y", "3". Then type "quit" to leave and continue the boot. (? provides a list of commands)
I find that both OpenBSD and FreeBSD work great from CD. Might be a tad slow the first time a command is used, but after that it will be in the memory disk buffers and work fast. I have not used it on a machine with less than 64MB.
OpenBSD ISO image is at ftp://???.???.???.???/pub/openbsd.cd/diskimage.iso with other files present in the directory.
FreeBSD ISO image is at ftp://???.???.???.???/pub/freebsd.cd/diskimage.iso with the boot floppy image set up as a 1.44mb floppy.
------------------------------------------------------------------------------
Diff's for OpenBSD /etc/rc (FreeBSD similar) are :
##############################################################################
--- rc Mon Feb 12 09:11:33 2001
+++ /home/m4/src/OpenBSD/src/etc/rc Tue Feb 13 19:21:42 2001
@@ -22,49 +22,6 @@
} < $_file
}
-cutword () {
-# read lines on stdin, return Nth element of each line, like cut(1)
- local _a _oifs="$IFS"
-
- IFS=":"
- while read _a; do
- set -- $_a
- test "$1" = "" && break
- echo $1
- done
- IFS="$_oifs"
-}
-
-get_intfs () {
-# read lines on stdin, return ifconfig -a lines that are interfaces.
- local _a
-
- while read _a; do
- set -- $_a
- test "$1" = "" && break
- case $1 in
- lo*:) ;;
- enc**:) ;;
- gre**:) ;;
- ppp**:) ;;
- sl**:) ;;
- tun**:) ;;
- bridge**:) ;;
- gif*:) ;;
- vlan*:) ;;
- media**:) ;;
- status**:) ;;
- *:) echo $1
- ;;
- esac
- done
-}
-
-get_ifdevs() {
- # return available network devices
- /sbin/ifconfig -a | get_intfs
-}
-
# End subroutines
stty status '^T'
@@ -149,28 +106,8 @@
umount -a >/dev/null 2>&1
mount -a -t nonfs
-# if memory file systems mounted, fix them.
-if [ -f /cdboot/mfs.tgz ]; then
- tar zxpf /cdboot/mfs.tgz -C /
- echo 'Fixed up mfs from /cdboot/mfs.tgz'
-fi
-chmod 755 /dev /etc /var
-chmod a+rwx,a+t /tmp
-
-echo ''
-echo "Check date"
-date
-echo 'Set date via following format'
-date '+ %Y%m%d%H%M (yyyymmddhhmm) [if ok, press return with no date]'
-echo -n '> '
-read date
-if [ "$date" != "" ]; then
- date -n $date
-fi
-if [ ! -d /cdboot ]; then
- mount -uw / # root on nfs requires this, others aren't hurt
- rm -f /fastboot # XXX (root now writeable)
-fi
+mount -uw / # root on nfs requires this, others aren't hurt
+rm -f /fastboot # XXX (root now writeable)
# set flags on ttys. (do early, in case they use tty for SLIP in netstart)
echo 'setting tty flags'
@@ -187,23 +124,12 @@
)
fi
-if [ -f /etc/hostname.dhcp ]; then
- _IFS=`get_ifdevs`
- _IFS=`echo "$_IFS" | cutword`
-# only do the first interface (dhclient doesn't work for more than one).
- set -- $_IFS
- rm -f /etc/hostname.$1
- echo "ln -s /etc/hostname.dhcp /etc/hostname.$1"
- ln -s /etc/hostname.dhcp /etc/hostname.$1
-fi
# set hostname, turn on network
echo 'starting network'
. /etc/netstart
-if [ ! -d /cdboot ]; then
- mount /usr >/dev/null 2>&1
- mount /var >/dev/null 2>&1
-fi
+mount /usr >/dev/null 2>&1
+mount /var >/dev/null 2>&1
# if there's no /var/db/host.random, make one through /dev/urandom
if [ ! -f /var/db/host.random ]; then
##############################################################################
------------------------------------------------------------------------------
FreeBSD needs some things added and deleted for a floppy image to fit and work. The most important is: options ROOTDEVNAME="cd9660:acd0c" To make it fit on a 1.44mb floppy and since it is a CD, you can delete things like SOFTUPDATES, MD_ROOT, NFS, NFS_ROOT, USERCONFIG and VISUAL_USERCONFIG, device eisa and the devices that reside on it, and devices that are only available on the ISA bus, scsi bus devices, raid disks, pcmcia (cardbus) devices, parallel port devices, SLIP and PPP, memory disks (md), and USB devices. Looking at the floppy disk image creation configurations, and desiring to add things like samba and appletalk, the following are added:
pseudo-device vn # Vnode driver (turns a file into a device)
options NETATALK
options EXT2FS #Linux filesystem
options ROOTDEVNAME="cd9660:acd0c"
and for reducing of the kernel size:
options NFS_NOSERVER
options SCSI_NO_OP_STRINGS
options SCSI_NO_SENSE_STRINGS
options MAXDSIZ="(256*1024*1024)"
options DFLDSIZ="(256*1024*1024)"
Put the kernel file in the root directory for the mkisofs command. Put the same kernel as kernel.gz (gzip -9) into the boot.img file.
If you want to change the kernel floppy image, you may do something like the following for FreeBSD:
vnconfig -c vn0c DISK/cdboot/floppy.img
mount /dev/vn0c /mnt
cat kernel | gzip -9 > /mnt/kernel.gz
umount /mnt
vnconfig -u vn0c