|
In Section 3, it was pointed out that the /var filesystem constructed by /etc/rc.diskless2 and the presence of a read-only root filesystem causes problems with many common software packages used with FreeBSD. In this article, suggestions for successfully running cron, syslog, ports installations, and the Apache web server will be provided.
In /etc/rc.diskless2 there is a variable named var_dirs. This variable consists of a space-delimited list of directories that will be created inside of /var after it is mounted as a memory filesystem. cron and cron/tabs are not in that list, and without those directories, cron will complain. By inserting cron, cron/tabs, and perhaps even at, and at/jobs as elements of that variable, you will facilitate the running of the cron(8) and at(1) daemons.
However, this still does not solve the problem of maintaining cron tabs across reboots. When the system reboots, the /var filesystem that is in memory will disappear and any cron tabs you may have had in it will also disappear. Therefore, one solution would be to create cron tabs for the users that need them, mount your / filesystem as read-write and copy those cron tabs to somewhere safe, like /etc/tabs, then add a line to the end of /etc/rc.diskless2 that copies those crontabs into /var/cron/tabs after that directory has been created during system initialization. You may also need to add a line that changes modes and permissions on the directories you create and the files you copy with /etc/rc.diskless2.
syslog.conf specifies the locations of certain log files that exist in /var/log. These files are not created by /etc/rc.diskless2 upon system initialization. Therefore, somewhere in /etc/rc.diskless2, after the section that creates the directories in /var, you will need to add something like this:
# touch /var/log/security /var/log/maillog /var/log/cron /var/log/messages # chmod 0644 /var/log/*
You will also need to add the log directory to the list of directories that /etc/rc.diskless2 creates.
Before discussing the changes necessary to successfully use the ports tree, a reminder is necessary regarding the read-only nature of your filesystems on the flash media. Since they are read-only, you will need to temporarily mount them read-write using the mount syntax shown in Section 3. You should always remount those filesystems read-only when you are done with any maintenance - unnecessary writes to the flash media could considerably shorten its lifespan.
To make it possible to enter a ports directory and successfully run make install, it is necessary for the file /var/db/port.mkversion to exist, and that it has a correct date in it. Further, we must create a packages directory on a non-memory filesystem that will keep track of our packages across reboots. Because it is necessary to mount your filesystems as read-write for the installation of a package anyway, it is sensible to assume that an area on the flash media can also be used for package information to be written to.
First, create a package database directory. This is normally in /var/db/pkg, but we cannot place it there as it will disappear every time the system is booted.
# mkdir /etc/pkg
Now, add a line to /etc/rc.diskless2 that links the /etc/pkg directory to /var/db/pkg. An example:
# ln -s /etc/pkg /var/db/pkg
Add another line in /etc/rc.diskless2 that creates and populates /var/db/port.mkversion
# touch /var/db/port.mkversion # chmod 0644 /var/db/port.mkversion # echo 20010412 >> /var/db/port.mkversion
where 20010412 is a date that is appropriate for your particular release of FreeBSD
Now, any time that you mount your filesystems as read-write and install a package, the make install will work because it finds a suitable /var/db/port.mkversion, and package information will be written successfully to /etc/pkg (because the filesystem will, at that time, be mounted read-write) which will always be available to the operating system as /var/db/pkg.
Apache keeps pid files and logs in apache_install/logs. Since this directory doubtless exists on a read-only filesystem, this will not work. It is necessary to add a new directory to the /etc/rc.diskless2 list of directories to create in /var, to link apache_install/logs to /var/log/apache. It is also necessary to set permissions and ownership on this new directory.
First, add the directory log/apache to the list of directories to be created in /etc/rc.diskless2.
Second, add these commands to /etc/rc.diskless2 after the directory creation section:
# chmod 0774 /var/log/apache # chown nobody:nobody /var/log/apache
Finally, remove the existing apache_install/logs directory, and replace it with a link:
# rm -rf (apache_install)/logs # ln -s /var/log/apache (apache_install)/logs
This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.
For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.
Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:40