-
Notifications
You must be signed in to change notification settings - Fork 6
Home
An attempt at pulling the nanobsd development fragmentation back into a single place.
- Disk Image Formats
- Arm (Imported from BSDRP)
- Sparc64 (Imported from BSDRP)
- ISO Image support on i386 and amd64 (Imported from tools/tools/nanobsd/rescue)
- Use geom_label to locate the slices not device names. (Imported from BSDRP)
- Fixes from PR misc/136889 (Imported from BSDRP)
- Modular functions (each function in its own file).
- Modular target support.
A target is a NanoBSD configuration that can build images for multiple hardware platforms. Each target has the following basic structure (relative to nanobsd installation base):
targets target/{target name} target/{target name}/nanobsd.conf target/{target name}/make.conf.build target/{target name}/make.conf.install target/{target name}/Files target/{target name}/{target arch}/nanobsd.conf target/{target name}/{target arch}/make.conf.build target/{target name}/{target arch}/make.conf.install target/{target name}/{target arch}/Files
Each of the configuration files in the base of the target are processed first at the relevant stages. After these have been processed then the script will check to see if there is a config file in the target architecture sub directory and include it to override options on per platform basis.
You can add lines like those that follow to the nanobsd.conf in base of the target to restrict the supported architectures:
case ${NANO_ARCH} in i386) ;; *) echo "$0: Target ${NANO_TARGET} does not support the requested architecture ${NANO_ARCH}" >&2 exit 1 esac
This snippet will allow the target to built only on i386 systems.
- Setup default config
- Parse config file
- Setup build
- Clean out build tree (optional)
- Build
- Generate make.conf.build
- Build World
- Build Kernel
- Generate the installed world
- Clean out _.w
- Generate make.conf.install
- Install world (make installworld)
- Install etc (make distribution)
- Customize install for nanobsd
- Setup nanobsd etc
- Install kernel
- Run all scripts registeres with customize_cmd
- Setup nanobsd disk layout for ramdisks
- Prune empty dirs in /usr
- Run all scripts registered with late_customize_cmd
- Create the disk image
- Run last_orders.
In the original nanobsd there is a core set of functions embedded in the shell script and if you want to make changes to them you have to redefine them; also if you wanted to add extra functions you would normally end up defining them in the config file. Personally I find this solution rather ugly, so one of the main features of NanoBSD NG is to split each function into a separate file.
- build_kernel
- Builds the kernel specified in NANO_KERNEL
- build_world
- Builds the world from the specified source directory.
- clean_build
- Cleanup
- clean_world
- Cleanup
- install_etc
- Use distribution target to install files for /etc and create an empty make.conf
- install_kernel
- Installs the kernel specified in NANO_KERNEL
- install_world
- Install world.
- make_conf_build
- Concatenate all target make.conf.build's into the build environment.
- make_conf_install
- Concatenate all the target make.conf.build's and make.conf.install's into the build environment.
- prune_usr
- Remove empty directories from under /usr
- setup_nanobsd
- Configure the filesystem layout to work in the nanobsd fasion.
- setup_nanobsd_etc
- Configure settings under /etc in the image to work with nanobsd.
These functions setup the following variables based on the manufacturer/type and size of the media:
- NANO_HEADS
- NANO_SECTS
- NANO_MEDIASIZE
- FlashDevice
- This function takes manufacturer name and size as arguments.
- UsbDevice
- This functions takes generic-hdd/generic-fdd and a size as arguments.
NanoBSD currently provides support for creating disk images for the following platforms:
- amd64
- arm
- i386
- sparc64
These functions are covered in detail in the customization section of usage.
- pprint
- Pretty print a log message at a level.
- run_customize
- Run the commands registered with customize_cmd
- run_late_customize
- Run the commands registered with late_customize_cmd
This assumes we are creating a target called: tiny.
Check out a working copy of NanoBSD NG:
cd /usr/local git clone git://github.com/amishHammer/NanoBSD-NG.git nanobsd cd nanobsd
I would recommend you take a look at targets/default/nanobsd.conf, this file contains the default settings for the configuration options.
Now you need create the target directory and create some config files:
mkdir targets/tiny
We are going to put the following settings in targets/tiny/nanobsd.conf
NANO_NAME=TINY NANO_SRC=/usr/src NANO_KERNEL=GENERIC NANO_IMAGES=2 FlashDevice Sandisk 2g
If you want to make a bootable CD (you will need cdrtools installed) then you can replace the FlashDevice line with:
NANO_IMAGE_TYPE=cdNow you can place tunable knobs (see src.conf(5) and make.conf(5)) to the the targets build configuration files:
We don't bind or games in our build so we add the following to targets/tiny/make.conf.build
WITHOUT_BIND=YES WITHOUT_GAMES=YES
We also don't want to install a tool chain into the image so we add the following to targets/tiny/make.conf.install
WITHOUT_TOOLCHAIN=YES
Now we can generate the build:
./nanobsd.sh -t tiny
If we want to cross build an amd64 image we can do the following:
./nanobsd.sh -t tiny -a amd64
The nanobsd framework is very flexiable and will allow you to customize the created image in any way you want. The system ships with a number of functions out the box to help you customize you images.
You can register customization functions to run using one of the following configuration directives in your nanobsd.conf.
- customize_cmd
- Register a command to run as part of the normal customization process.
- late_customize_cmd
- Register a command to run as part of the late customization process.
customize_cmd cust_pkg customize_cmd cust_console_serial
The variable NANO_SERIAL_SPEED is used by all of the console customization functions to set the speed of the serial ports. This variable should contain the port speed in bps. The default speed is 9600 baud.
- cust_console_dual
- Configure the image in dual console mode. This will activate the serial console and VGA console on the system and allow logins on the serial ports as well as the VGA console.
- cust_console_serial
- Configure the image to only have a serial console. This will activate the serial console and disable the VGA console.
- cust_console_vga
- This will set the VGA console to be the main console but will also activate the serial ports to access VT100 logins.
The system includes two functions to help you install packages in your images. These functions are only compatible with image creation for the same target architecture as the host environment. The only notable exception to this is building i386 images on amd64 hosts, this should work but at the time of writing is untested.
- cust_pkg
- This function copies the packages from targets/{target}/{target arch}/Pkg into the image and installs them with pkg_add.
- cust_pkg_fetch
- This function looks for lists of packages to be installed in the following files: targets/{target}/package.list and targets/{target}/{target arch}/package.list. For each file the script will iterate though the lines executing pkg_add -r on each entry. This function also temporarily copies the hosts resolv.conf into the image so that DNS works.
- cust_allow_ssh_root
- Set "PermitRootLogin yes" in sshd_config
- cust_install_files
- Install files stored in the following Files directories:
- targets/default/Files
- targets/{target}/Files
- targets/{target}/{target arch}/Files
- cust_remove_paths
- This function looks for files containing lists of paths to remove from the image in the following files: targets/{target}/remove.list and targets/{target}/{target arch}/remove.list
Incorporate the following PR's