cvs commit: src/tools/tools/nanobsd Makefile i386.diskimage

Andrea Campi andrea+freebsd_current at
Sat Aug 21 11:04:28 PDT 2004

Hi Thomas,

On Mon, Aug 16, 2004 at 10:41:58PM +0000, Thomas Quinot wrote:
> thomas      2004-08-16 22:41:58 UTC
>   FreeBSD src repository
>   Modified files:
>     tools/tools/nanobsd  Makefile i386.diskimage 
>   Log:
>   Properly identify the root filesystem to be used in /etc/fstab in each
>   slice of the flash card, ensuring that the loader will mount the root fs
>   from the booted slice by default.

I think this is not what you intended to do:

RCS file: /usr/local/www/cvsroot/FreeBSD/src/tools/tools/nanobsd/i386.diskimage,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- src/tools/tools/nanobsd/i386.diskimage	2004/05/28 21:23:23	1.7
+++ src/tools/tools/nanobsd/i386.diskimage	2004/08/16 22:41:58	1.8
@@ -43,18 +69,40 @@ fdisk ${MD}
 boot0cfg -B -b ${WD}/boot/boot0sio -s 1 -m 3 ${MD}
 rm -f ${TMPFILE1}
 bsdlabel -w -B ${MD}s1
-newfs -O1 -U ${MD}s1a
-newfs -O1 -U ${MD}s3
+# Prepare primary root slice
+newfs ${PRIROOTLABEL} -O1 -U ${MD}s1a
 mount /dev/${MD}s1a ${TMPMNT}
 (cd ${WD} && find . -print | cpio -dump ${TMPMNT}) || true
+make_fstab ${PRIROOTSLICE}
 df ${TMPMNT}
 umount ${TMPMNT}
+# Prepare alternative root slice
+dd if=/dev/${MD}s1 of=/dev/${MD}s2 bs=64k
+if [ -n "${ALTROOTLABEL}" ]; then
+  tunefs ${ALTROOTLABEL} /dev/${MD}s2a
+mount /dev/${MD}s2a ${TMPMNT}
+make_fstab ${ALTROOTSLICE}
+umount ${TMPMNT}

make_fstab creates the /etc/fstab file in ${WD}, but in both cases
you call it *after* copying from ${WD} to the destination filesystem,
so in fact they are noops. I think you should probably change make_fstab
like this:

make_fstab () {
  echo "/dev/$1 / ufs ro 1 1" > $2/etc/fstab

and pass it the destination:

make_fstab ${ALTROOTSLICE} ${TMPMNT}

What do you think? I can send you a diff if you prefer.


                  Weird enough for government work.

More information about the freebsd-current mailing list