This chapter provides information for understanding the internals of FuguIta and for doing your own development based on FuguIta.
FuguIta is based on OpenBSD, so most of its components are openBSD-related information.
For the specific parts of FuguIta that are different from the official OpenBSD, please refer to List of published documents on the Japan Post top page of this site.
(Please note that some past materials may differ from the current FuguIta.)
FuguIta source code can be found at https://github.com/ykaw/FuguIta.
FuguIta has all writable files in memory, so even if the power is suddenly turned off without performing a shutdown operation, etc., there will be no problem with the file system.
Unless you save files with usbfadm during operation, the system will start up in the same state each time.
Using these characteristics, you can create a dedicated machine (Turn Key System) to run a specific application based on FuguIta.
To build such a system, we use a combination of the techniques described so far;
These detailed procedures can be found on this site Creating a router with Fuguita - Example of making an appliance and Practically used FuguIta to use.
Creating a LiveUSB according to the capacity of the USB memory created a LiveUSB image file. Describes how to create an image.
[Memo]
⇒Since this operation deals with large size files, the size of mfs must be more than 2 gigabytes.
If mfs isn't enough, mount another recording device and work there.
This master_dvd.sh can be used with either a working FuguIta LiveDVD or FuguIta LiveUSB.
Below is an example of using remaster_dvd.sh.
First, create a working directory and copy the contents of LiveDVD/LiveUSB under sysmedia.
fugu-demo# mkdir work fugu-demo# cd work fugu-demo# cp -av /sysmedia . /sysmedia -> ./sysmedia /sysmedia/boot -> ./sysmedia/boot /sysmedia/bsd-fi -> ./sysmedia/bsd-fi /sysmedia/bsd-fi.mp -> ./sysmedia/bsd-fi.mp /sysmedia/boot.catalog -> ./sysmedia/boot.catalog /sysmedia/cdboot -> ./sysmedia/cdboot /sysmedia/cdbr -> ./sysmedia/cdbr /sysmedia/etc -> ./sysmedia/etc /sysmedia/etc/boot.conf -> ./sysmedia/etc/boot.conf /sysmedia/etc/random.seed -> ./sysmedia/etc/random.seed /sysmedia/fuguita-6.9-amd64.ffsimg -> ./sysmedia/fuguita-6.9-amd64.ffsimg fugu-demo# ls -l total 8 drwxr-xr-x 3 root wheel 432 May 11 09:21 sysmedia
Run remaster_dvd.sh inside the copied sysmedia directory. Basically that's all.
fugu-demo# cd sysmedia fugu-demo# ls -l total 2008728 -rw-r--r-- 1 root wheel 90496 May 10 20:57 boot -rwxr--r-- 1 root wheel 2048 May 9 12:31 boot.catalog -rw-r--r-- 1 root wheel 10273019 May 10 21:04 bsd-fi -rw-r--r-- 1 root wheel 10302063 May 10 21:04 bsd-fi.mp -rw-r--r-- 1 root bin 91668 May 10 01:31 cdboot -rw-r--r-- 1 root bin 2048 May 10 01:31 cdbr drwxr-xr-x 2 root wheel 96 Apr 17 2014 etc -rw-r--r-- 1 root wheel 1007681536 May 10 21:08 fuguita-6.9-amd64.ffsimg fugu-demo# remaster_dvd.sh mkhybrid 1.12b5.1 Scanning . Scanning ./etc Size of boot image is 4 sectors -> No-emulation CD boot sector Total translation table size: 0 Total rockridge attributes bytes: 1111 Total directory bytes: 2048 Path table size(bytes): 22 502200 extents written (980 Mb)
After executing remaster_dvd.sh, an ISO image file will be created in the working directory.
fugu-demo# ls -l .. total 2008808 -rw-r--r-- 1 root wheel 1028505600 May 14 02:34 FuguIta-6.9-amd64-202105141.iso drwxr-xr-x 3 root wheel 384 May 14 02:34 sysmedia fugu-demo# ls -l total 2008720 -rw-r--r-- 1 root wheel 90496 May 10 20:57 boot -rwxr--r-- 1 root wheel 2048 May 14 02:34 boot.catalog -rw-r--r-- 1 root wheel 10273019 May 10 21:04 bsd-fi -rw-r--r-- 1 root wheel 10302063 May 10 21:04 bsd-fi.mp -rw-r--r-- 1 root bin 91668 May 10 01:31 cdboot -rw-r--r-- 1 root bin 2048 May 10 01:31 cdbr drwxr-xr-x 2 root wheel 96 Apr 17 2014 etc -rw-r--r-- 1 root wheel 1007681536 May 10 21:08 fuguita-6.9-amd64.ffsimg
There is a file called fuguita-6.9-amd64.ffsimg in sysmedia, which contains the FuguIta file tree. You can customize your LiveDVD by modifying the files in this file tree.
fugu-demo# vnconfig vnd0 fuguita-6.9-amd64.ffsimg fugu-demo# mount /dev/vnd0a /mnt fugu-demo# ls -l /mnt total 52 -rw-r--r-- 1 root wheel 578 May 7 17:43 .cshrc -rw-r--r-- 1 root wheel 468 May 7 17:43 .profile drwxr-xr-x 2 root wheel 512 May 7 17:43 altroot drwxr-xr-x 2 root wheel 1024 May 7 17:46 bin drwxr-xr-x 2 root wheel 512 May 8 04:16 dev drwxr-xr-x 23 root wheel 1536 May 8 04:35 etc drwxr-xr-x 2 root wheel 512 May 7 17:43 home drwxr-xr-x 2 root wheel 512 May 7 17:43 mnt drwx------ 3 root wheel 512 May 8 04:35 root drwxr-xr-x 2 root wheel 1536 May 7 17:46 sbin lrwxrwx--- 1 root wheel 11 May 7 17:43 sys -> usr/src/sys drwxrwxrwt 2 root wheel 512 May 8 04:19 tmp drwxr-xr-x 14 root wheel 512 May 8 04:09 usr drwxr-xr-x 23 root wheel 512 May 7 17:43 var .... (Customization work) ...
Once customization is complete, close the filesystem image and remaster.
fugu-demo# umount /mnt fugu-demo# vnconfig -u vnd0 fugu-demo# remaster_dvd.sh mkhybrid 1.12b5.1 Scanning . Scanning ./etc : :
This section introduces how to create a LiveUSB disk image file.
Run usbfadm newdrive:
? : ? ->newdrive Please make sure the device inserted. Then press ENTER -> ==== disk(s) and vnode devices ============================ sd0 at scsibus1 targ 0 lun 0: <ATA, Hitachi HTS72757, JF4O> sd0: 715404MB, 512 bytes/sector, 1465149168 sectors sd1 at scsibus2 targ 1 lun 0: <UFD 3.0, Silicon-Power32G, 1.00> sd1: 29624MB, 512 bytes/sector, 60669952 sectors sd2 at scsibus5 targ 1 lun 0: <BUFFALO, USB Flash Disk, 4000> sd2: 7788MB, 512 bytes/sector, 15950592 sectors img: create FuguIta raw disk image on current directory ============================================================ Enter the name of device which FuguIta will be installed->img ← Specify "img" to create an image file. Enter size of a vnode device file. You can add suffix K, M, G or T (otherwise considered 'bytes'). ->2g 2048+0 records in 2048+0 records out 2147483648 bytes transferred in 3.076 secs (698129518 bytes/sec) Disk: vnd0 geometry: 41943/1/100 [4194304 Sectors] Offset: 0 Signature: 0x0 Starting Ending LBA Info: #: id C H S - C H S [ start: size ] ------------------------------------------------------------------------------- 0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused 1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused 2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused 3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused Select partition type: 1: [MBR] 2: GPT 3: Hybrid (not recommended if you wish modify partitioning later) -> ~ 略 ~ ** Phase 5 - Check Cyl groups 3 files, 3 used, 386996 free (20 frags, 48372 blocks, 0.0% fragmentation) ? : ? ->bye Bye bye... $
A disk image file is created in the current directory by the above operations. The file name will be the same as the distributed one, "FuguIta-OPENBSD_VERSION-PLATFORM-RELEASE.img".
The FuguIta build tool is irregularly published. By using this build tool, you can create the same thing as the distribution of FuguIta.
This section explains the steps to build FuguIta using the build tool.
The following explanation assumes the following environment.
Before starting build, perform the following preparations:
[Memo]
⇒As explained inrelease(8), you will need a file system separate from the root file system to install the built system ( ``DESTDIR'' as described in release(8)).
Please specify this file system when installing OpenBSD. The size should be approximately 4GB or more.
# pkg_add rsync pv quirks-7.50:updatedb-0p0:(ok) quirks-7.50:(ok) Ambiguous: choose package for rsync a 0: <None> 1: rsync-3.3.0p2 2: rsync-3.3.0p2-minimal Your choice: 2 rsync-3.3.0p2-minimal:(ok) pv-1.8.5:libiconv-1.17:(ok) pv-1.8.5:gettext-runtime-0.22.5:(ok) pv-1.8.5:(ok) The following new rcscripts were installed: /etc/rc.d/rsyncd See rcctl(8) for details.
Download the build tool fuguita-buildtools-7.6.tar.gz from the tools directory of FuguIta download site and extract it.
# tar xvzpf fuguita-buildtools-7.6.tar.gz
Execute the following command to initialize the construction tool.
# cd fuguita-buildtools-7.6 # make init
This will create the directories needed for the build, etc.
Copy the install set (*76.tgz) generated by building OpenBSD to the install_sets directory of the FuguIta build tool.
# cp RELDIR/*76.tgz install_sets
RELDIR is the directory where generated release sets are stored, as described in release(8).
[Memo]
'⇒'' Installation set *76.tgz can also be downloaded and used from the official OpenBSD mirror.
However, in this case, the FuguIta created will be based on OpenBSD at the time the release was published, so no later patches have been applied. Please be careful.
Also, even if you create FuguIta using this method, you need to extract the OpenBSD source code under /usr/src or /usr/xenocara.
Next, build the rsync, rlwrap, and pv commands that will be called from FuguIta's utilities.
First, get the source code (xxHash is a high-speed hash calculation library. It is used when building rsync).
# cd /usr/ports/net/rsync && make fetch # cd /usr/ports/sysutils/xxhash && make fetch # cd /usr/ports/misc/rlwrap && make fetch # cd /usr/ports/sysutils/pv && make fetch
The obtained source code will be placed under /usr/ports/distfiles.
Link (or copy) this source code to the working directory for build and compile.
# pkg_add gmake (xxHashの構築に必要です) # cd (FuguItaビルドツールの置き場所)/fuguita-buildtools-7.6/fiopt/build # ln -s fiopt.mk Makefile # ln -s /usr/ports/distfiles/rsync-*.tar.gz . # ln -s /usr/ports/distfiles/xxHash-*.tar.gz . # ln -s /usr/ports/distfiles/rlwrap-*.tar.gz . # ln -s /usr/ports/distfiles/pv-*.tar.gz . # make RSYNC=rsync-3.3.0 XXHASH=xxHash-0.8.2 RLWRAP=rlwrap-0.46.1 PV=pv-1.8.5
Please specify the version of each source code you have actually
obtained as an argument to make.
If the build completes successfully, fiopt76.tar.gz will be created in the parent directory.
# cd .. # ls -l total 1736 drwxr-xr-x 2 root wheel 512 Nov 15 02:58 CVS drwxr-xr-x 7 root wheel 512 Dec 12 23:53 build -rw-r--r-- 1 root wheel 867970 Dec 12 23:53 fiopt76.tgz
Link (or copy) this to the install_sets directory.
# cd ../install_sets # ln -s ../fiopt/fiopt76.tgz . # cd ..
After preparing the files and commands required to build FuguIta, finally execute the following command to set up the build environment.
# make setup
[Memo]
⇒ You can customize FuguIta by placing a file called site76.tgz under install_sets. This customization method complies with OpenBSD's https://www.openbsd.org/faq/faq4.html#site.
If install.site is included in site76.tgz, its contents will be added to /etc/rc.firsttime.
As a result of building FuguIta by adding site76.tgz, if the file sysmedia/fuguita-7.6-amd64.ffsimg exceeds 2GB, the ISO image will not be created correctly. Please be careful.
Finally, build FuguIta.
To build both LiveDVD and LiveUSB, do the following:
# make all
Only LiveDVD is built with
# make livedvd
and this will only build LiveUSB.
# make liveusb
This file is intended to save time when starting LiveDVD in mode 0 (without this file, there is no problem in booting FuguIta itself).
To create mode0symlinks.cpio.gz, boot the completed LiveDVD in mode 0 and run the gen_mode0sldir command as root with root privileges. After execution, a file called /etc/fuguita/mode0symlinks.cpio.gz will be created.
Place this file in the build tool's lib directory with the file name mode0symlinks.cpio.gz.amd64 and rebuild FuguIta to create FuguIta with mode0symlinks.cpio.gz installed.
# cp mode0symlinks.cpio.gz lib/mode0symlinks.cpio.gz.amd64 # make clean # make all
FuguIta has a file called /etc/fuguita/global.conf, which contains settings related to the entire system as shown below.
fuguita_sys_mb=1122 # size of sysmedia.img newdrive_defswap=16M # default swap size at usbfadm newdrive memfstype=mfs # 'mfs' or 'tmpfs' mfs_max_mb=30720 # mfs hard limit - 30GB
Among these, fuguita_sys_mb defines the size of the partition that stores the FuguIta system, and this value is used when remastering FuguIta LiveUSB.
The setting value of fuguita_sys_mb corresponds to the size of the livecd.iso file generated when building a LiveDVD, but it is safe to leave about 10MB in consideration of updates using the fiupdate utility.
# echo $(( $(wc -c < livecd.iso)/1024/1024+10 ))
Write the values displayed by this command to the lib/global.conf.amd64 file and rerun make.
# vi lib/global.conf.amd64 # make clean # make all
This section describes the main targets in the Makefile.