# Modifying FreeBSD 10 ISO



## ideaflow (Jul 15, 2014)

I am trying to create a customised version of the FreeBSD boot ISO. I have tried a number of methods and nothing quite seems to work. One problem I have is extracting the contents of the original ISO. I have tried these methods:

`tar -C /path/to/isofolder/ -pxvf /path/to/iso`
This command seems to produce some errors while extracting the files, although they whiz past too quickly to see properly, one error reporting it was ignoring a file, and maybe something about out of sequence, as well as some 'can't create' messages.

And

`mdconfig -a -t vnode -f file.iso -u 0`
`mount_cd9660 /dev/md0 /mnt/freebsd_install/`
`cp -R /mnt/freebsd_install/* /path/to/isofolder/`

Then I modify one of the scripts in these folders and then I try and create my modified ISO from the contents of the folder I have modified.

`mkisofs -J -R -V "Custom" -no-emul-boot -b boot/cdboot -o ~/mycustom.iso /path/to/isofolder/`

However, the ISO file I create always seems to be much larger than the original ISO, even if I just add one extra word to an existing script. E.g. original ISO is 652,998,656 bytes, my new ISO is 841,009,152 bytes!

My original (mounted) ISO folder is showing a size of 796,377k (using the du command) and the copied folder (mounting and copying) is 842,648k. It looks like the original iso is compressing the contents somehow, and that the copy process is also adding extra stuff in there. The tar extraction method yields a folder size of 639,852k.

As a result my new ISO is too big to fit on a CD when I use the mount and copy method, despite the original being well short of the maximum size. If I use the tar extraction method I end up with an ISO that can fit onto CD but this doesn't seem to work properly, the initial boot is okay, but after selecting the boot option 'multi-user' the boot goes most of the way through but then reports repeated MEDIUM_ERRORS and at the end reports that it fails with error 19.

I am basing my attempts on these articles:

http://www.freebsd.org/doc/en_US.ISO885 ... anced.html

viewtopic.php?f=4&t=39187&p=217349&hilit=mkisofs#p217349

Any ideas where these processes are going wrong? I was wondering if the original ISO has symlinks or something which the copy process is expanding or the tar process is not handling properly, but I don't know enough about FreeBSD and CD file systems to go any further with this.


----------



## SirDice (Jul 15, 2014)

I suggest you look into making a release(7). The process will allow you to build a custom FreeBSD installation CD, DVD, FTP and/or memory stick.


----------



## ideaflow (Jul 15, 2014)

Thanks for the suggestion. I had looked at that option and thought it seemed like rather a long winded way of going about changing one or two scripts in the install ISO.

This comment in the release man page worried me: "Before attempting to build a release, the user is expected to be familiar with the contents of build(7), and should have experience upgrading systems from source." That doesn't apply to me    

If I install a clean FreeBSD system along with docs, src, and ports, should I then just configure my release.conf file and run `release.sh -c release.conf` to create my own release? If I want to replicate a -RELEASE build rather than -CURRENT what do I put instead of 'head/@rHEAD'?

From the sounds of it, the release.sh script will run `make release` automatically, which would then give me the standard build. Should I make whatever modifications I want in the relevant CHROOTDIR and then run `make release` again to get my custom install media?


----------



## ideaflow (Jul 15, 2014)

Update:

I followed these steps on a machine with FreeBSD 10 and src installed:


```
cd /usr
cd src
make buildworld buildkernel
cd release
make release
make install DESTDIR=/var/freebsd-snapshot
```

That all seemed to work okay and memstick and ISO images are generated and the size looks about right (not tried them out yet). However, these images will just be a standard build. I couldn't find where I should go to modify scripts such as rc.local for example, and when I do find the right location and update a script, which steps do I need to re-run? I'm guessing `make release` and `make install`, would that be right?

As an aside the images generated have 'p6-i386' as part of the file name, 'i386' will refer to the processor, what does the p6 signify? Also has it defaulted to i386 because of my processor (this machine has a Intel Core 2 Duo) or because I used i386 install media originally?

Thanks.


----------



## SirDice (Jul 16, 2014)

ideaflow said:
			
		

> As an aside the images generated have 'p6-i386' as part of the file name, 'i386' will refer to the processor, what does the p6 signify?


That would be patch 6. If you updated your source after 8 July it will read p7. The latest source for releng/10.0 also contains security updates.



> Also has it defaulted to i386 because of my processor (this machine has a Intel Core 2 Duo) or because I used i386 install media originally?


Your system is i386 so it builds for i386 by default. It's possible to build for a different architecture though.


----------



## wblock@ (Jul 16, 2014)

Most Core2 processors can do 64-bit.  Once installed, the operating system does not auto-select, it just sticks with the architecture that was already installed.


----------



## ideaflow (Jul 16, 2014)

Thanks for the clarification on the architecture and path level indicators. I think my main question may have been missed amongst the rest of my update:

After running through the various make and release steps, which directory should I go to to modify scripts that run during the boot from install media. In particular I wish to replace the /etc/rc.local script with one that performs a custom install instead of the welcome menu the official build gives (the one with the 'Install', 'Shell', and 'Live CD' options). I also would like to add extra files to the installed FreeBSD system, so where should I put these so they end up on my custom release media? I can have my custom installation script copy them if necessary.

Thanks.


----------



## vince66 (Sep 6, 2018)

SirDice said:


> I suggest you look into making a release(7).


Dear SirDice ... this post is from 2014 ... It's 4 years that you always write :  I suggest you look into making a release(7).


My apologize... but ... have you tried to make one only time a release of FreeBSD ?


----------



## SirDice (Sep 6, 2018)

vince66 said:


> My apologize... but ... have you tried to make one only time a release of FreeBSD ?


On average about once a month from a recent -STABLE. I use those images to update my -STABLE jails on Poudriere.


----------



## vince66 (Sep 6, 2018)

SirDice said:


> I use those images to update my -STABLE jails on Poudriere.


But if you use Poudriere, probably you never tried release(7) ... so ...

why you write: "I suggest you look into making a release(7)."

By release(7) man page it is not very easy make a FreeBSD release, if it's the first time.

Ok ... i'll try to do by myself ... I hope there are no much problems with the release 11.2.


----------



## SirDice (Sep 6, 2018)

vince66 said:


> But if you use Poudriere, probably you never tried release(7) ... so ...


I'll repeat my first sentence, on average about once a month from a recent -STABLE. So yes, I do use release(7). 

I don't use the release.sh script, here's what I do:

```
svn update /usr/src
cd /usr/src
make clean
make buildworld buildkernel
cd release
make clean 
make -DNOPKG -DNODOC -DNOPORTS KERNCONF="GENERIC VBOX" release
make -DNOPKG -DNODOC -DNOPORTS KERNCONF="GENERIC VBOX" DESTDIR=/storage/release/11-stable install
root@molly:~ # ll /storage/release/11-stable/
total 2037916
-rw-r--r--  1 root  wheel        462 Aug 12 14:10 CHECKSUM.SHA256
-rw-r--r--  1 root  wheel        718 Aug 12 14:10 CHECKSUM.SHA512
-rw-r--r--  1 root  wheel  325468160 Aug 12 14:06 FreeBSD-11.2-STABLE-amd64-bootonly.iso
-rw-r--r--  1 root  wheel  664756224 Aug 12 14:05 FreeBSD-11.2-STABLE-amd64-disc1.iso
-rw-r--r--  1 root  wheel  731947520 Aug 12 14:07 FreeBSD-11.2-STABLE-amd64-memstick.img
-rw-r--r--  1 root  wheel  364814848 Aug 12 14:07 FreeBSD-11.2-STABLE-amd64-mini-memstick.img
drwxr-xr-x  2 root  wheel         12 Aug 12 14:04 ftp/
```
This provides me with everything I need. I don't need ports or packages on those images because I have my own Poudriere repositories. And I don't need the docs either.


```
root@molly:~ # poudriere jail -l | grep -- -STABLE
11-desktop  11.2-STABLE     amd64 url=file:///storage/release/11-stable/ftp 2018-08-12 14:14:21 /usr/local/poudriere/jails/11-desktop
11-server   11.2-STABLE     amd64 url=file:///storage/release/11-stable/ftp 2018-08-12 14:15:31 /usr/local/poudriere/jails/11-server
```


----------



## vince66 (Sep 6, 2018)

SirDice said:


> here's what I do


Please
let me take a look at what you do .... I need to study (and learn) any step.

Many many thanks !!!!
See you !


----------

