# Unable to compile the kernel



## TheCompass (Sep 15, 2013)

Hi community,

These days I'm trying to modify my kernel /root/kernels/MYKERNEL, and this I obtained through the GENERIC: `cp GENERIC /root/kernels/MYKERNEL`, but when I do these commands to compile it:
`make buildkernel KERNCONF=MYKERNEL`
`make installkernel KERNCONF=MYKERNEL`
FreeBSD gives me errors respectively:

```
make: don't know how to make buildkernel. Stop
make: don't know how to make installkernel. Stop
```

I installed SYS from the sysinstall (Configure->Distribution-> Src -> Sys) but as I have described, it does not work.

Does anyone know how to solve this problem? I have read that it is advisable to install it using csup, but I do not know.

Kind regards.


----------



## jb_fvwm2 (Sep 15, 2013)

[cmd=]csup [/cmd] has been obsoleted for the most part.  One would be advised to use  devel/subversion  from the ports tree. Also, the commands you've shown are only part of a much larger sequence of commands: see /usr/src/UPDATING  near the bottom for various methods. Other missing factors may also apply.


----------



## wblock@ (Sep 15, 2013)

TheCompass said:
			
		

> These days I'm trying to modify my kernel /root/kernels/MYKERNEL, and this I obtained through the Generic `cp GENERIC /root/kernels/MYKERNEL`, but when I do these commands to compile it:
> `make buildkernel KERNCONF=MYKERNEL`
> `make installkernel KERNCONF=MYKERNEL`
> 
> ...



make(1) looks for a Makefile in the current directory, so the first step is to change to the source directory:

```
# cd /usr/src
# make buildkernel KERNCONF=MYKERNEL
```


----------



## ShelLuser (Sep 15, 2013)

TheCompass said:
			
		

> These days I'm trying to modify my kernel /root/kernels/MYKERNEL, and this I obtained through the Generic `cp GENERIC /root/kernels/MYKERNEL`, but when I do these commands to compile it:
> `make buildkernel KERNCONF=MYKERNEL`
> `make installkernel KERNCONF=MYKERNEL`
> 
> FreeBSD gives me errors respectively


Apart from the current directory, as mentioned by @wblock@, I'm also wondering where your new configuration file ended up. Because it looks to me as if you merely copied GENERIC to a completely different directory (/root/kernels) and then tried to compile the kernel.

But if your configuration file sits outside the source tree then there's no way that make can ever know about it. So try doing this instead:


```
# cp GENERIC /root/kernels/MYKERNEL
# ln -s /root/kernels/MYKERNEL
# cd ../../..    # (or optionally use cd /usr/src)
# make buildkernel KERNCONF=MYKERNEL
```
And so on...


----------



## j4ck (Sep 17, 2013)

It seems that you are compiling the kernel in a wrong directory. You have to change your current directory to /usr/src. In order to use your own kernel, you can copy your modified kernel to the /usr/src/sys/amd64/conf or /usr/src/sys/i386/conf directory depending on your machine architecture and then do the compiling process.

`cp /root/kernels/MYKERNEL /usr/src/sys/amd64/conf`
`cd /usr/src`
`make buildkernel KERNCONF=MYKERNEL`
`make installkernel KERNCONF=MYKERNEL`


----------



## TheCompass (Sep 17, 2013)

jb_fvwm2 said:
			
		

> [cmd=]csup [/cmd] has been obsoleted for the most part.  One would be advised to use  devel/subversion  from the ports tree. Also, the commands you've shown are only part of a much larger sequence of commands: see /usr/src/UPDATING  near the bottom for various methods. Other missing factors may also apply.


Hi, I don't know how to do this, if you can explain it some more, o*r* give me a link to a topic of this theme.



			
				j4ck said:
			
		

> It seems that you are compiling the kernel in a wrong directory. You have to change your current directory to /usr/src. In order to use your own kernel, you can copy your modified kernel to the /usr/src/sys/amd64/conf or /usr/src/sys/i386/conf directory depending on your machine architecture and then do the compiling process.
> 
> `cp /root/kernels/MYKERNEL /usr/src/sys/amd64/conf`
> `cd /usr/src`
> ...


Thanks but it doesn't run, gives the same errors, thanks for your time, and thanks to others too. I'm testing your tips but I still can't compile the kernel, I do this:

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

I edit the file MYKERNEL, and when I go to compile it, the problems persists:

`cd /usr/src`
`make buildkernel KERNCONF=kerneladrian`
`make installkernel KERNCONF=kerneladrian`

Gives the same errors:

```
make: don't know how to make buildkernel. Stop
make: don't know how to make installkernel. Stop
```

Any more solutions? Thanks for everything and your time, I appreciate it very much.


----------



## TheCompass (Sep 17, 2013)

`cd /usr/src`
`make buildkernel KERNCONF=MYKERNEL`
`make installkernel KERNCONF=MYKERNEL`

Sorry, the rush.:r


----------



## ShelLuser (Sep 18, 2013)

Could you run `head -15 /usr/src/Makefile` and paste the results here (don't forget to use the 
	
	



```
tags)?

I'm beginning to suspect that your source tree could be either wrong or incomplete.

Another point of interest: which version of FreeBSD are you using by the way?
```


----------



## SirDice (Sep 18, 2013)

TheCompass said:
			
		

> Hi, I don't know how to do this, if you can explain it some more, o*r* give me a link to a topic of this theme.


Handbook: A.5. Using Subversion



> I edit the file MYKERNEL, and when I go to compile it, the problems persists:
> 
> `cd /usr/src`
> `make buildkernel KERNCONF=kerneladrian`
> ...


That sounds to me like you don't have a source tree, or at the very least an incomplete one.


----------



## ShelLuser (Sep 19, 2013)

I'm happy to learn that our comments seem to have helped you out.

Still; I'd also like to request that you share your experiences with us, because that could also help other users as well. Don't worry too much about it; you can always blame me


----------



## TheCompass (Sep 19, 2013)

ShelLuser said:
			
		

> I'm happy to learn that our comments seem to have helped you out.
> 
> Still; I'd also like to request that you share your experiences with us, because that could also help other users as well. Don't worry too much about it; you can always blame me



Certainly I still have not managed to solve the problem, I'm trying to install all of the source tree but I do not get it.

If anyone has a link of a post to install all of the source tree that would be appreciated, I'm trying to install the devel/subversion but it does not work or maybe I do not do it completely well.

Big greetings to all.


----------



## SirDice (Sep 19, 2013)

TheCompass said:
			
		

> I'm trying to install the devel/subversion but does not work or maybe I do not completely well.


To get the source you will need to have subversion installed. What are the problems you are having with the port?


----------



## TheCompass (Sep 21, 2013)

ShelLuser said:
			
		

> Could you run `head -15 /usr/src/Makefile` and paste the results here (don't forget to use the
> 
> 
> 
> ...


To install the suberversion I do this:
`cd /usr/ports/devel/subversion`
`make install clean`

I select OK in all windows with the predefined options, I think it is installed correctly but I don't know how to continue.

Kind regards!


----------



## Morte (Sep 21, 2013)

If you're just trying to get the source directory, you might find it easier to grab the source manually:

ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.1-RELEASE/

The file you want is src.txz.  This is the release version however, and you may want to get the latest patches. I can't recall if freebsd-update picks that up or not.


----------



## wblock@ (Sep 22, 2013)

Thread 29172 shows how to install FreeBSD source.


----------



## youngunix (Sep 22, 2013)

Following this link, this is how I rebuilt mine yesterday.
First, moved everything in /usr/ports/ including hidden files and folders, like so:

`# mkdir /root/ports-bkup && mv /usr/ports/* /root/ports-bkup`
NOTE: the above command will not move the hidden files, you need to do it manually.

Second, checkout the source using subversion:
`# svn checkout [url=https://svn0.us-west.FreeBSD.org/ports/head]https://svn0.us-west.FreeBSD.org/ports/head[/url] /usr/ports/`
NOTE: accept the certificate permanently if you don't want to be prompted each time you checkout.

Third, update /usr/ports/:
`# svn update /usr/ports/`
Or
`# cd /usr/src/`
`# make update SVN_UPDATE=yes`

Now, let's deal with the kernel:
`# mkdir /root/custom-kernel && cp /usr/src/sys/amd64/conf/GENERIC /root/custom-kernel/DATBSD`
NOTE: there (/root/custom-kernel/) you can edit your new kernel (mine named DATBSD).

When you are done, copy the new edited kernel as follow:
`# cp /root/custom-kernel/DATBSD /usr/src/sys/amd64/conf/`
Then
`# cd /usr/src`
`# make buildkernel KERNCONF=DATBSD`
`# make installkernel KERNCONF=DATBSD`

Good luck!


----------



## wblock@ (Sep 22, 2013)

youngunix said:
			
		

> Following this link, this is how I rebuilt mine yesterday.
> First, moved everything in /usr/ports/ including hidden files and folders, like so:
> 
> `# mkdir /root/ports-bkup && mv /usr/ports/* /root/ports-bkup`
> NOTE: the above command will not move the hidden files, you need to do it manually.



Just rename the directory: `mv /usr/ports /usr/ports.bak`.  Most people will not have made local modifications, /usr/ports can just be deleted.



> Now, let's deal with the kernel:
> `# mkdir /root/custom-kernel && cp /usr/src/sys/amd64/conf/GENERIC /root/custom-kernel/DATBSD`
> NOTE: there (/root/custom-kernel/) you can edit your new kernel (mine named DATBSD).
> 
> ...



It is not necessary to copy the whole kernel configuration file: Simplifying FreeBSD Kernel Configuration Files. If you put the new configuration file in some other directory for safety, like /root, creating a link in the conf directory means it does not have to be copied back after changes: `ln -s /root/DATBSD /usr/src/sys/amd64/conf/`


----------



## youngunix (Sep 22, 2013)

wblock@ said:
			
		

> Just rename the directory: `mv /usr/ports /usr/ports.bak`.  Most people will not have made local modifications, /usr/ports can just be deleted.
> 
> 
> 
> It is not necessary to copy the whole kernel configuration file: Simplifying FreeBSD Kernel Configuration Files. If you put the new configuration file in some other directory for safety, like /root, creating a link in the conf directory means it does not have to be copied back after changes: `ln -s /root/DATBSD /usr/src/sys/amd64/conf/`



I know I didn't follow the documentation to the letter, yet, the way I proceeded was quick, painless, and less confusing (for me). Thus, ending with the same result.


----------



## TheCompass (Sep 23, 2013)

youngunix said:
			
		

> Following this link, this is how I rebuilt mine yesterday.
> First, moved everything in /usr/ports/ including hidden files and folders, like so:
> 
> `# mkdir /root/ports-bkup && mv /usr/ports/* /root/ports-bkup`
> ...



Hi, good night, thanks to all who are helping me.

First I move the /usr/ports to other folder and I do without problem that
`# svn checkout [url=https://svn0.us-west.FreeBSD.org/ports/head]https://svn0.us-west.FreeBSD.org/ports/head[/url] /usr/ports/` 

Second, I can update the /usr/ports
`# svn update /usr/ports/` 
But the /usr/src is empty, then I do
`# cd /usr/src`
`# make update SVN_UPDATE=yes` 
And that gives the same problem
`# make: don't know how to make update. Stop` :r 

Consequently I can't do 
`# mkdir /root/custom-kernel && cp /usr/src/sys/amd64/conf/GENERIC /root/custom-kernel/DATBSD`
Note: I've tried to update the SYS from the sysinstall but neither works the `buildkernel`

Thanks for all and your time, I appreciated very much.


----------



## wblock@ (Sep 23, 2013)

TheCompass said:
			
		

> But the /usr/src is empty, then I do
> `# cd /usr/src`
> `# make update SVN_UPDATE=yes`
> And that gives the same problem
> `# make: don't know how to make update. Stop` :r



Yes, that is acting as expected.  See post #3.

Let's start over.  Forget all the previous posts.  In the following, it is assumed that you want FreeBSD 9.1-RELEASE (you have not actually specified what version).  If not, you will have to change the URL used for the checkout.


```
# rm -rf /usr/src
# svn checkout https://svn0.us-west.FreeBSD.org/base/releng/9.1/ /usr/src
```


----------

