View Single Post
  #9   (View Single Post)  
Old 11th January 2016
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

I just tested the procedure and it works on an Alix board with an OpenBSD current version of :
Code:
OpenBSD 5.8-current (GENERIC) #1430: Sat Dec 12 09:13:24 MST 2015
    deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
I have a attached a transcript (serial cable console connection) Please note that I use the more descriptive directory name /Template.mfs as source to populate the mfs.

An excerpt of the interesting part where the test directory /monkey is being edited into the /var.
Code:
    171 ------ So reboot works ....
    172 Now adjusting to really using /var instead of /monkey
    173 -------------------------------------------------------
    174 
    175 ------------ reboot to single user mode
    176 Note that I am connected with a serial console.
    177 Single user mode will stop networking, so if you are logged in with SSH you have a problem. ....
    178 
    179 --- see init(8) for more info about sending a 'TERM' signal to process nr 1 ...
    180 
    181 root@alix[~]kill -TERM 1
    182 Enter pathname of shell or RETURN for sh: 
    183 
    184 \u@\h[\w]                                                               
    185 \u@\h[\w]mount
    186 /dev/wd0a on / type ffs (local, noatime, softdep)
    187 /dev/wd0e on /home type ffs (local, noatime, nodev, nosuid, softdep)
    188 /dev/wd0d on /usr type ffs (local, noatime, nodev, softdep)
    189 
    190 -- So we lost our 'mfs' file system ...
    191 
    192 --- delete the contents of the /var directory, so we only have an empty
    193 --- /var directory as mount point for the mfs reincarnation of /var 
    194  
    195 \u@\h[\w]rm -r /var/*
    196 \u@\h[\w]ls -l /var
    197 
    198 \u@\h[\w]cat /etc/fstab
    199 72e6d0f437619269.b none swap sw
    200 72e6d0f437619269.a / ffs rw,noatime,softdep 1 1
    201 72e6d0f437619269.e /home ffs rw,noatime,softdep,nodev,nosuid 1 2
    202 72e6d0f437619269.d /usr ffs rw,noatime,softdep,nodev 1 2
    203 swap               /monkey mfs rw,noatime,nosuid,noexec,-P=/Template.mfs/var,-s=80000
    204 
    205 --- copy the /etc/fstab file
    206 
    207 \u@\h[\w]cp /etc/fstab /etc/fstab.orig
    208 
    209 --- test with sed(1) to change 'monkey' into 'var'
    210 
    211 \u@\h[\w]sed -e 's/monkey/var/' /etc/fstab.orig
    212 
    213 72e6d0f437619269.b none swap sw
    214 72e6d0f437619269.a / ffs rw,noatime,softdep 1 1
    215 72e6d0f437619269.e /home ffs rw,noatime,softdep,nodev,nosuid 1 2
    216 72e6d0f437619269.d /usr ffs rw,noatime,softdep,nodev 1 2
    217 swap               /var mfs rw,noatime,nosuid,noexec,-P=/Template.mfs/var,-s=80000
    218 
    219 --- Now the real thing ...
    220 
    221 \u@\h[\w]sed -e 's/monkey/var/' /etc/fstab.orig >/etc/fstab
    222 \u@\h[\w]cat /etc/fstab
    223 72e6d0f437619269.b none swap sw
    224 72e6d0f437619269.a / ffs rw,noatime,softdep 1 1
    225 72e6d0f437619269.e /home ffs rw,noatime,softdep,nodev,nosuid 1 2
    226 72e6d0f437619269.d /usr ffs rw,noatime,softdep,nodev 1 2
    227 swap               /var mfs rw,noatime,nosuid,noexec,-P=/Template.mfs/var,-s=80000
    228 
    229 --- Looks good so we can reboot 
    230 \u@\h[\w]reboot
    231 dd: /var/db/host.random: No such file or directory
    232 chmod: /var/db/host.random: No such file or directory
    233 dd: /var/db/host.random: No such file or directory
    234 single user: not running shutdown scripts
    235 syncing disks... done
    236 rebooting...
    252 root@alix[~]mount                                                       
    253 /dev/wd0a on / type ffs (local, noatime, softdep)
    254 /dev/wd0e on /home type ffs (local, noatime, nodev, nosuid, softdep)
    255 /dev/wd0d on /usr type ffs (local, noatime, nodev, softdep)
    256 mfs:1731 on /var type mfs (asynchronous, local, noatime, noexec, nosuid, size=80000 512-blocks)
    257 
    258 root@alix[~]ls -l /var
    259 total 40
    260 drwxr-xr-x  2 root  wheel      512 Dec 12 17:05 account
    261 drwxrws---  2 root  wheel      512 Dec 12 17:05 audit
    262 [snip]
    263 drwxr-xr-x  4 root  wheel      512 Dec 12 17:05 unbound
    264 drwxr-xr-x  2 root  wheel      512 Dec 12 17:06 yp
    265 
    266 root@alix[~]df -h
    267 Filesystem     Size    Used   Avail Capacity  Mounted on
    268 /dev/wd0a      873M   44.2M    785M     5%    /
    269 /dev/wd0e      376M    9.8M    348M     3%    /home
    270 /dev/wd0d      2.2G    185M    1.9G     9%    /usr
    271 mfs:1731      37.7M    3.5M   32.3M    10%    /var
    272 
    273 --- end of transcript (slightly edited of course ;) )
Re: /tmp directory

I don't think it worth to move /tmp to use a memory file system. It usually is empty.
Another reason is the following section of mount_mfs(1):
Code:
ENVIRONMENT
     TMPDIR  Directory in which to create temporary mount points for use by
             mount_mfs -P instead of /tmp.
I just wonder how that would work if /tmp is configured to be a memory file system....

Re: /dev

Some people also use a MFS for /dev. See https://www.mail-archive.com/openbsd.../msg01014.html

I will try that another day ...

BTW In case of questions you can use $ less -N alix-mfs.txt to see or refer to the line numbers of the transcript.
Attached Files
File Type: txt alix-mfs.txt (10.0 KB, 65 views)
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote