# Custom Kernel



## iic2 (May 21, 2009)

Installing a Custom Kernel
http://aplawrence.com/Unixart/compiling_freebsd.html	     - BABYBSD
http://nixdoc.net/man-pages/FreeBSD/man1/mkdir.1.html    - Great on-line Man Pages
http://www.gsp.com/cgi-bin/man.cgi?section=1&topic=ln    - more about ln -s
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-building.html

My Note: My 3rd major experience with UNIX type.  Mind Blown Again 

BACK-UP ORIGINAL KERNEL FIRST  * Kernel is in the boot directory under /
# cd /boot 
# cp -pvr kernel kernel.orig  
* Be patience .. This process takes about 2 Â½ minutes. FreeBSD will display the results "-pvr".

* To manually install the Kern-Developer source you will be creating this directory â€“  /usr/src/sys
* First insert FreeBSD Disk-1 into CD drive. 
mount /cdrom 
mkdir -p /usr/src/sys 
ln -s /usr/src/sys /sys 
cat /cdrom/7.2-RELEASE/src/ssys.[a-d]* | tar -xzvf - 
cat /cdrom/7.2-RELEASE/src/sbase.[a-d]* | tar -xzvf - Not needed - include anyway
This process takes about 9 Â½ minutes. . All file from the CD start with (x) so don't get worry.

Now we (cd) and go  make a copy of GENERIC in same directory (short-name it what you wish). 
# cd /usr/src/sys/i386/conf
# cp -pvr GENERIC BABYBSD
# ee BABYBSD
At 4th line (ident) change the name from GENERIC to BABYBSD

Start commenting out SCSI controllers ,RAID ,PCI/ISA NIC etc. depending on what you have.  But my first time I did not comment out anything cause I wanted to see it work first.

FREEZE: Don't go no where!   Save the file. Now type:  #make LINT in this directory.  It will create a file named LINT real fast.  This file will list all the options supported by the kernel. 

NOW YOU ARE READY TO COMPILE YOUR NEW TINY KERN - Takes about 30  min Text may halt for long time don't worry.  Just wait until you will get command line prompt agin.

HANDS-UP: You MUST type this while in same DIR.  I guest we are calling the c compiler? That is really a question. 

# /usr/sbin/config BABYBSD
# cd ../compile/BABYBSD 

# make depend  
# make  
# make install 


* Test by Re-Booting  ....  IF FAIL: at Boot Prompt type -  "boot kernel.orig"

_________________
-----------------
I had to note myself this way so I can remember.  I got lost so many times.  I spelled src, scr after sooo many time of trying.  But I learn a lot in this latest 24-24.  I got to get a life some day.

I hope this be where some members will post future pros and cons about this method and how to build a better file.  Things like what to include and what should never be remove.  I know that most hardware is personal but every one need pf.    That's where the real work comes in.  But for right now,  it seems to be a real winner.  But It got to be missing something special.

Thank you Amarjyoti Krishnan ... FreeBSD is truly flexible


----------



## SirDice (May 21, 2009)

iic2 said:
			
		

> # /usr/sbin/config BABYBSD
> # cd ../compile/BABYBSD
> 
> # make depend
> ...


This is seriously outdated. Use:

```
# cd /usr/src
# make buildkernel KERNCONF=BABYBSD
# make installkernel KERNCONF=BABYBSD
```


----------



## iic2 (May 22, 2009)

That was the problem. I don't want to have to re-install those ports again just to be sure.  But it did not work for me with-out them.  Then I read in  the official freeBSD docs some where while searching that said "you must have the Full Port Tree installed"  in-order to use that.  Darn I just got rid of them.

That did not sound fair to me. Than I got lucky and found the thread at top of page that did it with-out requirements.  Out dated sounds good to me as long as it works.


----------



## SirDice (May 22, 2009)

You do NOT need a ports tree to compile/install the base kernel and world.

The way I posted is the way to do it. Not the old way. If you have problems doing it correctly please post any errors.


----------



## phoenix (May 22, 2009)

Note:  to use the new, recommended method, you need a full *source* tree installed (everything under /usr/src).  To use the old, no-longer-recommended, method you only need the *kernel* sources installed (only /usr/src/sys/*).

However, it's best to have the full source tree installed, such that you always have the installed system, the installed source, the kernel and the userland, all nicely in sync with each other.  (Hence, one of the reasons the old method is no longer recommended.)


----------



## iic2 (May 22, 2009)

I got the whole thing mixed up.  I didn't want to install the PORT-TREE mainly for size.  I get 323mb when using 7.2.  I been planning to compile needed programs from source in the first place.  That's what I meant by installing manually but I did not phrase the question properly.

So it was about the SOURCE-TREE all along. Now I understand. .. but I got a few more questions about it so I'm going to search the forum for more info now that I know what to search.   Thanks


----------



## iic2 (May 22, 2009)

Just to be sure.. Is the [6]Kern-Developer source the full source tree.  If not how do I get it of the CD.  I don't want to install all out-side programs source.


----------



## phoenix (May 22, 2009)

Kern-Developer is just the kernel sources (/usr/src/sys/ tree).  This does not include any of the sources for the rest of the FreeBSD OS.

You need the Full Sources distribution (description mentions full sources, kernel+binaries, or something like that).

Or, you can copy /usr/share/examples/cvsup/standard-supfile to something like /etc/supfile.source, edit it to use the correct tag= for your release (use RELENG_X_Y, such that 7.0 would be RELENG_7_0, 7.1 would be RELENG_7_1, 7.2 would be RELENG_7_2, etc), and run `# csup /etc/supfile.source`.  That will download the source tree from the Internet.


----------



## iic2 (May 22, 2009)

SirDice,


> If you have problems doing it correctly please post any errors.


I glad you said that cause as a new-bee I can't post to bug-report when 60% of the time I thought I had miss-typed.  I did all of above well over 40 times cause I thought I made mistakes or changed my mine cause of that.  I can't believe it only been a few days since posting my last two thread.  When I say 24-24 it mean 24-24 with under a few hours of sleep at best.

Anyway, I'm doing a new install in advance right now while typing this note because I all really know what is about to happen on 7.2.  I am installing absolutely nothing as most-usual: Let's do this:

# cd /boot 
# cp -pvr kernel kernel.orig
..........................................
mount /cdrom 
mkdir -p /usr/src/sys 
ln -s /usr/src/sys /sys 
cat /cdrom/7.2-RELEASE/src/ssys.[a-d]* | tar -xzvf - 

many lines something about amd ...last line is:
x sys/amd64'acpica/madt.c: Seek fail: Invalid argument
tar: Error exit delayed from previous errors




> because I all really know what is about to happen on 7.2.


Well I spoke tooo soon:
THIS HAS NEVER HAPPEN BEFORE ... It use to look good and this is what I use to get.  And this was the problem in the first place:

I always IMMEDIATLY-CHECK RESULTS:
cd /usr/src/sys
ls
sys
cd sys
ls
sys
cd sys
ls
sys
cd sys
ls
sys
cd sys
ls
sys
cd sys
ls
sys
FOREVER

..................
..................
So I guest after some many times of re-installing and doing the same thing over and over again then it went away and I had it ... re-installed again to make sure and I had it again .. Than I re-installed again and wrote ever step that you see at the very top of this page.

See why I been going so crazy... Cause I want to know WHY before I move on to installing what I need.  Avarge people never have time to waist like i.  Maybe my CD is burned-up (and I know my CD has not been scratched cause I am toooo careful, I THINK)  cause I never saw this before.

Never even got to this part THIS TIME for the FIRST TIME:
cat /cdrom/7.2-RELEASE/src/sbase.[a-d]* | tar -xzvf -


As of now I'm going back to do it all over again with a newly created cd just in case and if I get the usually results I'll install the kernel thing using the CD.  I bet people think they got a CUSTOM KERNEL but really don't.  I did not either on my final try.  I deleted it and my machine booted up the same 34 seconds with or with-out.

Possible bug-report near OVER


phoenix,Thank you you made my world


----------



## iic2 (May 22, 2009)

Give me a few hours.  That first error got to be a burn-out disk cause It worked too many times before with no problem.  I just want to see if I get the usual error ... the 2nd set to be sure.  Making new CD now.


----------



## iic2 (May 23, 2009)

I got a feeling that I'm going back to plan1, manual install of a few programs cause that the way I am.  No goodies for me unless I fail.  I did that all my life for Windows and now I'm on a real operating system, so I don't plan to blow it.  Knowing where everything is IS what programming is all about.  But if you need to get  production up-and-running quickly than the Source-Port System is design to do that and they do it well.  So forgive me.  The information you provided here is invaluable and will live forever. I never found it worded like that in any doc or site or PERIOD.  I ran back so quick to post to ask while I had the chance. I will using it someday with-out question if not next week.  But for now, I choose total low-level learning and dealing with Python,  Perl and more.  I thought I had to say this.

Anyway, for me less files means less confusion.  But as I say, that's me until production time (when class begin) and I'm in no rush to go back.


I CALCULATE ONLY THE MEGABIT DIR	ad0s1a = root	and	ad0s1f = usr
----------------------------------------------------------------------------
----------------------------------------------------------------------------  

Disk 1 ONLY - RAW - No port No Nothing	573 mb
Disk 1 With Kernel Source while installing		720 mb		148 mb ADDED
Disk 1 With Make World Source while installing	1085 mb		512 mb ADDED

Anything under 2G make for a great production web-server IMHO.
Anything under 1G makes a iic2 Super Server 

::::::::::::::::::::::::::::::::::

New CD created, fdisk, disk formatted twice and new install is has been completed: 
I go to root and I re-boot and un-plug machine for total fresh start:
I Insert same command lines and I don't  miss a beat:


HERE ARE THE RESULTS:

tar:Error exit delayed from previous error.
#May 22 20:59:21 kernel: pid 679 (bsdtar), uid 0 inumber 14520 on /:filesystem full

This time I go see what is in cd / first because I got hip to src days ago.
There is no (src).  I see (sys)

Now I go to see cd /usr
I see a src folder

Now I cd src
ls
I see sys

Now I cd /sys
ls
I SEE SYS ----AGAIN
...................................
...................................

Let me know what the bsd-team find, THIS YEAR   For now I'll even blame it on my hardware again OR getting hacked off another machine with my disk 1 2 and 3 on it under Windows that is connected to the internet bubut these file is on an seperate partition with nothing else on it ... I don't know.  That's why I like ....  rawBSD  ...... but suppose that has been corrupted (if it not my hardware)   I don't know.


----------



## iic2 (May 23, 2009)

the flirt symbol must be the editor used thing.

 :  filesystem full


----------



## iic2 (May 23, 2009)

*Just for good measures*

I just did another install off new CD.  I included
[X] 4 Developer Full Sources, binaries and doc but no games
[X] 6 Kern-Developer Full binaries and doc, kernel source only
[Yes] and the worlds beloved Port Collection

So it was not me but the tactic which may be miss-wired or even calling the wrong commands for 7.2 ... To no surprise there was no problem but at the same time I have nothing to check for myself as a programmer or user but size of file.   At this stage I bet nothing would ever report wrong for common tasks.  So for now the common users can feel safe but not the rest of us until we get the heads-up or ( at lease myself )

ONLY -  RAW - No port No Nothing		573 mb
ONLY -  Kern-Developer Full binaries		720 mb		148 mb ADDED
ONLY -  Developer Full Sources			1085 mb		512 mb ADDED
THE WORKS  -  Full Source - Kernel and Ports	1143 mb		570 mb ADDED

What the world is this  â€” Adding the WORKS you get UNDER Make World in size ???  I remember a Port only install that was 1043 mb and if I was wrong throw in the kern-dev
Why I have to be the one to notice these things.

Good Night


----------



## SirDice (May 23, 2009)

Use the minimal install. If that's done do the following:


```
# cd ~
# cp /usr/share/examples/cvsup/stable-supfile .
```
Edit the copied stable-supfile. Point the host to a mirror closeby. Change **default release=cvs tag=RELENG_7_2*. RELENG_7_2 is 7.2-RELEASE.

```
# csup stable-supfile
```
You now have the full source tree. Create a custom kernel as you did before by copying GENERIC and editting the copy.

```
# cd /usr/src
# make buildworld
# make buildkernel KERNCONF=BABYBSD
# make installkernel KERNCONF=BABYBSD
# reboot
(single user mode)
# fsck -y
# mount -u /
# mount -a -t ufs
# cd /usr/src
# make installworld
# mergemaster
# reboot
```

There's no need to copy the 'old' kernel to kernel.old as the installkernel scripts will take care of that.


----------



## iic2 (May 23, 2009)

Was about to ask a very silly question.  I figured out what your code is about. Thanks SirDice


----------



## iic2 (May 27, 2009)

Yes


----------

