Making parts of the filesystem read/write from NetBoot
Monday, October 30th, 2006So we use NetBoot (well NetInstall really) a lot here for diagnostics and as a platform for radminding machines from.
I’ve recently been refactoring our entire Radmind setup here, mainly because we’ve been using it for so long that we’re not actually taking advantage of any of the features Radmind has introduced in the last couple of years.
As part of this, I’ve been trying to avoid using our existing radmind wrapper script, and instead to try and do everything using the supplied ra.sh script, with appropriately configured preapply/postapply scripts, which is working rather nicely so far.
Anyway, to get to the point of this post, I worked out that if I wanted to use ra.sh while booted from a NetInstall image, I really needed /var/radmind to be read/write, which it isn’t.
After poking around through the /etc/rc.cdrom script, I noticed that Apple do things this way:
echo "Creating RAM Disk for /private/tmp" dev=`hdik -drivekey system-image=yes -nomount ram://2048 ` # 1MB if [ $? -eq 0 ] ; then newfs $dev mount -o union $dev /private/tmp fi
which is all rather dandy when you think about it. hdik is creating a 1Mb RAM disk, and then it is mounted as a union mount at /private/tmp, effectively making that directory read/write.
The only problem is that our Radmind transcripts take up about 40-50Mb, and you can’t use hdik to make a RAM disk of that size, which I imagine is a limitation of the fact that hdik is intended for rather lightweight disk images, being an in-kernel tool and all.
So I started poking around trying to work out how to use hdiutil to accomplish the same thing, but it turns out that hdid is actually far simpler. Rather than being an in-kernel tool, it will actually use the DiskImages.framework, which means the disk image limitations don’t hold.
So here’s what I add to /etc/rc.cdrom.postWS to create 96Mb of r/w space in /var/radmind
# Create r/w mount for /var/radmind and populate it with the file structure echo "Creating RAM disk for /var/radmind" dev=`hdid -nomount ram://196608` # 96Mb if [ $? -eq 0 ]; then newfs $dev mount -o union $dev /var/radmind mkdir /var/radmind/cert mkdir /var/radmind/client mkdir /var/radmind/postapply mkdir /var/radmind/preapply fi
and now everything is peachy.