欢 迎 光 临
's BLog
这就是我
最新公告
站点日历
最新日志
最新回复
最新留言
 日志搜索

友情链接
其他信息
·miniBSD 6.x Guide     -|ixp2xxx 发表于 2006/5/24 12:03:00

miniBSD 6.x Guide

Last Update: Saturday, February 04, 2006

My guide will attempt to make the process of reducing FreeBSD 6.x as painless as possible. If you read the document and find any problems with it, please let me know and I will correct the mistakes. If you would like to contribute information to the guide, please let me know and I will update the guide with your contributions.

Please participate in the user forums, which are located at http://forums.ultradesic.com.

Please use the e-mail address minibsd at ultradesic dot com when contacting me about this miniBSD 6.x guide.

 

(Note: Any feedback you, as a reader, can provide will be greatly appreciated.)

 

 

 

 

 

 

Requirements


To build a miniBSD system based on FreeBSD 6.x, you will need to have root access to a computer, laptop, or some other hardware that is capable of running FreeBSD 6.x. (A Soekris net4801 with a 2.5" hard-drive would work just fine, though compiling on it would be slow.)

The actual computer hardware that you use to build your miniBSD system will be referred to as the
FreeBSD Host Machine throughout this guide. It is an important distinction.

It is assumed you know how to install FreeBSD. If you need help in that area, this project probably isn't meant for you. But never-the-less, refer to the handbook on the FreeBSD website if you need assistance with installing FreeBSD.

If you are installing FreeBSD just for the purpose of building a miniBSD system, you only need a minimal install. All the real work will be done inside of a chroot(8) environment (hereafter called a FreeBSD jail) so there is no need to do a full install. It will just take longer and waste disk space.

Once you have your
FreeBSD Host Machine ready to go, you can continue with this guide.

 

 

 

Install the FreeBSD jail

Logon as root to your FreeBSD Host Machine and execute syinstall by typing the following:

/usr/sbin/sysinstall

From the menu, choose:

  • Custom
    • Options

 

You will then be looking at a black screen with lots of text on it. Press the down arrow key on your keyboard until the cursor gets to the Install Root option in the right side column. Press the space bar to bring up the edit box and then type:

/usr/jail

Hit enter to accept the change, and then press
Q to quit back out to the Options page.

Skip over Partition and Label and select Distributions.

Within the Distributions page, arrow down until the cursor gets to the Minimal option, select the Minimal distribution package by pressing the space bar, then arrow down to the Custom option and hit Enter.

Within the Custom page, arrow down until the cursor gets to the src option and hit Enter.

Within the src page, you want to select the following:

  • lib
  • sys

Exit back to the main Options page.

Choose your Media source, and then choose Commit to perform the install.

Once the install to
/usr/jail is complete, exit out of sysinstall.

 

 

Configure the FreeBSD jail

Once your FreeBSD jail is installed, you will need to configure a couple of things to make it usable.


I recommend creating a simple shell script that will put you in the jail environment and ensure that
dev is mounted. Here is the shell script I created. I put it in the /root directory of my FreeBSD Host Machine. Download it by clicking here, or use fetch by typing the following:

cd /root
fetch http://www.ultradesic.com/pub/miniBSD_Files/minichroot.sh


Save the script and make it executable by typing the following:


chmod 0700 /root/minichroot.sh

(Note: You should always look over a script before you execute it and make sure you understand what it's doing.)


Using this script will ensure that
dev is mounted within the FreeBSD jail before you chroot into it. But before you enter the FreeBSD jail, there are a couple of more thing you will want to do.

First, copy the
/etc/resolv.conf and /etc/localtime file from the FreeBSD Host Machine to /usr/jail/etc by typing the following:

cp /etc/resolv.conf /usr/jail/etc
cp /etc/localtime /usr/jail/etc

If your computer stores its time in UTC, you can skip this part. (See the adjkerntz(8) man page for for information.) If your computer stores its time as local time, make sure to copy over
/etc/wall_cmos_clock as well by typing the following:

cp /etc/wall_cmos_clock /usr/jail/etc

(Note: or just create an empty file by typing: touch /usr/jail/etc/wall_cmos_clock)


Next, edit the
/usr/jail/root/.cshrc file and add the following line to the very bottom:

set prompt = "MiniBSD %~ %# "

That will set the prompt so that you won't confuse which shell you are logged in at. This is extremely helpful and I highly recommend that you do this step.

You are now ready to enter the
FreeBSD jail. If using my script, type the following command:

/root/minichroot.sh

If you're not using my script, type the following:

touch /root_check
mount -t devfs devfs /usr/jail/dev
chroot /usr/jail /bin/csh

That's it. Continue to the next section.

 

 

(Note: The FreeBSD jail can be configured where you could build your miniBSD image from the relative safety of an ordinary user account. I will address the steps necessary to accomplish that setup soon.)

 

 

 

 

Safety Checks

Now you are ready to begin building your miniBSD system. But before you start, you should ensure that you are in fact inside the FreeBSD jail and that dev is mounted within the FreeBSD jail. Look for the root_check file that was created automatically when you executed the /root/minichroot.sh shell script. Type the following:

ls /root_check

If you are in the
FreeBSD jail, you should NOT be able to see the file. If you do see the file, something has already gone wrong. STOP NOW and figure it out.

Now that you know you are inside the
FreeBSD jail, check to make sure the device nodes exist in your /dev directory by typing the following:

ls /dev

If you don't see any files listed, something has gone wrong. You should STOP NOW and figure it out.

Once you have verified that you are in the
FreeBSD jail, and that the dev system has been properly mounted inside the FreeBSD jail, you are then ready to move on.

 

 

 

 

Building miniBSD 6.x


This section is where all of the real work is done. All of the commands executed in these next sections should be executed within the
FreeBSD jail. If you feel that you have hopelessly messed up your build, you can simply exit the FreeBSD jail, unmount the /usr/jail/dev directory, and remove the /usr/jail directory and all of its content. Then start back at the beginning.

 

 

 

 

 

 

Create Directory Structure

The first thing to do is to create the directory structure for your miniBSD system. You can manually enter all the mkdir commands, or you can use the simple shell script I created to have it all done for you.


If you want to do it the easy way, download my script, and execute it by typing the following:

cd /root
fetch http://www.ultradesic.com/pub/miniBSD_Files/create-minibsd-dirs.sh
chmod 0700 /root/create-minibsd-dirs.sh
/root/create-minibsd-dirs.sh

If you want to do it manually, here is the directory structure you will need.

(Note: This is just the directory structure you need for a minimal system. If you plan to have additional daemons/programs, you'll need to create whatever directories are required by those programs.)

 

阅读全文 | 回复(0) | 引用通告 | 编辑 | 收藏该日志]

发表评论:

    昵称:
    密码:
    主页:
    标题: