You might have seen that tmpfs support for pax(1) landed on master. I would like to switch the Makefile for bsd.rd to use pax(1) instead of mount + mount -u for creating the snapshot image. This would make the build process easier to understand and has less room for bad side effects on failed builds (a filesystem which didn't get unmounted).
The code to do that is available on the natano_ramdisk_pax branch. (diff included below for convenience; tested on amd64) Comments, oks or test reports? cheers, natano commit 43be65ebdac89153e227db982a816c7dd91a246f Author: Martin Natano <[email protected]> Date: Mon Dec 8 16:36:32 2014 +0100 Use pax(1) to build the file system for bsd.rd. diff --git a/distrib/amd64/ramdisk/Makefile b/distrib/amd64/ramdisk/Makefile index b891d85e..fc7d1f0 100644 --- a/distrib/amd64/ramdisk/Makefile +++ b/distrib/amd64/ramdisk/Makefile @@ -7,9 +7,8 @@ CRUNCHCONF?= ${CBIN}.conf LISTS= ${.CURDIR}/list UTILS?= ${.CURDIR}/../../miniroot -MOUNT_POINT= /mnt +FSDIR= ${.OBJDIR}/fs MTREE= ${UTILS}/mtree.conf -TMPFS_MAXSIZE= 255M .NOTPARALLEL: @@ -27,21 +26,15 @@ bsd: exec ${MAKE}; } cp ${ARCH}/compile/GENERIC/bsd bsd -${IMAGE}: ${CBIN} tmpfs_setup do_files tmpfs_snapshot tmpfs_teardown - -tmpfs_setup: ${CBIN} - mount -t tmpfs -o -s${TMPFS_MAXSIZE} tmpfs ${MOUNT_POINT} - -tmpfs_snapshot: - rm -f ${IMAGE} - mount -t tmpfs -u -o snapshot ${IMAGE} ${MOUNT_POINT} - -tmpfs_teardown: - @df -i ${MOUNT_POINT} - -umount ${MOUNT_POINT} - -unconfig: - -umount -f ${MOUNT_POINT} +${IMAGE}: ${CBIN} + rm -rf ${FSDIR} + install -d -o root -g wheel ${FSDIR} + mtree -def ${MTREE} -p ${FSDIR}/ -u + TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} \ + REV=${REV} TARGDIR=${FSDIR} UTILS=${UTILS} \ + RELEASEDIR=${RELEASEDIR} sh ${UTILS}/runlist.sh ${LISTS} + rm ${FSDIR}/${CBIN} + (cd ${FSDIR} && pax -w -f ${.OBJDIR}/${IMAGE} -x tmpfs {,.}*) .PRECIOUS: ${IMAGE} @@ -61,17 +54,11 @@ ${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c ${CRUNCHCONF}: ${LISTS} awk -f ${UTILS}/makeconf.awk CBIN=${CBIN} ${LISTS} > ${CRUNCHCONF} -do_files: - mtree -def ${MTREE} -p ${MOUNT_POINT}/ -u - TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} \ - REV=${REV} TARGDIR=${MOUNT_POINT} UTILS=${UTILS} \ - RELEASEDIR=${RELEASEDIR} sh ${UTILS}/runlist.sh ${LISTS} - rm ${MOUNT_POINT}/${CBIN} - clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}*.cache \ *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip \ lib*.a lib*.olist ${CBIN}.map boot ${CRUNCHCONF} + /bin/rm -rf ${FSDIR} .include <bsd.own.mk> .include <bsd.obj.mk> diff --git a/distrib/armv7/ramdisk/Makefile b/distrib/armv7/ramdisk/Makefile index e72ba7f..2ecefe4 100644 --- a/distrib/armv7/ramdisk/Makefile +++ b/distrib/armv7/ramdisk/Makefile @@ -12,7 +12,7 @@ CRUNCHCONF?= ${CBIN}.conf LISTS= ${.CURDIR}/list UTILS?= ${.CURDIR}/../../miniroot -MOUNT_POINT= /mnt +FSDIR= ${.OBJDIR}/fs MTREE= ${UTILS}/mtree.conf VND?= vnd0 @@ -21,8 +21,6 @@ VND_RDEV= /dev/r${VND}a VND_CRDEV= /dev/r${VND}c PID!= echo $$$$ -TMPFS_MAXSIZE= 64M - KERNADDR_EXYNOS=0x40300000 KERNADDR_IMX=0x10300000 KERNADDR_OMAP=0x80300000 @@ -61,25 +59,18 @@ ${BSD_RD}.${SOC}.umg: ${BSD_RD} ${BSD_RD} ${BSD_RD}.${SOC}.umg .endfor -${IMAGE}: tmpfs_setup do_files tmpfs_snapshot tmpfs_teardown +${IMAGE}: + rm -rf ${FSDIR} + install -d -o root -g wheel ${FSDIR} + mtree -def ${MTREE} -p ${FSDIR}/ -u + TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} \ + REV=${REV} TARGDIR=${FSDIR} UTILS=${UTILS} \ + RELEASEDIR=${RELEASEDIR} sh ${UTILS}/runlist.sh ${LISTS} + rm ${FSDIR}/${CBIN} + (cd ${FSDIR} && pax -w -f ${.OBJDIR}/${IMAGE} -x tmpfs {,.}*) .endif -tmpfs_setup: - mount -t tmpfs -o -s${TMPFS_MAXSIZE} tmpfs ${MOUNT_POINT} - -tmpfs_snapshot: - rm -f ${IMAGE} - mount -t tmpfs -u -o snapshot ${IMAGE} ${MOUNT_POINT} - -tmpfs_teardown: - @df -i ${MOUNT_POINT} - -umount ${MOUNT_POINT} - -unconfig: - -umount -f ${MOUNT_POINT} - -vnconfig -u ${VND} - .PRECIOUS: ${IMAGE} ${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} @@ -91,19 +82,13 @@ ${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c ${CRUNCHCONF}: ${LISTS} awk -f ${UTILS}/makeconf.awk CBIN=${CBIN} ${LISTS} > ${CBIN}.conf -do_files: - cat ${MTREE} | mtree -de -p ${MOUNT_POINT}/ -u - TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} \ - REV=${REV} TARGDIR=${MOUNT_POINT} UTILS=${UTILS} \ - RELEASEDIR=${RELEASEDIR} sh ${UTILS}/runlist.sh ${LISTS} - rm ${MOUNT_POINT}/${CBIN} - clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ lib*.a lib*.olist ${CBIN}.map \ *.o *.lo *.c ${ALLBSD} ${ALLBSDRD} rm -f instbin.conf rm -rf cd-dir + /bin/rm -rf ${FSDIR} .ifdef RELEASEDIR install:
