# Build FreeBSD



## j4ck (May 19, 2013)

Hi
I'm trying to rebuild my operating system using make. According to the handbook manual I've made a list named make.conf under /etc which contains:


```
WITHOUT_BLUETOOTH="YES"
WITHOUT_EXAMPLES="YES"
WITHOUT_FLOPPY="YES"
WITHOUT_GAMES="YES"
WITHOUT_MAN="YES"
WITHOUT_MAN_UTILS="YES"
WITHOUT_SHAREDOCS="YES"
WITHOUT_WIRELESS="YES"
WITHOUT_WIRELESS_SUPPORT="YES"
WITHOUT_AT="YES"
WITHOUT_CALENDAR="YES"
WITHOUT_INFO="YES"
WITHOUT_LOCALES="YES"
WITHOUT_ZFS="YES"
WITHOUT_BSD_CPIO="YES"
WITHOUT_CTM="YES"
WITHOUT_DICT="YES"
WITHOUT_GDB="YES"
WITHOUT_GNU="YES"
WITHOUT_GROFF="YES"
WITHOUT_HTML="YES"
WITHOU_INFO="YES"
WITHOUT_LPR="YES"
WITHOUT_MAIL="YES"
WITHOUT_PORTSNAP="YES"
WITHOUT_QUOTAS="YES"
WITHOUT_RCS="YES"
WITHOUT_SYSINSTALL="YES"
WITHOUT_BIND="YES"
WITHOUT_BIND_XML="YES"
WITHOUT_BIND_IDN="YES"
WITHOUT_BIND_SIGCHASE="YES"
WITHOUT_BIND_LARGE_FILE="YES"
WITHOUT_FREEBSD_UPDATE="YES"
WITHOUT_RESCUE="YES"
```
I expect to trim e.g. man pages after `make buildworld` and `make installworld`, but man pages still remain. What should I do? Am I missing something?


----------



## phoenix (May 19, 2013)

Install world installs all the new bits you just compiled, but doesn't remove anything. You need to run `make delete-old` to remove all the old stuff you are no longer building. And the `make delete-old-libs` to remove all the old libraries you are no longer building.

Note: you really should put all those settings into /etc/src.confâ€¦


----------



## jozze (May 19, 2013)

Also, after issuing `# make delete-old-libs` some of your ports may stop working, so you'll have to recompile them -- see handbook. Especially WITHOUT_MAN_UTILS might break some things, because most ports use them to build their own manpages.


----------



## j4ck (May 20, 2013)

phoenix said:
			
		

> Install world installs all the new bits you just compiled, but doesn't remove anything. You need to run `make delete-old` to remove all the old stuff you are no longer building. And the `make delete-old-libs` to remove all the old libraries you are no longer building.



Here's what I do:

```
#make buildkernel KERNCONF=MYKERN
#make installkernel KERNCONF=MYKERN
#make buildworld
#make delete-old
#make delete-old-lib
#make installworld
```



> Note: you really should put all those settings into /etc/src.confâ€¦


And I did so. But changes I expect do not affect. Still I have e.g. man pages sysinstall ...


----------



## j4ck (May 20, 2013)

It's better to say that e.g. `man` command still remains but executing `man src.conf` causes this:
	
	



```
eval: tbl: not found
eval: groff: not found
```
And there's no `calendar` command anymore as I expected but it's directory remains: /usr/share/calendar
I also expect no shared documents 
	
	



```
WITHOUT_SHAREDDOCS="YES"
```
 but as I said this directory still remains.


----------



## bkouhi (May 20, 2013)

> Here's what I do:
> 
> ```
> #make buildkernel KERNCONF=MYKERN
> ...



Hello @j4ck.

I think you're doing it in the wrong order. The correct way to rebuilding the FreeBSD is:

`make buildworld`
`make buildkernel`
`make installkernel`
`make installworld`
`make check-old`
`make delete-old`
`make delete-old-libs`

Build the new compiler first, then build the kernel with that new compiler (the old compiler may have bug and can't build the new kernel). Also, install the kernel before the world and then delete old files and libraries.

If you want to customize FreeBSD and build your own OS, why not installing the kernel and world in an alternate DESTDIR? Please see build(7).

For example:
`make DESTDIR=/root/myos/workdir installkernel`
`make DESTDIR=/root/myos/workdir installworld`


----------



## j4ck (May 20, 2013)

> If you want to customize FreeBSD and build your own OS, why not installing the kernel and world in an alternate DESTDIR?


And what should I do with that DESTDIR? consider that I've installed kernel and world into that DESTDIR, how can I use this as the new OS?


----------



## bkouhi (May 20, 2013)

Hmm...
Well, I've never used it before but maybe you can do it via mkisofs(8)():

`% mkisofs -R -no-emul-boot -b boot/cdboot -o myos.iso /root/myos/workdir`


----------



## j4ck (May 20, 2013)

You mean make a bootable iso image? I also found this script after googleing /usr/src/release/i386/mkisoimages.sh.
So, this will be what I do:
`#cd /usr/src`
`#make buildworld`
`#make buildkernel`
`#make DESTDIR=/root/myos/workdir installkernel`
`#make DESTDIR=/root/myos/workdir installworld`
`#mkisofs -R -no-emul-boot -b boot/cdboot -o myos.iso /root/myos/workdir`
or
`#sh /usr/src/release/i386/mkisoimages.sh -b IMAGE_LABEL IMAGE_NAME BASE_BITS_DIR`


----------



## bkouhi (May 20, 2013)

These are almost same. That script also use mkisofs(8)(). If you want to use the way I just suggested, you should adjust the /etc/fstab manually. But that script will adjust the fstab file automatically for you. Also, there is something that I forgot to mention. You should run the `make distribution` command after `make installworld`. This command will install the /etc directory for you.

Here is an example of fstab file:


```
/dev/iso9660/[B]CDLABEL[/B]   /    cd9660    ro    0    0
```

Replace the CDLABEL with the name of your CDROM.

HTH

Edit:
Oh, sorry, that script use makefs(8)(), not mkisofs(8)(). But the procedure is almost same.


----------



## kpa (May 20, 2013)

There's also release(7) if you want to build your own version of FreeBSD on a bootable media.


----------



## j4ck (May 20, 2013)

I did exact the same process, but when I try to install and try my new OS, I face this error:

```
Operating system not found
```


----------



## kpa (May 20, 2013)

j4ck said:
			
		

> I did exact the same process, but when I try to install and try my new OS, I face this error:
> 
> ```
> Operating system not found
> ```



This is often caused by not setting the active flag for the bootable slice on the disk when using MBR partitioning.


----------



## j4ck (May 21, 2013)

kpa said:
			
		

> This is often caused by not setting the active flag for the bootable slice on the disk when using MBR partitioning.



How to fix it?


----------



## kpa (May 21, 2013)

With gpart(8) it would be done like this: `gpart set  -a active -i 1 adaX`.


----------



## wblock@ (May 21, 2013)

This thread makes my head hurt.  You don't need to build a CD to rebuild your operating system.  The Handbook shows the correct procedure, as does @bkouhi.  Don't build a CD, just reboot and it will boot the new version.


----------



## bkouhi (May 23, 2013)

Sorry for misunderstanding. I thought you want to build another operating system based on FreeBSD. But, what exactly do you want to do? If you just want to rebuild (or upgrade) your FreeBSD system, you don't need to build a CDROM, and even you don't need to use another DESTDIR. You only need a CDROM if you want to build your own OS based on FreeBSD. For example a FreeBSD with some modifications and extra features and maybe without unwanted parts.

Sorry again.


----------



## j4ck (May 23, 2013)

bkouhi said:
			
		

> Sorry for misunderstanding. I thought you want to build another operating system based on FreeBSD. But, what exactly do you want to do? If you just want to rebuild (or upgrade) your FreeBSD system, you don't need to build a CDROM, and even you don't need to use another DESTDIR. You only need a CDROM if you want to build your own OS based on FreeBSD. For example a FreeBSD with some modifications and extra features and maybe without unwanted parts.
> 
> Sorry again.



Of course you got exactly what I mean. I want to build my own release and have it on a CD or memory stick. You showed the correct way of doing so. Thanks for that.


----------

