Building a customized FreeBSD ISO

I am following this link: http://www.cyclecide.com/~rudy/example/custom-freebsd.html to build a customized FreeBSD ISO.All I am in verse to include a mfi module to work.Though FreeBSD 8.2 includes mfi driver in GENERIC kernel but I need to include a new driver version from LSI website.

I performed these steps:

Code:
First, downlaod the ISO you want to start with (ftp.freebsd.org) 
Mount the ISO so you can 'see' inside it. 
    mdconfig -a -t vnode -f 8.2-x64-dvd.iso  -u 0
    mount_cd9660 /dev/md0 /mnt
    
Prepare a spot to modify the ISO contents. (We are going to copy everything and then make a new ISO.) 
    mkdir 8.2-x64-dvd.iso-custom
    cd 8.2-x64-dvd.iso-custom
    rsync -a /mnt/ .
    
 
     # find the source, unpack it, delete it
     cd 8.2-RC2/base
     mkdir TEMP &&  cat base.?? | tar --unlink -xpzf - -C TEMP
     rm base.??

     # Go there (into the new ISO staging area)
     cd TEMP

How can I proceed further. All I need is to:
patching the driver, replacing it,and running make release with the proper parameters.

As I can't see sys/dev/mfi under /usr/src, I have no idea how to proceed further.

I have been suggested to follow http://romana.now.ie/writing/customfreebsdiso.html link but it seems to be little complicated.
 
I tried all the above, read the comments, the man pages, the handbook, random howtos, etc. and nothing worked. [EDIT: by the way, I am building 8-STABLE here, and don't know if the same applies to 9-*]

In the end, this is what worked. It is clearly a hack, and appears as if the FreeBSD release system is broken. But I am guessing it is a documentation issue, otherwise I would never been able to download an iso ;)


  1. Download the sources through cvsup (rather than csup, but maybe both work)
    This step inspired by these 2 pages:
    http://romana.now.ie/writing/customfreebsdiso.html
    http://wiki.idefix.fechner.net/index.php/FreeBSD-Build_Own_CD

    I downloaded them to /usr/cvs
  2. Put them in a CVS root, following these instructions:

    http://www.freebsd.org/doc/en/articles/cvs-freebsd/article.html

    Here is exactly what I did (same as handbook with different paths):
    Code:
            % mkdir /usr/ncvs
            % cvs -d /usr/ncvs init
            % cd /usr/cvs2
            % cvs -d /usr/ncvs checkout CVSROOT
            % cd CVSROOT
            % cp /usr/cvs/* .
            % cvs add *

  3. Patch the Makefile (hack #1, my own idea):

    Code:
    --- /usr/src/release/Makefile   2012-01-24 10:22:36.550332286 +0100
    +++ /usr/cvs2/CVSROOT/src/release/Makefile      2012-01-26 11:48:45.793630981 +0100
    @@ -499,6 +499,12 @@
     .endif
     .endif
     .endif
    +#pm: added hack
    +       -test -f asdfasdf && echo "Copying whole src since it is missing"
    +       if [ ! -f ${CHROOTDIR}/usr/src/sys/conf ]; then \
    +               cp -an /usr/cvs2/CVSROOT/src// ${CHROOTDIR}/usr/src/ ; \
    +       fi
    +
            # Add version information to those things that need it.
            if [ ! -f ${CHROOTDIR}/tmp/.world_done ]; then \
                    cd ${CHROOTDIR}/usr/src/sys/conf && \

    Without this patch, I was getting this error:
    Code:
            ...
            cvs checkout: Updating src/usr.sbin/zzz
            rm -rf /root/archive/FreeBSD/usr/ports
            # Add version information to those things that need it.
            if [ ! -f /root/archive/FreeBSD/tmp/.world_done ]; then  cd /root/archive/FreeBSD/usr/src/sys/conf && [newline added for readability]
            mv newvers.sh foo &&  sed "s/^RELEASE=.*/RELEASE=8.2-STABLE-20110927/" foo > newvers.sh &&  rm foo;  fi
            cd: can't cd to /root/archive/FreeBSD/usr/src/sys/conf
            *** Error code 2

    The "-test -f asdfasdf" part of my patch is just because I don't understand how to write/edit a Makefile, and echo alone didn't work.
  4. Make a symlink (hack #2, my own idea)

    # ln -s /usr/cvs2/CVSROOT /usr/cvs2/CVSROOT/

    Without this, I got this error:
    Code:
            cd /root/archive/FreeBSD/usr &&   cvs -R  -d /usr/cvs2/CVSROOT  co  -P src
            cvs [checkout aborted]: /usr/cvs2/CVSROOT/CVSROOT: No such file or directory
            *** Error code 1
  5. Run make

    # make release BUILDNAME=8.2-STABLE-20110927 CHROOTDIR=/root/archive/FreeBSD CVSROOT=/usr/cvs2/CVSROOT

    FYI I also tried without the symlink and:

    # make release BUILDNAME=8.2-STABLE-20110927 CHROOTDIR=/root/archive/FreeBSD CVSROOT=/usr/cvs2

    which just results in a different error.
  6. Make iso files (last part mentioned here).

    If you were planning on adding some scripts and other files, add them now to dvd1.

    # cd /usr/cvs2/CVSROOT/src/release/amd64/

    # sh mkisoimages.sh -b FreeBSD82STABLE20110927 ~/archive/FreeBSD-8.2-STABLE-20110927.iso ~/archive/FreeBSD/R/cdrom/dvd1

And thanks for the links, which helped a bunch. The handbook seems to have nothing at all about "make release".
 
When did you insert the mfi module? I don't see any step talking about it. Please suggest. All I want to build is FreeBSD 9.0 with customized mfi driver.
 
peetaur said:

Thanks for the above link.
I am following http://wiki.idefix.fechner.net/index.php/FreeBSD-Build_Own_CD completely.
On one of the step it says
Code:
Then apply your changes to /usr/src (kernel config files, patches everything you need).

Is that talking about /usr/src/sys/amd64/conf/GENERIC kernel? What entry I need here related to mfi?

Also
Code:
Create a directory for own packages that will be included to the CD:
mkdir -p /root/ownpackages/disc1
Now copy all packages to the directory /root/ownpackages/disc1.

Copy all packages ..which packages it's talking about?

Again, my question is what about the mfi driver I have? Do I need to do diff here to insert it as a patch?
 
linuxunix said:
What is cvs2 here?

I look back at what I wrote and am as confused as you are. I'll try to make sense of it... here is my old step 2 including comments, and the bold parts are new.

Code:
    make a directory to create a real local cvs repository (not the working dir, but the repository itself)
        % mkdir /usr/ncvs
    initialize the repository    
        % cvs -d /usr/ncvs init
    [B]inserting this step here to fix a small bit of confusion: create the working directory
        % mkdir /usr/cvs2[/B]
    change to the working directory (not the repository, but the checked out version)
        % cd /usr/cvs2
    check out the repository you just created (which should be empty)
        % cvs -d /usr/ncvs checkout CVSROOT
    change directory to CVSROOT (I don't know why it is named that... I guess it is just a different standard than the normal trunk/branches/tags way to organize things)
        % cd CVSROOT
    copy your actual code (downloaded in my step #1 in a previous post) to the empty checked out cvs working directory (so now the working directory isn't empty)
        % cp /usr/cvs/* .
    add the files to the repository (so now the real cvs repository isn't empty)
        % cvs add *
    [B]at this point there was no commit/push or whatever the cvs equivalent is, but I didn't look that up since it works in the end anyway.[/B]
 
linuxunix said:
Thanks for the above link.
I am following http://wiki.idefix.fechner.net/index.php/FreeBSD-Build_Own_CD completely.
On one of the step it says
Code:
Then apply your changes to /usr/src (kernel config files, patches everything you need).

Is that talking about /usr/src/sys/amd64/conf/GENERIC kernel?

Yes, /usr/src/sys/amd64/conf/GENERIC is your "kernel config file". You should also back it up first, and you could also rename it, since it is not the "GENERIC" one anymore, but a modification of it.


linuxunix said:
What entry I need here related to mfi?

Unfortunately, I don't know. I thought it would be the same name as the kernel module that is built.

For example in my GENERIC file, which after (& not including) 8.2-RELEASE includes:
device mps # LSI-Logic MPT-Fusion 2
Which replaces the need to load the mps.ko kernel module.

But if you don't have a kernel module... I don't know which name you use. I would search elsewhere for other examples, and then try to find those examples in my GENERIC file to make sense of it.

This is also in my GEMERIC file:
device mfi # LSI MegaRAID SAS

So looking at that, I would assume that if you modified the existing mfi code (not copied it somewhere, renamed it, etc.) you can just verify that your kernel config file has mfi like mine, and that your changes to mfi are in your working source tree, and then just build without editing.


linuxunix said:
Also
Code:
Create a directory for own packages that will be included to the CD:
mkdir -p /root/ownpackages/disc1
Now copy all packages to the directory /root/ownpackages/disc1.

Copy all packages ..which packages its talking about?

I think this is the stuff you created using pkg_create. If you didn't create any, don't worry about it. (I skip this step, since you would use portsnap fetch, etc. to build the latest ports anyway.)

linuxunix said:
Again , my question is what about the mfi driver I have? Do I need to do diff here to insert it as a patch?

If you modified the mfi driver source code, you should have edited/patched the code in your build tree (in my example, the /usr/cvs2 directory), before the build. (Do I understand your question?)
 
One more comment about what I said about renaming "GENERIC" to something else, and step 5 in my original howto thing. If you rename it, then I guess the new name needs to go somewhere in step 5.
 
Thanks Peetaur for the quick response.

This is what I did until now(below). Suggest if this looks Ok.
Code:
Preparing the Local Repository:

mkdir -p /usr/local/etc/cvsup
cp /usr/share/examples/cvsup/cvs-supfile /usr/local/etc/cvsup/ncvs

Edit the file:
*default host=cvsup10.us.freebsd.org
*default base=/usr
*default prefix=/home/storage/ncvs
*default release=cvs
*default delete use-rel-suffix

*default compress

# Add these
src-all
src-crypto
src-eBones
src-secure
src-sys-crypto
ports-all
doc-all
#www

cvsroot-all

Checkout the sources:

mkdir /home/storage/ncvs
cvsup -g -L2 ncvs

Building the Custom ISO:

Delete /usr/src and check it out from your local repository:

cd /usr
rm -R src
mkdir -p /usr/src
cd /usr
cvs -R  -d /home/storage/ncvs  co  -P -r RELENG_6 src
cd /usr/
cp -pR src src.orig

Applying the Kernel changes:

Move to the arch/conf directory and copy the GENERIC configuration file to the name you want to give your kernel. For example:

         # cd /usr/src/sys/amd64/conf			
         # cp GENERIC MYKERNEL

Comment the following line in the file MYKERNEL by placing # at the   beginning of the line.


         device     cbb    #cardbus (yenta) bridge

Add the following line to the file /usr/src/sys/conf/files .

         dev/mfi/mfi_syspd.c     optional     mfi

  (Note add this line next to the line which has dev/mfi/mfi_cam.c optional mfi)


Copy the attached zip (mfi.zip) file under the path /usr/src/sys/dev (Before proceeding to next step make sure
 that the directory with name “mfi” does not exist under path /usr/src/sys/dev/. If already a directory with
 name “mfi” exists, move it to some other folder. 

Under the directory /usr/src/sys/dev, run the following command to unzip the source.

            # tar –x –f mfi.zip

Now If I see the next suggested steps on http://wiki.idefix.fechner.net/index.php/FreeBSD-Build_Own_CD it says
"..We will use a unattened install procedure to install the own build kernels so we don't have to modify the sysinstall package.."

To use our own install script edit:
/usr/src/usr.sbin/sysinstall/Makefile
and add:
CFLAGS+= -DLOAD_CONFIG_FILE=install.cfg
Now create a install.cfg file in /usr/src/release for an example see here.
Create a directory for own packages that will be included to the CD:
mkdir -p /root/ownpackages/disc1
Now copy all packages to the directory /root/ownpackages/disc1.
Make a diff with:
cd /usr
diff -Nur src.orig src >/root/patch.diff

No idea if I really need it. What actually packages I need here. Still didn't get it.

As of now, what I did is added
Code:
CFLAGS+= -DLOAD_CONFIG_FILE=install.cfg
to /usr/src/usr.sbin/sysinstall/Makefile and created an install.cfg file in /usr/src/release and created a directory (/root/ownpackages/disc1) for own packages that will be included to the CD. Skipped this
Now copy all packages to the directory /root/ownpackages/disc1.
Just ran :

Code:
cd /usr
diff -Nur src.orig src >/root/patch.diff

Will it be sufficient. When I ran the last command, it's asking file to patch:
What issue it could be?
 
Hi,

I am struggling hard to build a custom ISO.
if you can elaborate your overall steps that would help me with my new mfi driver.
 
Back
Top