# Custom FreeBSD ISO/IMG file



## GregTheHun (Nov 16, 2018)

Hello all, after searching for a while I've given up on trying to find some recent information on trying to create my own custom FreeBSD iso/img file that can be installable.

Simply, I'd like to get an installed setup that I like create some form of snapshot/iso/img file that I can then install on a USB drive much like the default FreeBSD iso/img and install that on any machine (given an architecture like amd64).

Can anyone help me with the right docs, or a simple set of commands to get a running system as is installable?


----------



## yuripv (Nov 16, 2018)

See release(7).


----------



## GregTheHun (Nov 16, 2018)

So, I'm assuming from the release page that I would type this:


```
# Add this to loader.conf, once the machine is setup the way I like.
geom_md_load="YES"

# Reboot, because it will definitely load the module and I don't mind waiting

# Then type this (possibly adding /usr/src/release to the release.sh script):
cd ~/
sh release.sh memstick FreeBSD-custom-img-file.img
```

Unless I have this totally wrong, then please let me know.


----------



## GregTheHun (Nov 17, 2018)

Plus, looking around in /usr/src, it appears to be empty.

I don't know what I'm missing to make this work.


----------



## ShelLuser (Nov 17, 2018)

First you need to have the source code installed and then learn how to use it. It's often installed together with your FreeBSD installation, but if it isn't then you could consider doing this: `svnlite co https://svn.freebsd.org/base/releng/11.2 /usr/src`, it'll take a while but after that you'll have the complete source tree installed in /usr/src, which is step one.

Now you'll have access to /usr/src/release and can go crazy 

Even so I'd recommend to become familiar with the source tree first. Try upgrading your system for example, and look into things like /etc/src.conf (see src.conf(5)) and how to configure this thing (/usr/src/sys/amd64/conf/GENERIC).

A good start (IMO) would be chapter 25.3 of the handbook: upgrade FreeBSD from source, as well as chapter 8: configuring the FreeBSD kernel.

And there's always these forums


----------



## GregTheHun (Nov 17, 2018)

Good reads and will do, hopefully I can get an installable custom FreeBSD image soon.

Typically I just take the default installer and install a few things like bash, sshguard, and configure pf and ssh to get my main system to a point where I can use it faster and more securely.

Then I’m on my way, I just hate when I want to install it on another machine that I have to keep going through the same configuration files over and over. I just want a “.img” file that I can install on a given architecture and go ahead with other fun installs.

I’ll let you guys know how it progresses and post my steps when I can.


----------



## GregTheHun (Nov 18, 2018)

Welp, unfortunately, this was the last error I got trying to run the command at the bottom next to the green cursor position box.


----------



## Phishfry (Nov 19, 2018)

First off I think you probably want to build images using root user.
Second for the statfs(2) error there are only so many error conditions looking at the manual.
I don't see the error code in your snapshot but this stands out to me in the manual:


> [EACCES] Search permission is denied for a component of the path prefix of _path_.


I am building a release image now just to test.  Have you built an unmodified RELEASE first to prove your method?
`cd /usr/src/release`
`./release.sh memstick test.img`
Too long a path is also a statfs error so I shortened the image name.


----------



## Phishfry (Nov 19, 2018)

Some notes while waiting: You really should have >16GB disk space free when building RELEASE.
It is rather slow on a i3-2330M. I opened an xfce4 terminal and its been chugging along for over 6 hours now.
Clang building takes quite a bit of time.


----------



## GregTheHun (Nov 19, 2018)

Yes, I do have greater than 16gb of space, it’s mostly a new machine plus some small additions like screen as you might’ve noticed. Will give a whirl and report.


----------



## Phishfry (Nov 19, 2018)

I have never built release and I am unsure of the syntax.
To me it looks like you need to:
`cd /usr/src`
`make -j 8 buildworld && make -j 8 buildkernel KERNCONF=GENERIC`
Then:
`cd /usr/src/release`
`make memstick`

https://www.freebsd.org/cgi/man.cgi?release(7)
http://blog.cochard.me/2013/06/generating-custom-freebsd-installation.html

Currently my /scratch CHROOT is at 10GB, so release.sh is still chugging along.
I could swear I have seen Stage 3 come up twice.


----------



## Phishfry (Nov 19, 2018)

It failed for me with the same warning. Same spot too right after buildworld.
I am trying on a faster machine with the above approach.


----------



## Phishfry (Nov 19, 2018)

OK got through buildworld and buildkernel quick and can confirm that `make memstick` runs as expected.
Will update if successful. I should end up with a memstick.img located somewhere.


----------



## Phishfry (Nov 19, 2018)

That worked and made a 940 megabyte /usr/obj/usr/src/amd64.amd64/release/memstick.img.
No custom packages or conf's though like you wanted..


----------



## Phishfry (Nov 19, 2018)

I am trying a different way:
`cd /usr/src/release`
`./release.sh -c /usr/src/release/amd64/amd64.conf memstick`


----------



## Phishfry (Nov 19, 2018)

That method failed as it is trying to use FreeBSD 13 source.

```
cd: /usr/doc/en_US.ISO8859-1/htdocs/releases/13.0R: No such file or directory
```


----------



## Phishfry (Nov 19, 2018)

This post seems to be relevant:
https://forums.freebsd.org/threads/...ase-sh-generate-release-sh.49925/#post-279167


bsdnet said:


> release.sh always tried to get the latest code from SVN.




So you need to modify amd64.conf to change the SRC:

```
SRCBRANCH="base/releng/11.2"
DOCBRANCH="doc/release/11.2.0"
PORTBRANCH="ports/branches/2018Q4"
```


----------



## Phishfry (Nov 20, 2018)

That worked but it ignored the memstick directive and built mini-memstick, memstick, iso and bootonly.
Here is the tail end of the console output:

```
make -C /usr/src/release  release-done
touch release
true
mkdir -p /R
cp -a ftp /R/
cp -p disc1.iso /R/FreeBSD-11.2-RELEASE-p4-amd64-disc1.iso
cp -p bootonly.iso /R/FreeBSD-11.2-RELEASE-p4-amd64-bootonly.iso
cp -p memstick.img /R/FreeBSD-11.2-RELEASE-p4-amd64-memstick.img
cp -p mini-memstick.img /R/FreeBSD-11.2-RELEASE-p4-amd64-mini-memstick.img
cd /R && sha512 FreeBSD-11.2-RELEASE-p4-amd64* > /R/CHECKSUM.SHA512
cd /R && sha256 FreeBSD-11.2-RELEASE-p4-amd64* > /R/CHECKSUM.SHA256
```

I created a custom config file /usr/src/release/my.conf

```
TARGET="amd64"
TARGET_ARCH="amd64"
KERNEL="GENERIC"
SRCBRANCH="base/releng/11.2"
DOCBRANCH="doc/release/11.2.0"
PORTBRANCH="ports/branches/2018Q4"
```
Ran it with:
`cd /usr/src/release`
`./release.sh -c my.conf memstick`


----------



## aht0 (May 12, 2019)

Did you get anywhere with including custom configs etc?


----------



## GregTheHun (May 12, 2019)

No, but this is something I would like to post more on when I test this with 12.0 since that’s current now.


----------

