# FreeBSD custom installation CD/DVD



## bsaidus (Oct 4, 2014)

Hello all.
Can you help me by a tutorial or Step by step on how to create a FreeBSD custom installation CD/DVD?
I.E:
I have installed a fresh FreeBSD with some ports (Lighttpd, php, mc, mysql). so How can I create a CD/DVD installation from this install. thus When I install it I will not reinstall these ports.

Thank you in advance.


----------



## uzsolt (Oct 5, 2014)

From handbook:


> To build a customized release of FreeBSD, refer to the Release Engineering Article.


So I think the first point is to check this article.


----------



## SirDice (Oct 6, 2014)

bsaidus said:
			
		

> Can you help me by a tutorial or Step by step on how to create a FreeBSD custom installation CD/DVD?


There's a man page for it: release(7)


----------



## bsaidus (Oct 6, 2014)

Thanks for the feedback. But I'm asking for something else (if I can call that "Like appliances"). I want, in the end, a CD or DVD  that boots (like mfsBSD) with a script that I implement to install a whole OS (Some thing like pfSense or m0n0wall).

Thank you.


----------



## wblock@ (Oct 6, 2014)

bsaidus said:
			
		

> I want in final a CD or DVD  that boots (like mfsBSD) with a script that I impliment to install a whole OS (Some thing like pfsense or m0n0).



If mfsBSD is close, use it.  There was a talk at BSDCan 2012 about separating the FreeNAS GUI out into a reusable project which might also help: http://youtu.be/pgmbk53n5WY?list=PL4A10C737F224D0DC


----------



## bsaidus (Oct 8, 2014)

I've succeeded in creating a DVD that boots but at the moment of creating the MD0 it hangs mounting the filesystem, because there is no disk attached to it. in the attached image you will see:

Procedure that I've done:
All processes are done on a VMware workstation.
The VM for freebsd FreeBSD contains two hard disks, ad0, ad1.

 Installed a fresh minimal FreeBSD, deleted symbols in the kernel dirextory (*.symbols) and compressed kernel to kernel.gz.
Note: the partitions (/usr, /var, /tmp) are installed under the root (/) on ad0s1a (no other partitions) and ad0s1b for the swap.
for the disk ad1 I have only created a new file system for later use.
Rebooted the machine to start with mfsBSD.
Mounted the disks: ad0s1a under /mnt and ad1s1a under /media.
Created a copy of the file system initially installed on ad0sa1.
Executed a command: `du -hs /mnt` to get the size of the file system.
Created a file named: disk-img.dd on the second HDD like this: `dd if=/dev/zero of=/media/disk-img.dd bs=1k count = 358400` (the size is 350MB).
Created a directory called: /media/dz:  `mkdir /media/dz` and mounted the dd disk as follows: 
`mdconfig -a -t vnode -f /media/disk-img.dd` (the md created is 1 i.e. md1)
`bsdlabel -w md1`
`newfs md1a`
`mount /dev/md1a /media/dz`
Used cpdup to copy directory /mnt (which is the working Freebsd FreeBSD file system (ad0s1a)) to /media/dz (my disk image).
`cpdup -vv /mnt /media/dz`
After copying is done I unmounted my dd disk:
`unmount /media/dz`
`mdconfig -d -u 1`
`gzip`ped it to: disk-img.dd.gz
Moved disk-img.dd.gz to a directory called: /media/RELEASE/
Copied /boot directory from the FreeBSD DVD to /media/RELEASE:  `cp -r /cdrom/boot   /media/RELEASE/`.
Modied loader.rc to  as follows: 

```
geom_uzip_load="YES"
tmpfs_load="YES"
mfs_load="YES"
mfs_type="mfs_root"
mfs_name="/disk-img.dd"
ahci_load="YES"
vfs.root.mountfrom="ufs:/dev/md0"
```


Created an ISO image of the directory /media/RELEASE: 
`mkisofs -b boot/cdboot -no-emul-boot -r -J -V GavarBSD -o /media/gvBSD.iso /media/RELEASE`

Finally: it boots until it mounts the file system in md0; then the kernel panics.


----------



## bsaidus (Oct 11, 2014)

Hello all.
Thanks for feedbacks.
I've resolved the problem  :OOO 
The solution is in the loader configuration as folow .


```
geom_uzip_load="YES"
    tmpfs_load="YES"
    mfs_load="YES"
    mfs_type="mfs_root"
    mfs_name="/disk-img.dd"
    ahci_load="YES"
    # vfs.root.mountfrom="ufs:/dev/md0"
    vfs.root.mountfrom="ufs:/dev/md1a"
```
Thanks !


----------

