Recreating the FreeBSD Installation Disks

Ian Smith smithi at
Thu Aug 28 14:04:27 UTC 2014

In freebsd-questions Digest, Vol 534, Issue 7, Message: 2
On Wed, 27 Aug 2014 09:25:17 -0500
"Martin G. McCormick" <martin at> wrote:

 > 	I have been asking lots of questions recently about
 > whether the procedure for building a custom FreeBSD installation
 > CD has changed and it apparently has not but the problem I am
 > having is not hard to define.
 > The original image downloaded from is:
 > FreeBSD-9.1-RELEASE-amd64-disc1.iso and it is
 > 718862336 bytes large.
 > I mounted it on a FreeBSD9 system as follows:
 > ##Set up memory disk.
 > # mdconfig -f FreeBSD-9.1-RELEASE-amd64-disc1.iso -u 1
 > ##Mount it.
 > #mount -t cd9660 /dev/md1 /mnt2
 > 	Everything looks normal if you ls /mnt2.
 > If one was to use mkisofs with /mnt2 as the top of the tree, a
 > new iso image file should appear somewhere that is about the
 > same size as the starting ISO file. As a test to see if this
 > happens, I did the following:
 > #   mkisofs -J -R -V customBSD -no-emul-boot -b boot/cdboot -iso-level 3 -o \
 > #/home/martin/tmp/serialcd64.iso .
 > #ls -l /home/martin/serialcd64.iso
 > -rw-r--r--  1 root  martin  833892352 Aug 26 10:48 serialcd64.iso
 > Man! I sure wish my pay check could do that after a week of
 > living.

I wish I could make a millionth of that in a week :)

Your mkisofs usage differs from /usr/src/release/amd64/ 
(or /i386/, the same) which might be worth comparing with the above.

 > 	I know that hard links will make tar and rsync produce
 > larger outputs if not called correctly. My understanding is that
 > hard links are multiple sets of inode numbers pointing to the
 > same files so they are hard to mechanically distinguish from
 > actual disk space being occupied by the same data in more than
 > one spot.

My reading of ln(1) leads me to believe that hard links are multiple 
directory entries (on the same filesystem) pointing to the same inode?
But reading and observation is all I know about hard links ..

 > 	When one needs to make a custom CD, the extremely
 > difficult part is recreating the steps that were used to
 > originally build the image.

/usr/src/release has all the goodies, the Makefile shows the options.

 > 	An amusing side note; I used rsync to create a writable
 > copy of the tree as follows:
 > #cd ./treetop
 > #sudo rsync -a /mnt2/ ./
 > 	A few seconds later, I had something that built without
 > a single complaint so I made an image out of treetop and got:
 > #ls -l custom*
 > -rw-r--r--  1 martin  martin  455213056 Aug 26 11:42 custom.iso
 > 	That was the exact same file tree that insists on being
 > 120 MB too large if you try to make a straight ISO image from
 > the mounted file system of the original image which is about 300
 > MB larger than this one.

I guess you could list all the hard links and count their space with 
find and a bit of awk or such.  Similarly compare whole-tree filecounts?
I don't know if there are also different blocksizes to consider?

 > 	That has been pretty much the story of the last few days
 > and I am running out of things to try. The process for building
 > the FreeBSD installation CD is clever since it manages to cram
 > so much in to the limited space without compressing the entire
 > image. So far, orthogonalness has escaped me at every turn.

As I recall reading (only in passing, sorry) you wanted to do a shuffle 
using a linux box to make a memstick? and had problems with (some)tar?

I used Darren Pilgrim's 
to make bootable memsticks for both 10.0- and 9.2-RELEASE; I had pkg 
issues with 10.0 so reverted to 9.2-R which installed fine, (old-style) 
dvd packages and all.  So I expect should 9.1, and I don't see why this 
wouldn't work just as well from disc1 as from dvd1, but check that.

-rw-r--r--  1 smithi  smithi  2554132480 Mar 12 03:29 FreeBSD-9.2-RELEASE-amd64-dvd1.iso
-rw-r--r--  1 root    smithi  2789646336 Mar 12 03:52 FreeBSD-9.2-RELEASE-amd64-dvd1-memstick.img

Yes the memstick is ~235MB larger, I wasn't fussed.  Darren's script is 
based on /usr/src/release/amd64/{,} using 
this tar construct:

 tar cf - -C $2 . | tar xpf - -C $4  # $2 dvd mountpoint, $4 memstickdir

And then you get to mess with the memstick contents, after the makefs 
and before the gpart-itioning .. if you're going to add much to the 
release contents you may need to allocate extra space with the makefs?

For the record, if relevant to your issues, on 9.2 & 9.3 anyway:
 % which tar
 % ll /usr/bin/*tar*
 lrwxr-xr-x  1 root  wheel      6 Jun 25 16:09 /usr/bin/tar@ -> bsdtar
 -r-xr-xr-x  1 root  wheel  68712 Jun 25 16:09 /usr/bin/bsdtar*

HTH, Ian

More information about the freebsd-questions mailing list