Subject: Re: improvements to mknod(8)
To: None <tech-userlevel@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 02/07/2003 20:14:58
> The problem with that hack is that once you do it, you have to go through
> gyrations to populate a non-mfs /dev. While doable, it's not
> well-documented.

I suspect it could be automated and done in an rc script.
Something like (untested):

# see if /dev is memfs
mount -t memfs | grep -q ' on /dev ' || exit 0

# (or maybe) see if / and /dev are the same fs
root_dev="$(stat -f '%d') /`"
dev_dev="$(stat -f '%d') /`"
[ "$root_dev" = "$dev_dev" ] || exit 0

[ -d /.dev ] && rm -rf /.dev
[ -d /.dev_old ] && rm -rf /.dev_old
[ -e /.dev_old -o -e /.dev ] && error ...
mkdir /.dev || error....
cd /.dev || error ...
/dev/MAKEDEV all || error ...

cp /dev/MAKEDEV .
log="$(stat -f '%Y' /dev/log)"
[ -n "$log" ] && ln -s "$log" log

# we should now have a populated /dev in .dev, perform the switch
cd /
umount -f /dev
mv /dev /.dev_old || error ...
mv /.dev /dev || error ...

# new /dev in place
[ -d /.dev_old ] && rm -rf /.dev_old

	David

-- 
David Laight: david@l8s.co.uk