#author("2023-02-20T16:06:12+09:00","default:kaw","kaw")
#author("2023-05-30T15:18:31+09:00;2023-04-30T23:11:45+09:00","default:kaw","kaw")
#navi(FuguItaGuide)
[[Introduction>fg2:pagetop]] explained the basic usage procedure of FuguIta. ~
[[Introduction>fge2:pagetop]] explained the basic usage procedure of FuguIta. ~
In this chapter, we will introduce more advanced usage that takes advantage of the features of FuguIta.

>''[Memo]''~
''⇒''This chapter assumes that you continue to use the environment set in [[Introduction>fg2:pagetop]] as follows:
''⇒''This chapter assumes that you continue to use the environment set in [[Introduction>fge2:pagetop]] as follows:
- Assuming fugu-demo.localnet as hostname
- ready to access internet
- General user yoshi is created. Since yoshi also belongs to the wheel group, he can become root.

#contents
* Manage OpenBSD [#wfc42427]

#aname(pkg_add)
** Add application software [#o79d8c5f]
FuguIta can add various software in addition to the software provided by OpenBSD.

The easiest way to add software is to use OpenBSD's ports/packages system. ~
To add software for packages, run the command [[pkg_add>man:pkg_add]] as root. As an example, here is an example of installing Mozilla
Firefox, a web browser.
 fugu-demo$ su -
 Password:
 fugu-demo# pkg_add firefox
 quirks-4.53 signed on 2021-12-19T13:27:04Z
 quirks-4.53:(ok)
 firefox-95.0.1:libiconv-1.16p0:(ok)
 firefox-95.0.1:gettext-runtime-0.21p1:(ok)
     :
     略
     :
 firefox-95.0.1:dconf-0.40.0:(ok)
 firefox-95.0.1:gtk+3-3.24.30:(ok)
 firefox-95.0.1:(ok)
 Running tags:ok
 The following new rcscripts were installed: /etc/rc.d/messagebus
 See rcctl for details.
 New and changed readme(s):
         /usr/local/share/doc/pkg-readmes/dbus
         /usr/local/share/doc/pkg-readmes/firefox
         /usr/local/share/doc/pkg-readmes/glib2
         /usr/local/share/doc/pkg-readmes/gtk+3
 fugu-demo# exit
 fugu-demo$
In the above example, we temporarily became root using the [[su>man:su.1]] command. Of course, you can log out of yoshi, log back in as root, and execute pkg_add there.
Executing pkg_add will also add other software required to run the target application. In the firefox example above, these are libiconv, gettext-runtime, dconf, gtk+3, etc.
It is displayed that there is a document about the installed software under the  directory /usr/local/share/doc/pkg-readmes, so it is a good idea to read it.

Applications can be added in a manner similar to the example above. ~
See https://ftp.jaist.ac.jp/pub/OpenBSD/7.2/packages/amd64/ with a web browser to see what software can be pkg_added from ports/packages.
>''[Memo]'' ~
''⇒''The ports/packages system is explained in detail at https://www.openbsd.org/faq/faq15.html. Also, in the above example, we used ftp.jaist.ac.jp as the download source, but there are other download sites, and you can see the list at https://www.openbsd.org/ftp.html. increase. ~
''⇒''It is also possible to directly compile and install the source code released by the software developer without using ports/packages, so-called "stray build".

On FuguIta, the software added by pkg_add is also subject to data save/restore by the usbfadm command.

#aname(configntp)
** Server setting example - change the NTP server that refers to the time [#q727987b]
NTP (Network Time Protocol) is a protocol (communication protocol) for synchronizing the time of each computer while communicating on the network. ~
OpenBSD has a function to synchronize its own time with the time reference on the Internet using NTP, and this function can also be used in FuguIta.

OpenBSD configures whether to use NTP during installation. On the other hand, FuguIta has this feature enabled by default.

The NTP function is implemented by the program [[ntpd>man:ntpd.8]], and to see the operating status of ntpd, execute the command [[ntpctl>man:ntpctl.1]] increase.
>''[Memo]''~
''⇒''The NTP
software used by OpenBSD is called ``[[OpenNTPD>http://www.openntpd.org]]'' and was created by the OpenBSD developers. ~
Linux and FreeBSD use different implementations of the same ntpd.
 $ ntpctl -s status
 fugu-demo$ ntpctl -s status
 4/4 peers valid, constraint offset 0s, clock synced, stratum 3
If "clock synced" is displayed as in the above example, ntpd communicates with the external NTP server that serves as the time reference, and as a result, you can see that the time is synchronized. on the other hand,
 $ ntpctl -s status
 fugu-demo$ ntpctl -s status
 0/1 peers valid, clock unsynced
If it is "clock unsynced" like this, the time has not been synchronized for some reason.

On OpenBSD, if the NTP function is enabled during installation, it will refer to a group of servers called pool.ntp.org as the time reference, and FuguIta's settings follow that.

On corporate LANs, etc., communication with external NTP servers such as pool.ntp.org may not be possible due to security concerns. In such a case, if an NTP server is operated on the company LAN, the local host's time can be kept accurate by referring to that server.

Here is how to configure the NTP server;

ntpd is configured by the file [[/etc/ntpd.conf>man:ntpd.conf.5]], so edit ntpd.conf with root privileges.

 $ doas -s
 fugu-demo$ doas -s
 Password:
 # vi /etc/ntpd.conf
 fugu-demo# vi /etc/ntpd.conf

  ntpd.conf内のこの3行を
   ↓
 servers pool.ntp.org
 sensor *
 constraints from "https://www.google.com"
   ↓
  以下の一行に変更
   ↓
 server ntp.localnet
In the above example, the settings are changed to refer to the NTP server "ntp.localnet".

After editing the configuration file, restart ntpd to reflect the changes. ~
A program like ntpd that runs in the background and provides services is called a daemon in Unix, but OpenBSD uses the command [[rcctl>man:rcctl.8]] to operate the daemon can.
 # rcctl restart ntpd
 fugu-demo# rcctl restart ntpd
 ntpd(ok)
 ntpd(ok)
 # 
 fugu-demo# 
Since the setting change work is completed above, return to the general user from root. After that, monitor the behavior of ntpd with ntpctl.
 # exit
 $ ntpctl -s status
 fugu-demo# exit
 fugu-demo$ ntpctl -s status
 1/1 peers valid, clock unsynced
If it looks like the above, it is not synchronized (yet), but you can see that one peer (peer, referring NTP server) is valid.
 $ ntpctl -s status
 fugu-demo$ ntpctl -s status
 1/1 peers valid, clock synced, stratum 3
After a while, it was confirmed that the time was synchronized.

ntpctl can also display the state of ntpd in more detail.
Inaddition, ntpd itself leaves operation records in log files such as/var/log/daemon and /var/log/messages. ~
For details, refer to the manual page of each command and configuration file.

>''[Memo]'' ~
''⇒''ntpd corrects the time drift very slowly. This is because a sudden big change in the time may adversely
affect the operation of the system. Therefore, if the time difference is large, it may take a long time to synchronize.

#aname(osconfig)
** Change OS settings [#u31180aa]
In the previous section, [[How to change the NTP server settings>#configntp]].

This section describes the configuration of services running on OpenBSD.
Because it's not realistic to give a detailed description of every configuration method, I'll divide the configuration into categories and explain each of those categories.

***kernel parameters [#k4e6e3b9]
Functions of the OpenBSD kernel
can be controlled in a number of ways, one of which is using the [[sysctl>man:sysctl.8]] command.
 $ sysctl -a | less
 fugu-demo$ sysctl -a | less
 kern.ostype=OpenBSD
 kern.osrelease=5.8
 kern.osrevision=201510
 kern.version=OpenBSD 5.8-stable (RDROOT.MP) #2: Wed Nov 11 13:18:48 JST 2015
     root@nimbus5.localnet:/opt/fi/5.8/sys/arch/i386/compile/RDROOT.MP
 
 kern.maxvnodes=44152
 kern.maxproc=1310
   ~以下略~
The example above shows all kernel parameters. ~
Since the display content does not fit on one screen, the display data is piped to the pager program [[less>man:less.1]] and displayed.

If you know in advance which parameter you want to display, you can specify its name to display it. ~
The example below shows the maximum amount of memory to allocate for file I/O buffering.
 $ sysctl kern.bufcachepercent
 fugu-demo$ sysctl kern.bufcachepercent
 kern.bufcachepercent=20
 $
From this display, you can see that the buffer is set to allocate up to 20% of the installed memory capacity.

To change this value: Root privileges are required to change settings, so sysctl commands are executed via the doas command.
 $ doas sysctl kern.bufcachepercent=50
 fugu-demo$ doas sysctl kern.bufcachepercent=50
 Password:
 kern.bufcachepercent: 20 -> 50
 $
You can also set it automatically at system startup instead of manually running the sysctl command. For that, write the contents you want to set in a file called [[/etc/sysctl.conf>man:sysctl.conf.5]].
>''[Memo]'' ~
''⇒''In addition to changing kernel settings Rewrite kernel by
-config command
-Change at boot time with UKC (User Kernel Config)
-kernel recompile

>There are methods such as, but the contents that can be set and the difficulty of work differ for each. For details, please refer to each manual page and [[FAQ on the official site>http://www.openbsd.org/faq/faq5.html]].

#aname(netconfig)
***Network Basic Settings [#g5485916]
As explained above, network-related settings are made when FuguIta starts up, so if you can communicate without any problems, you don't need to change any settings. ~
If you operate FuguIta as a server or network gateway, you may need to change or add settings.
:Interface Settings | Settings related to network interfaces such as IP addresses and netmasks are set in the file /etc/hostname.<interface name>. The format of this file can be found at [[hostname.if(5)>man:hostname.if.5]].
>''[Memo]'' ~
''⇒''What kind of network interfaces your PC has is displayed with "[[ifconfig>man:ifconfig]] -a".

:route control|default route is described in [[/etc/mygate>man:mygate]]. For other route control, run the route control daemon or describe the execution of the route command in /etc/hostname.if or /etc/rc.local.
:Name resolution|[[/etc/resolv.conf>man:resolv.conf.5]]
:Packet filtering|[[PF>man:pf]] is a packet filter developed by OpenBSD, but it has a lot of functions other than filtering such as network bandwidth control and address conversion. . For PF, there are online manuals such as [[pfctl(8)>man:pfctl.8]] and [[pf.conf(5)>man:pf.conf.5]] [[PF - User's Guide>https See http://www.openbsd.org/faq/pf/index.html]].

*** Daemon start/stop and setting [#j3b1b712]
OpenBSD comes with various daemons installed, including some that don't run by default.
[[Change the NTP server that refers to the time>#configntp]] explained how to start, stop, and change the settings of the NTP daemon as an example. Follow similar steps for other daemons.

On OpenBSD, [[/etc/rc.conf.local>man:rc.conf.local.8]] controls the startup of such daemons. and options to be given to the daemon at startup.
>''[Memo]'' ~
''⇒''Actually, all daemons are specified in [[/etc/rc.conf>man:rc.conf.8]], and rc.conf.local is
rc.conf works to override the settings of

To control the behavior of various daemons, the contents of rc.conf.local are changed, so edit it with a text editor.In addition, the command [[rcctl>man:rcctl.8]] can be used to control starting/stopping daemons and to change settings.
Like ntpd is configured via ntpd.conf, other daemons also have their own configuration files, many of which reside directly under /etc.
In addition, the directory /etc/examples contains sample files for setting various daemons, so you can refer to, copy, or edit these files as actual setting files.

*** Other settings [#b1cb73a2]
[[/etc/rc.local>man:rc.local]] is a shell script executed during the final stages of system startup. If you want to perform processing other than what has been explained so far, describe the processing in this file.

Please refer to [[rc(8)>man:rc.8]] for how OpenBSD starts up and shuts down.

* FuguIta boot mode [#q98d81f4]
** Boot Mode 1 - Faster boot time / Saves memory usage [#pb06b5f7]
If you specify mode 1 when starting FuguIta, the time required for the system to complete booting
will be shortened. ~
Various setting items are the same as mode 0.
 Select boot mode;
   0: fresh boot (normal)
   1: fresh boot (lower memory, faster boot than mode 0)
   2: fresh boot (works only on mfs)
   3: retrieve user data from USB flash memory
   4: retrieve user data from floppy disk
   5: interactive shell for debugging
 ->1
Memory usage (mfs size) after startup is also less than mode 0. ~
As a guideline, it will be possible to operate from a machine with about 64 MB of mounted memory;
 File usage (mode 0)
 $ df -h
 fugu-demo$ df -h
 Filesystem     Size    Used   Avail Capacity  Mounted on
 /dev/rd0a      1.6M    729K    833K    47%    /
 /dev/cd0a      697M    697M      0B   100%    /sysmedia
 /dev/vnd5a     676M    664M   11.9M    98%    /fuguita
 mfs            698M   25.5M    673M     4%    /ram

 File usage (mode 1)
 $ df -h
 fugu-demo$ df -h
 Filesystem     Size    Used   Avail Capacity  Mounted on
 /dev/rd0a      1.6M    730K    832K    47%    /
 /dev/cd0a      697M    697M      0B   100%    /sysmedia
 /dev/vnd5a     676M    664M   11.9M    98%    /fuguita
 mfs            713M    6.8M    706M     1%    /ram
However, boot mode 1 has the advantage of requiring fewer resources than the standard boot mode, mode 0, but has the disadvantage of not being able to change files and directories under /usr. In other words, you cannot add applications using pkg_add or the like.

Start mode 1 can be used when operation is possible only with the software included in FuguIta.
The above situation will be inherited even if you restart in mode 3 after starting in mode 1 and saving the file with usbfadm.

** Boot Mode 2 - Operation in memory [#a816b1ef]
Boot mode 2 is a mode in which all files are transferred on mfs and everything operates in memory.
 Select boot mode;
   0: fresh boot (normal)
   1: fresh boot (lower memory, faster boot than mode 0)
   2: fresh boot (works only on mfs)
   3: retrieve user data from USB flash memory
   4: retrieve user data from floppy disk
   5: interactive shell for debugging
 ->2
In mode 2, DVD and USB memory are unmounted when the system boot is completed, so you can remove those devices and operate. Since program execution and file reading and writing are all performed in memory, it can be expected to operate faster than modes 0 and 1.
 $ df -h
 fugu-demo$ df -h
 Filesystem     Size    Used   Avail Capacity  Mounted on
 /dev/rd0a      1.6M    730K    832K    47%    /
 mfs            813M    736M   76.7M    91%    /ram
However, as explained at the beginning, in this mode 2, all system files on the DVD or USB memory are copied to mfs, so the amount of installed memory on the PC should be approximately 800MB or more as a guide.

Even in mode 2, if the file is saved with usbfadm and then restarted in mode 3, the state at the time of file saving is restored.

>''[Memo]'' ~
''⇒''Please note that the device cannot be removed in the following cases.
- if virtual memory usage is greater than real memory and swap partition cannot be disabled (warning message is displayed)
- If you are using [[encrypted partition>#encrypt]] (you will get a warning message)
- If you [[additionally mount >#fstab_tail]] partitions in that device

** boot mode and file system [#x19e8b61]
What is the difference in file system structure between boot mode 0 and boot mode 1?
The differences are explained below.
#ref(FuguIta/BBS/11/fi-filesys-mode0.png,wrap,around,right,50%)
The diagram on the right shows the file layout in startup mode 0 (click the diagram to enlarge).
Example path for /bin/ed, /usr/bin/vi, pkg_added /usr/local/bin/emacs.

Root filesystem is RAM DISK, [[rd>man:rd.4]]. This device is built into the kernel and has already been mounted since system boot. Under root is an unfamiliar directory called "boottmp". It contains commands that are necessary at the very beginning of system startup and utilities specialized for FuguIta.

The FuguIta device is actually a DVD or USB memory that stores the boot loader, OS kernel, and file system image p. It is mounted read-only at /sysmedia.
The file system image on /sysmedia is mapped to /dev/vnd4 and mounted at /fuguita. This is the OpenBSD file tree. It's pretty much the original OpenBSD, except for a few changes to match the live system. This file system is also read-only. Therefore, files cannot be created, modified, or deleted under this.

/ram is a memory file system called [[mfs>man:mfs.4]] (memory file system) and is both readable and writable. Files that need to be changed, such as /etc/*.conf, user data under /home, and software added by pkg_added, are placed above this. Also, files that rarely change are replaced with symlinks to
equivalent files in /fuguita. This will reduce the memory usage of mfs.
#clear
#ref(FuguIta/BBS/11/fi-filesys-mode1.png,wrap,around,right,50%)
Next is boot mode 1. In boot mode 1, /usr is symbolically linked to /fuguita/usr. This makes booting faster and using less memory than mode 0 by not copying or linking /usr to /ram. However, /usr/local is not writable, so pkg_add is not possible.
#clear
#ref(FuguIta/BBS/11/fi-filesys-mode2.png,wrap,around,right,50%)
The file layout for boot mode 2 is shown on the right. This is much simpler than modes 0 and 1, only / and /ram are mounted and all external devices are unmounted. Of course, all files can be changed.
#clear

* Management of FuguIta [#d77afde7]
#aname(dtjsetup)
** Install the Japanese desktop environment [#l12f579b]
On Fuguita, you can install the Japanese desktop environment by executing the command dtjsetup.
Below is an example of running dtjsetup.
 # dtjsetup                                   ← Start dtjsetup
 fugu-demo# dtjsetup                          ← Start dtjsetup
                                                (Both root and general users can use it)
 #==========================================
 # Welcome to dtjsetup
 #     Desktop (and Japanese) setup utility
 #
 # for FuguIta-6.6-amd64-202001171
 #==========================================
 
 Which desktop software will you install?     ← Choosing a desktop environment
   1:  no desktop (wm only)
   2: [rox-filer]
   3:  xfce
   4:  mate
   5:  lumina
   6:  lxqt
 ->                                           ← If you enter only [ENTER],
                                                 the You have selected the item.
 Which window manager will you install?       ← Select a window manager if you selected
   1:  cwm                                       1 or 2 in the previous section.
   2:  fvwm                                      
   3:  twm                                       
   4: [icewm]
   5:  fluxbox
   6:  jwm
 ->
 
 Will you setup Japanese language environment? [y/N] -> y
 Which input method will you install? 
   1: [scim-anthy]
   2:  uim-gtk
   3:  fcitx-anthy
   4:  ibus-skk
 ->
 
 *** You selected icewm as desktop software.
 *** Installing Japanese environment is YES.
 *** Japanese input method is scim-anthy.
 
 *** Checking your root authorization...
 *** OK.
 
 *** Checking network accessibility...
 *** OK.
 
 *** Installing packages: rox-filer icewm ja-kterm ja-sazanami-ttf mixfont-mplus-ipa mplus-fonts scim-anthy
 Will you continue? [y/N] -> y
 quirks-3.183 signed on 2020-01-31T18:21:51Z
 rox-filer-2.11p3:libiconv-1.16p0:ok
 rox-filer-2.11p3:xz-5.2.4:ok
     :
 icewm-1.6.1:libsndfile-1.0.28:ok
 icewm-1.6.1:ok
 Ambiguous: choose package for ja-kterm
 a	0: <None>
 	1: ja-kterm-6.2.0p9
 	2: ja-kterm-6.2.0p9-xaw3d
 Your choice: 1
 ja-kterm-6.2.0p9:ok
     :
 scim-anthy-1.2.7p11:ok
 Running tags:
 New and changed readme(s):
 	/usr/local/share/doc/pkg-readmes/glib2
 	/usr/local/share/doc/pkg-readmes/gtk+2
 	/usr/local/share/doc/pkg-readmes/scim
 --- +ja-sazanami-ttf-20040629p3 -------------------
 You may wish to update your font path for /usr/local/share/fonts/sazanami
 --- +mixfont-mplus-ipa-20060520p7 -------------------
 You may wish to update your font path for /usr/local/share/fonts/mixfont-mplus-ipa
 --- +mplus-fonts-063 -------------------
 You may wish to update your font path for /usr/local/share/fonts/mplus-fonts
 
 *** /root/.xsession already exists.
 *** This will be replaced with a new file.
 *** and the old one will be renamed to /root/.xsession_20200206_170903.
 
 *** Rewrite .xsession configuration file.
 Will you continue? [y/N] -> y
 
 Copy this .xsession file to /etc/skel ? [y/N] -> y    ← Once copied, this setting will be
                                                          inherited when a new user account is
                                                          created.
 *** Japanese environment and related software have been set up.
 *** However, the time zone has not yet been set to JST.
 Set timezone to JST? [Y/n] -> y
 
 *** When you use this machine both running OpenBSD and Windows.
 *** You may set the hardware clock to JST instead UTC.
 Set hardware clock to JST? [Y/n] -> n
 
 *** all installation and configuration completed.
 *** Check your /root/.xsession and login to X if OK.
 
 *** Note: You can save this configuration and addtionally installed softwares
 ***	  by using usbfadm utility.
 ***	  And can reload them at next boot time by selecting boot mode 3.
#ref(河豚板ガイド/DeskTop.jpg,wrap,around,right,33%)
After the above settings have been made, log out and log back in from the xenodm login screen to launch the installed desktop environment.

In the desktop environment, various applications can be added using the pkg_add command.

>''[Memo]''~
''⇒''Detailed explanation from installing FuguIta to installing various applications /ca008a34d73d5f1f6dd8]] has been published on the technical information sharing site Qiita. See also
#clear

***Enable login screen for X [#t5056563]
As described in [[Login method selection>fg1:loginmethod]] in FuguIta's startup settings, you can choose between the method of logging in from the console screen and the method of logging in from the X Window System login screen(xenodm). Select.
As described in [[Login method selection>fge1:loginmethod]] in FuguIta's startup settings, you can choose between the method of logging in from the console screen and the method of logging in from the X Window System login screen(xenodm). Select.

Even if you choose to log in from the console screen, you can later change the method to log in from the X Window System login screen (xenodm).~
To do this, modify the contents of the /etc/rc.conf.local file as described in [[Changing OS configuration>#osconfig]].

The following example uses the rcctl command to enable xenodem.
The following example uses the rcctl command to enable xenodm.

 $ doas rcctl enable xenodm  
 $ doas rcctl ls on
 fugu-demo$ doas rcctl enable xenodm  
 fugu-demo$ doas rcctl ls on
 check_quotas
 cron
 library_aslr
 ntpd
 pf
 pflogd
 slaacd
 smtpd
 sndiod
 sshd
 syslogd
 xenodm
 #
If you enable xdm with the rcctl command, you can see that the line "xdm_flags=" is added to rc.conf.local.
 $ cat /etc/rc.conf.local
 fugu-demo$ cat /etc/rc.conf.local
 xenodm_flags=
 $
After changing the settings, save with usbfadm, and then start xdm in mode 3.
>''[Memo]''~
''⇒''When xdm is displayed, press ''<Control>''+''<Alt>''+''<F1>'' to switch to the normal text login screen.
This virtual console has 12 faces in total,
''<Control>''+''<Alt>''+''<F1>'' to ''<Control>''+''<Alt>''+ Allocated up to ''<F12>''.
The X display is bound to the 5th virtual console, so pressing ''<Control>''+''<Alt>''+''<F5>'' will return you to the X screen.

///#aname(fiupdate)
///**FuguItaをアップデートする [#oa558bdd]
///OpenBSDは半年に一度、メジャーリリースが行われており、このとき OpenBSD 7.1 → OpenBSD 7.2 のようにバージョンが変わります。~
///そしてその半年にもセキュリティや安定性の向上などに関する修正が行われており、OpenBSDの式サイトでも http://www.openbsd.org/errata72.html で修正情報が提供されます。
///
///FuguItaもこの修正報への追従を行っており、現行で公開されている版はいままでの修正情報が全て適用されたものとなっています(実際には、適用作業と動作確認を行うため修正情報の公開からは数日程度のタイムラグがあります)。
///
///なお、FuguItaで現在運用中のOSのバージョンを確認するには次のようにコマンドを実行します。
/// $ uname -a                                       ← OSのバージョンを確認
/// OpenBSD fugu-demo.localnet 5.8 RDROOT.MP#2 i386
/// $ sysctl kern.version                            ← カーネルのバージョンを確認
/// kern.version=OpenBSD 5.8-stable (RDROOT.MP) #2: Wed Nov 11 13:18:48 JST 2015
///     root@nimbus5.localnet:/opt/fi/5.8/sys/arch/i386/compile/RDROOT.MP
/// 
/// $ cat /usr/fuguita/version                       ← FuguItaのバージョンを確認
/// 5.8-201512272
///
///この節では、現在お使いのFuguItaを最新版にアップデートする方法を解説します;
///
///***OpenBSDのメジャーリリースがバージョンアップした場合 [#a4c71402]
///これは、FuguItaがベースとしているOpenBSDのメジャーリリースが行われた場合です。例えば、
/// FuguIta-5.8-amd64-201504161
///          ↓
/// FuguIta-5.9-amd64-201510255
///ですが、これはFuguItaのベースとなっているOSがOpenBSD 5.8からOpenBSD 5.9に変っています。
///
///OpenBSDのメジャーリリースが変っている場合、システムのアップデートは困難です。~
///その理由は、OpenBSDがバージョンアップすると、システムコールの仕様変更、有ライブラリの互換性のないバージョンアップ、コマンドのや追加・削除や仕様変更などが大幅に行われるため、過去の環境を保ったままバージョンを移行することが現実的ではないためです。
///
///OpenBSDのメジャーリリースを跨いでの移行は、以下のような方法が推奨されます;
///
///+LiveDVDやLiveUSBを新規に作成する。
///+新しいバージョンのFuguItaを起動させ、古いバージョンのFuguItaから各種設定やユーザが作成したファイルなどの移行作業を行う。
///
///***OpenBSDのメジャーリリースは変わっていない場合 [#w52c2003]
///これは、
/// FuguIta-6.0-amd64-201511297
///           ↓
/// FuguIta-6.0-amd64-201512051
///のようにOpenBSDのバージョンを表す「6.0」の部分が変っていないことで確認できます。
///
///この場合はシステムの変更は部分的なものにとどまっていますので、ユーザデータの移行などは要ありません。
///システムの移行は、以下の手順で行います。
///
///''LiveDVDの移行手順''~
///LiveDVDの場合はメディアの部分的な書き換えはできませんので、新しいバージョンのLiveDVD版FuguItaを作り、それを使用する形になります。~
///USBメモリに保存したデータについては、そのまま起動モード3で読み込んで使用できます。
///
///''LiveUSBの移行手順''~
///LiveUSBの場合は、fiupdate (FuguIta update)というコマンドを用いることで、起動しているLiveUSBのアップデートを行うことができます。
///
///fiupdateを使うには、アップデート対象のLiveUSBをモード0、1あるいは2で起動します。~
///次に、布サイトより新しいバージョンのISOイメージとSHA256ファイルをダウンロードし、その後、fiupdateを起動します。
///>''【メモ】''~
///''⇒''LiveUSBをアップデートに使用するのはISOイメージファイルです。*.imgファイルではないことにご注意下さい。~
///''⇒''SHA256ファイルは、ダウンロードしたファイルの容が壊れていないことをチェックするためにfiupdateが使用します。
/// total 606752
/// -rw-r--r--  1 root  wheel  310651490 Oct  7 01:12 FuguIta-6.7-amd64-202010071.iso.gz
/// -rw-r--r--  1 root  wheel	 562 Oct  8 06:25 SHA256
/// 
/// fugu-demo# cat /usr/fuguita/version
/// 6.7-amd64-20209041
/// 
/// fugu-demo# fiupdate 202010071
/// 
/// fiupdate - Live Updater for FuguIta LiveUSB
///   Version/Arch: 6.7/amd64  (FuguIta-6.7-amd64-20209041)
/// 
/// Checking...
///      environment: ok
/// 
/// Note: This software is currently in beta testing.
///       Use this at YOUR OWN RISK.
/// 
///       We recommend that you run this command in fresh boot (boot mode
///       0, 1, or 2).
///       Alternatively, you must quit all application software and save
///       all your data before updating this FuguIta device.
/// 
///       All daemons, including xenodm, will be stopped before the update.
///       Please note that all X sessions will be aborted.
/// 
/// Do you proceed? [y/N] -> y
/// 
/// Checking...
/// 	checksum: (SHA256) FuguIta-6.7-amd64-202010071.iso.gz: OK
///      file layout: liveusb
///   existing files: ok
/// 
/// decompressing FuguIta-6.7-amd64-202010071.iso.gz...
/// 9296MiB 0:00:31 [9.51MiB/s] [================================>] 100% ETA 0:00:00
/// Now ready to update FuguIta-6.7-amd64-20209041 to FuguIta-6.7-amd64-202010071.
/// 
/// This machine will reboot immediately after update completed.
/// 
/// Do you proceed? [y/N] -> y
/// 
/// stopping all daemons...
/// cron(ok)
/// ntpd(ok)
/// pflogd(ok)
/// slaacd(ok)
/// smtpd(ok)
/// sndiod(ok)
/// sshd(ok)
/// syslogd(ok)
/// 
/// overwriting uniprocessor kernel...
/// 8.66MiB 0:00:06 [1.37MiB/s] [================================>] 100% ETA 0:00:00
/// overwriting multiprocessor kernel...
/// 8.69MiB 0:00:04 [1.84MiB/s] [================================>] 100% ETA 0:00:00
/// overwriting filesystem image...
/// 9864MiB 0:05:30 [3.05MiB/s] [================================>] 100% ETA 0:00:00
/// 
/// update completed.
/// now rebooting...
/// syncing disks... done
///アップデート完了後、PCは自動的に再起動します。~
///LiveUSBアップデート後の運用は今までと変りなく、データの移行等をする要もありません。
///
///>''【メモ】''~
///''⇒''fiupdateをネットワーク経由、あるいはX Window System上で実行すると、以下のような警告が表示されます。
/// It seems you are running this script on X Window System,
/// via network or something like this.
/// In this situation, during update, corresponding processes
/// will be killed and then update may fail.
/// 
/// Running this on direct console device is highly recommended.
/// 
/// Continue anyway? [y/N] ->
///fiupdateは、システムファイルを更新する前にてのデーモンを停止します。この時、ネットワークが切断されたりXのセッションが終了して、アップデートが失敗する可能性があります。~
///ですので、fiupdateはコンソールデバイス上で直接実行するようにして下さい。
///
///**FuguItaをモバイル環境で使う [#xb4d4820]
///FuguItaをモバイル環境の端末として使うためには、基本的な部分は固定環境での運用と大きく変わるところはありません。
///
///しかしモバイル環境特有の事を考慮し、設定を追加するとより効率的に運用できる面もあります。
///
///この節ではそのような設定目としてノートPCの電源関連について解説します。
///
///***電源関連の設定 [#sa3767ef]
///現在のPC、とりわけノートPCにはACPI (Advanced Configuration and Power Interface)やAPM (Advanced Power Management)という仕組みがあり、バッテリーなどの電源置の監視や制御を行うことができます。~
///OpenBSDではこれらの仕組みは[[acpi(4)>man:acpi.4]]、及び[[apm(4)>man:apm.4]]として実されており、管理用のコマンドを通じてアクセスすることができます。
///
///acpiやapmの管理は、[[apmd>man:apmd.8]]というデーモンにより行います。~
///apmdの状確認と設定を行います;
/// $ doas -s
/// Password:
/// # rcctl get apmd
/// apmd_class=daemon
/// apmd_flags=NO      ← apmdは無効(動作しない)設定になっている。
/// apmd_timeout=30
/// apmd_user=root
///apmdを有効にします。
/// # rcctl enable apmd
/// # rcctl set apmd flags -A  ← CPU負荷に応じてCPUクロック周波数を自動で変化させる
/// # rcctl start apmd
/// # rcctl get apmd
/// apmd_class=daemon
/// apmd_flags=
/// apmd_timeout=30
/// apmd_user=root
/// # 
///設定が完了したら[[usbfadmコマンドを使用して保存>fg2:usbfadm_sync]]し、FuguItaを[[モード3で再起動>fg2:boot_mode3]]します。
///
///apmdが稼動している状では、[[apm>man:apm.8]]というコマンドで状態の監視と制御が可能です。
/// $ apm
/// Battery state: high, 89% remaining, 57 minutes life estimate
/// A/C adapter state: not connected
/// Performance adjustment mode: auto (1000 MHz)
///以下の例では、apmコマンドに-Lフラグを与えて、CPUが常時低クロックで動作するように設定しました;
/// $ apm -L
/// $ apm
/// Battery state: high, 88% remaining, 42 minutes life estimate
/// A/C adapter state: not connected
/// Performance adjustment mode: manual (1000 MHz)
///バッテリーなどハードウェアの状は、sysctlコマンドや[[systat>man:systat.1]]コマンドでもモニタできます。
/// $ sysctl hw.sensors
/// hw.sensors.acpitz0.temp0=55.50 degC (zone temperature)
/// hw.sensors.acpiac0.indicator0=Off (power supply)
/// hw.sensors.acpibat0.volt0=14.80 VDC (voltage)
/// hw.sensors.acpibat0.volt1=15.30 VDC (current voltage)
/// hw.sensors.acpibat0.current0=1.19 A (rate)
/// hw.sensors.acpibat0.amphour0=1.12 Ah (last full capacity)
/// hw.sensors.acpibat0.amphour1=0.21 Ah (warning capacity)
/// hw.sensors.acpibat0.amphour2=0.07 Ah (low capacity)
/// hw.sensors.acpibat0.amphour3=0.92 Ah (remaining capacity), OK
/// hw.sensors.acpibat0.amphour4=2.15 Ah (design capacity)
/// hw.sensors.acpibat0.raw0=1 (battery discharging), OK
/// hw.sensors.acpibtn0.indicator0=On (lid open)
/// hw.sensors.acpidock0.indicator0=Off (not docked), UNKNOWN
/// hw.sensors.cpu0.temp0=55.00 degC
///
/// $ systat sensors
///     3 users    Load 0.40 0.42 0.37                     Wed Dec 30 04:18:11 2015
/// 
/// SENSOR                                 VALUE  STATUS  DESCRIPTION
/// acpitz0.temp0                     56.50 degC          zone temperature
/// acpiac0.indicator0                       Off          power supply
/// acpibat0.volt0                    14.80 V DC          voltage
/// acpibat0.volt1                    15.26 V DC          current voltage
/// acpibat0.current0                     1.08 A          rate
/// acpibat0.amphour0                    1.12 Ah          last full capacity
/// acpibat0.amphour1                    0.21 Ah          warning capacity
/// acpibat0.amphour2                    0.07 Ah          low capacity
/// acpibat0.amphour3                    0.90 Ah    OK    remaining capacity
/// acpibat0.amphour4                    2.15 Ah          design capacity
/// acpibat0.raw0                          1 raw    OK    battery discharging
/// acpibtn0.indicator0                       On          lid open
/// acpidock0.indicator0                     Off unknown  not docked
/// cpu0.temp0                        56.00 degC
///systatコマンドはデフォルトでは5秒おきに状を更新し、表示を続けます。「q」を入力すると終了します。
///
///apmコマンドはまた、PCを休止状にすることができます。~
///休止状にするにはapmコマンドの他、[[zzz>man:zzz.8]]や[[ZZZ>man:ZZZ.8]]などのコマンドも使用可能です。また、PCの機種によっては特定のキーに休止動作が割り付けられているものもあります。~
///休止からの復帰方法は機種により異なりますが、電源ボタンを短かく押したり休止キーを再度押したりするものが多いようです。
///>&color(red){''【ご注意】''&br;''!!''スタンバイ、スリープやハイバーネートのような休止動作を行うと、USBデバイスは切り離され、復帰時に再接続されます。従ってUSBデバイス上のファイルシステムをマウントしているLiveUSB版FuguItaはシステム復帰後、正常に動作しなくなりますのでご注意下さい。&br;''!!''PCの機種によっては休止動作がうまくいかないものがあります(スタンバイはできるがサスペンドやハイバーネートはできない、休止状から復帰できない、あるいは動作が不安定で時々復帰に失敗する、など)。使用にあたっては事前の動作確認をお願いします。};
///
///Xを使用している時は、xsetコマンドでディスプレイを制御できます。ホームディレクトリ直下の .xinitrc に以下のような行を追加します;
/// xset s on     ← スクリーンセーバーを有効にする
/// xset s 180    ← スクリーンセーバーの動作開始時間(秒)
/// xset +dpms    ← ディスプレイを省電力モードに移行
///この例の設定をおこなうと、マウスやキーボードの操作が180秒以上行われない場合、ディスプレイが省電力モードになります。
///
///#aname(netconf)
///***複数のネットワーク設定を切り換えて使用する [#q3ef73cd]
///ネットワークの設定は[[ネットワークの基本設定>#netconfig]]で説明したように/etcディレクトリ以下のいくつかのファイルで行われますが、FuguItaではgennetconfsというコマンドを用いることでそれらのファイルを生成することができます。~
///また、ネットワークの設定は複数持つことができ、chnetconfというコマンドで切り換えて使うことができます。
///
///FuguItaでは、ネットワーク関連の設定ファイルは/etc/fuguita/netconfs下のサブディレクトリに格納され、ネットワークを起動する前にそのサブディレクトリの中のファイルが/etcにコピーされ、その後、ネットワークが設定されます。~
///初期ブートで行った設定は、/etc/fuguita/netconfs/defaultの中にあります。
///
///例として、自用に「home」、職場用に「office」という2つの設定を追加してみます。
///
///まず、officeから。これは、イーサネットに接続し、固定アドレス設定での使用を想定しています。新しい設定を追加するには、設定名「office」を指定してgennetconfsを起動します。
/// fugu-demo# gennetconfs office
/// ===================================================
/// = gennetconfs: generate network configuration files
/// ===================================================
/// 
/// Hostname with domain part (FQDN):
/// only host name without domain part is also OK.
/// -> fuguita.office.local
/// 
/// IP protocol version(s) to be enabled: 4, 6, 46, 64 or "none"
///   4: enable only IPv4
///   6: enable only IPv6
///   46: give priority to IPv4 name resolution
///   64: give priority to IPv6 name resolution
///   none: operate as standalone
/// [64] -> 4
/// 
/// Network Interfaces: Choose one
/// 
///   NIC	 type	   Name
/// -------- ----- ------------
///     bge0 ether Broadcom BCM57765
///   urtwn0 wifi  GW-USValue-EZ GW-USValue-EZ
/// [bge0] -> bge0
/// 
/// IPv4 - address and routing:
///   Enter "auto" or "IPv4_address[/mask] [default_gateway]"
///   "auto" is an automatic setting by DHCP.
///   The "/mask" part can be specified in either format, such as "/255.255.255.0" or "/24".
///   If there is no default gateway, set the second field to "none" or leave it blank.
/// [auto] -> 192.168.20.115/24 192.168.20.254
/// 
/// DNS servers: up to 3 IP addresses, separated by spaces
/// -> 192.168.20.254
/// 
/// writing configured values to:
///   /etc/fuguita/netconfs/office/myname
///   /etc/fuguita/netconfs/office/mygate
///   /etc/fuguita/netconfs/office/hosts
///   /etc/fuguita/netconfs/office/hostname.bge0
///   /etc/fuguita/netconfs/office/resolv.conf
/// 
/// ======================================================
/// = end of gennetconfs:
/// = Use chnetconf utility to activate this configuration
/// ======================================================
///gennetconfsによる設定が完了すると、「/etc/fuguita/netconfs/設定名」の中に設定ファイルが作成されます。
/// fugu-demo# cd /etc/fuguita/netconfs/
/// fugu-demo# ls -l
/// total 24
/// drwxr-xr-x  2 root  wheel  144 Nov 25 05:46 default
/// drwxr-xr-x  2 root  wheel  240 Nov 25 07:00 office
/// drwxr-xr-x  2 root  wheel   96 Nov 18 05:49 templ.head
/// drwxr-xr-x  2 root  wheel    0 Nov 18 05:49 templ.tail
/// fugu-demo# ls -l office
/// total 40
/// -rw-r-----  1 root  wheel  23 Nov 25 07:00 hostname.bge0
/// -rw-r--r--  1 root  wheel  36 Nov 25 07:00 hosts
/// -rw-r--r--  1 root  wheel  15 Nov 25 07:00 mygate
/// -rw-r--r--  1 root  wheel  21 Nov 25 07:00 myname
/// -rw-r--r--  1 root  wheel  56 Nov 25 07:00 resolv.conf
/// fugu-demo# ls -l /etc/ | grep netconfs
/// lrwxr-xr-x  1 root  wheel	  28 Nov 25 06:56 myname -> /etc/fuguita/netconfs/default/myname
/// drwxr-xr-x  6 root  wheel	 192 Nov 25 06:59 netconfs
///これらの設定を実際に反映させるには、chnetconfユティリティを使用します。~
///chnetconfを実行すると、指定された設定ファイルを、/etcにコピーした後、「sh /etc/netstart」を部的に実行し、ネットワークの設定を変更します。
///>''【メモ】'' ~
///''⇒''設定ファイルのうち、mynameファイルだけはコピーではなくシンボリックリンクになります。これは/etcのネットワーク設定が、/etc/fuguita/netconfs内のどの設定を使用しているか、を示すためです。
///
/// fugu-demo# chnetconf -l    ← 現在の設定を表示
/// *default                   ← この設定が有効
///  office
/// fugu-demo# chnetconf office
/// fuguita# chnetconf -l
///  default
/// *office    ← この設定に変更された
/// fuguita# ifconfig    ← インターフェース設定を確認
/// bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
/// 	lladdr 10:9a:dd:6c:11:0c
/// 	index 1 priority 0 llprio 3
/// 	groups: egress
/// 	media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
/// 	status: active
/// 	inet 192.168.20.115 netmask 0xffffff00 broadcast 192.168.20.255
/// urtwn0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
/// 	lladdr 00:22:cf:46:6d:e6
/// 	index 4 priority 4 llprio 3
/// 	groups: wlan
/// 	media: IEEE802.11 autoselect (OFDM54 mode 11g)
/// 	status: no network
/// 	ieee80211: nwid ""
/// # ping www.google.com    ← 疎通を確認
/// PING www.google.com (172.217.175.68): 56 data bytes
/// 64 bytes from 172.217.175.68: icmp_seq=0 ttl=115 time=28.318 ms
/// 64 bytes from 172.217.175.68: icmp_seq=1 ttl=115 time=25.842 ms
/// 64 bytes from 172.217.175.68: icmp_seq=2 ttl=115 time=26.137 ms
/// ^C
/// --- www.google.com ping statistics ---
/// 3 packets transmitted, 3 packets received, 0.0% packet loss
/// round-trip min/avg/max/std-dev = 25.842/26.765/28.318/1.104 ms
///引続き、同様に設定「home」を作成してみます。こちらはWi-Fi接続でIPv6はSLAAC、IPv4はDHCPという手順を使用してアドレスの自動設定を行えることを想定しています。
/// fuguita# gennetconfs home
/// ===================================================
/// = gennetconfs: generate network configuration files
/// ===================================================
/// 
/// Hostname with domain part (FQDN):
/// only host name without domain part is also OK.
/// -> fuguita.home.local
/// 
/// IP protocol version(s) to be enabled: 4, 6, 46, 64 or "none"
///   4: enable only IPv4
///   6: enable only IPv6
///   46: give priority to IPv4 name resolution
///   64: give priority to IPv6 name resolution
///   none: operate as standalone
/// [64] ->
/// 
/// Network Interfaces: Choose one
/// 
///   NIC	 type	   Name
/// -------- ----- ------------
///     bge0 ether Broadcom BCM57765
///   urtwn0 wifi  GW-USValue-EZ GW-USValue-EZ
/// [bge0] -> urtwn0
/// 
/// Wi-Fi settings:
///   SSID -> my-wifinet
///   WPA Key -> my-wpa-secret-key
/// 
/// IPv6 - address and routing:
///   Enter "auto" or "IPv6_address[/prefixlen] [default_gateway]"
///   "auto" is an automatic setting by SLAAC.
///   The "/prefixlen" part can be an integer between 0 and 128.
///   If there is no default gateway, set the second field to "none" or leave it blank.
/// [auto] ->
/// 
/// IPv4 - address and routing:
///   Enter "auto" or "IPv4_address[/mask] [default_gateway]"
///   "auto" is an automatic setting by DHCP.
///   The "/mask" part can be specified in either format, such as "/255.255.255.0" or "/24".
///   If there is no default gateway, set the second field to "none" or leave it blank.
/// [auto] ->
/// 
/// writing configured values to:
///   /etc/fuguita/netconfs/home/myname
///   /etc/fuguita/netconfs/home/hostname.urtwn0
///   /etc/fuguita/netconfs/home/resolv.conf
/// 
/// ======================================================
/// = end of gennetconfs:
/// = Use chnetconf utility to activate this configuration
/// ======================================================
/// fuguita# chnetconf -l
///  default
///  home
/// *office
/// fuguita# chnetconf home
/// fuguita# chnetconf -l
///  default
/// *home
///  office
/// fuguita# ifconfig
/// bge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
/// 	lladdr 10:9a:dd:6c:11:0c
/// 	index 1 priority 0 llprio 3
/// 	media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
/// 	status: active
/// urtwn0: flags=a48843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6TEMP,AUTOCONF6,AUTOCONF4> mtu 1500
/// 	lladdr 00:22:cf:46:6d:e6
/// 	index 4 priority 4 llprio 3
/// 	groups: wlan egress
/// 	media: IEEE802.11 autoselect (OFDM54 mode 11g)
/// 	status: active
/// 	ieee80211: nwid my-wpa-secret-key chan 10 bssid 1c:b1:7f:27:5c:de -62dBm wpakey wpaprotos wpa2
///        wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
/// 	inet6 fe80::222:cfff:fe46:6de6%urtwn0 prefixlen 64 scopeid 0x4
/// 	inet 192.168.10.113 netmask 0xffffff00 broadcast 192.168.10.255
/// 	inet6 2409:........:8d47 prefixlen 64 autoconf pltime 604795 vltime 2591995
/// 	inet6 2409:........:1974 prefixlen 64 autoconf temporary pltime 77241 vltime 172795
/// pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33136
/// 	index 5 priority 0 llprio 3
/// 	groups: pflog
///これで、従来のdefaultを含め、3つのネットワーク設定が作成されました。
///
///これらの設定はchnetconfユティリティを使用して、いつでも切り換えることができます。
///
///#aname(fwupdate_wifi)
///***ファームウェアのダウンロードが要なWi-Fiデバイスを使う
///このではgennetconfs、chnetconfコマンドの応用としてWi-Fiデバイスの導入方法について説明します。
///
///OpenBSDでは様なWi-Fiデバイスがサポートされていますが、中にはそのままでは使用できず、ファームウェアのダウンロードとインストールが必要なデバイスがあります。
///>''【メモ】''~
///''⇒''ファームウェアのダウンロードが要な事情については、OpenBSDのサイトに以下のような記述があります;~
///OpenBSD FAQ - Wireless Networking ~
///https://www.openbsd.org/faq/faq6.html#Wireless ~
///~
///In order to use some wireless cards, you will need to acquire firmware files with fw_update. Some manufacturers refuse to allow free distribution of their firmware, so it can't be included with OpenBSD.~
///(訳) 一部のワイヤレスカードを使用するには、fw_updateでファームウェアファイルを取得する要があります。 メーカーによっては、ファームウェアの自由な配布を拒否しているため、OpenBSDに含めることはできません。
///
///このようなWi-Fiデバイスは、
///-まずファームウェア不要のデバイスで設定を行い、インターネットに接続
///-ファームウェアをダウンロードし、インストール
///-ネットワークの設定を目的のWi-Fiデバイス用に変更
///
///という手順で使用することができます。体的な手順は以下のとおりです。
///
///''1. ファームウェア不要のデバイスで設定を行い、インターネットに接続''~
///起動時に、以下のようにファームウェア不要のデバイスを用いてインターネットに接続できるように設定します。~
///ほとんどの有線LAN(イーサネット)デバイスや、あるいは一部のWiFiデバイスはファームウェアを要としません。
/// Network Interfaces: Choose one
/// 
///   NIC	 type	   Name
/// -------- ----- ------------
///     bge0 ether Broadcom BCM57766
///   urtwn0 wifi  GW-USValue-EZ GW-USValue-EZ
/// [bge0] -> bge0
///''2. ファームウェアをダウンロードし、インストール''~
///rootでログインし、[[fw_update>man:fw_update]]コマンドを実行。ファームウェアのダウンロードとインストールを行います。
/// fugu-demo# fw_update -v
/// Path to firmware: http://firmware.openbsd.org/firmware/7.0/
/// Installing: inteldrm-firmware intel-firmware urtwn-firmware
/// inteldrm-firmware-20201218:100%|OK
/// intel-firmware-20210608v0:100%|OK
/// urtwn-firmware-20180103p0:100%|OK
/// fugu-demo# 
///>''【メモ】'' ~
///''⇒''fw_updateは、起動時に自動的に実行されていますが、念の為、手動でもう一度実行しています。
///
///''3. 接続設定を使いたいWi-Fiデバイスに変更''~
///ファームウェアがインストールされたら、接続設定をWi-Fiデバイスに変更し、動作を確認します。
/// fugu-demo# gennetconfs wifi  ← 設定ファイルを生成
/// ===================================================
/// = gennetconfs: generate network configuration files
/// ===================================================
/// ~略~
/// Network Interfaces: Choose one
/// 
///   NIC	 type	   Name
/// -------- ----- ------------
///     bge0 ether Broadcom BCM57766
///   urtwn0 wifi  GW-USValue-EZ GW-USValue-EZ
/// [bge0] -> urtwn0                ← Wi-Fiデバイスを選択
/// 
/// Wi-Fi settings:
///   SSID -> my-wifinet            ← Wi-FiのSSIDと
///   WPA Key -> my-wpa-secret-key  ← パスワードを/// ~略~
/// ======================================================
/// = end of gennetconfs:
/// = Use chnetconf utility to activate this configuration
/// ======================================================
/// fugu-demo# chnetconf wifi       ← ネットワークを今行った設定に変更
/// fugu-demo# ping www.google.com  ← 接続を確認
/// PING www.google.com (216.58.220.100): 56 data bytes
/// 64 bytes from 216.58.220.100: icmp_seq=0 ttl=114 time=33.656 ms
/// 64 bytes from 216.58.220.100: icmp_seq=1 ttl=114 time=28.933 ms
/// 64 bytes from 216.58.220.100: icmp_seq=2 ttl=114 time=26.193 ms
/// 64 bytes from 216.58.220.100: icmp_seq=3 ttl=114 time=21.949 ms
/// ^C
/// --- www.google.com ping statistics ---
/// 4 packets transmitted, 4 packets received, 0.0% packet loss
/// round-trip min/avg/max/std-dev = 21.949/27.683/33.656/4.253 ms
///以上でWi-Fiのファームウェアのインストール完了です。
///最後に変更した容を[[usbfadmコマンドを使用して保存>fg2:usbfadm_sync]]します。この設定を指定し[[モード3で再起動>fg2:boot_mode3]]すれば、この設定を継続して使用できます。
/// # usbfadm -r
/// 
/// ========================================
/// = Sync current mfs as fugu-demo into /dev/sd1d
/// =
///     :
///     :
///
///*LiveUSBの管理 [#odbf7aa3]
///#aname(liveusb_remaster)
///**LiveUSBのリマスタリング [#fa481880]
///この節ではすでに稼動中のFuguItaを使い、新たに別のUSBメモリでFuguItaLiveUSBを作成する方法を説明します。~
///この方法を用いるとスワップパーティション、データの保存領域、他OSとのデータ交換用のFATパーティションなどをそれぞれサイズを指定して割り当てることができます。
///また、データ保存領域の暗号化も指定できます。~
///以下の例では、8GB(実際には7788MB)のサイズのUSBメモリにインストールする場合を想定しています。
///
///まず、FuguItaをモード0、またはモード1で起動します。起動するFuguItaはLiveDVD版、LiveUSB版のどちらでも使用できます。
///
///起動が完了したら、root権限でusbfadmコマンドを実行します。
/// fugu-demo$ doas usbfadm
/// doas (yoshi@fugu-demo.localnet) password:
/// 
/// Welcome to usbfadm.
/// USB flash drive administration tool for FuguIta
/// 
///  Version/Arch: 7.1/amd64  (FuguIta-7.1-amd64-202208121)
///     Boot mode: manual
/// Target device: not set
/// Data saved as: not set
/// 
/// Sorry, readline capability unavailable
/// 
/// Type ? for help.
/// 
/// ? : ? ->newdrive    ← LiveUSB作成を指示
/// 
/// Please make sure the device inserted.
/// Then press ENTER ->    ← USBメモリの着を確認したら <Enter>
///            認識したディスクデバイスの一覧が時系列で表示される
///                ↓
/// ==== disk(s) and vnode devices	============================
/// sd0 at scsibus1 targ 0 lun 0: <ATA, Hitachi HTS6457, JF40>
/// sd0: 2048MB, 512 bytes/sector, 4194304 sectors
/// sd1 at scsibus2 targ 0 lun 0: <UFD 3.0, Silicon-Power32G, 1.00 >
/// sd1: 65536MB, 512 bytes/sector, 134217728 sectors
/// sd2 at scsibus3 targ 0 lun 0: <BUFFALO, USB Flash Disk, 4000>
/// sd2: 7788MB, 512 bytes/sector, 15949824 sectors
/// vnd0: not in use
/// vnd1: not in use
/// vnd2: not in use
/// vnd3: not in use
/// vnd4: not in use
/// vnd5: covering /sysmedia/fuguita-7.1-amd64.ffsimg on sd0a, inode 9
/// ============================================================
/// Enter the name of device which FuguIta will be installed->sd2    ← LiveUSBを作成する
///                                                                     デバイスを指定
/// Disk: sd2	geometry: 992/255/63 [15949824 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 boot method:
///   1:  Legacy BIOS
///   2: [UEFI]
///   3:  none (only for save data)
///   4:  Hybrid
/// ->    ← 起動方法を指定。このようにEnterのみ力すると [ ] で囲まれた
///          デフォルト目(この場合はUEFI)を指定したことになる。
/// 
/// Select partition type:
///   1: [MBR]
///   2:  GPT
/// ->    ← パーティション形式の指定
/// 
/// Enter sizes for swap, user data and extra FAT.
///   You can add suffix K, M, G or T (otherwise considered 'bytes').
///   '*' implies 'all'
///   '0' doesn't make this partition.
/// 
/// 6GB (6754MB) (13833152sectors) free
/// swap->0    ← スワップパーティションのサイズ指定。
///               0の場合はスワップパーティションを作成しない。
/// 
/// 6GB (6754MB) (13833152sectors) free
/// user data [*] -> 3g    ← データ保存用パーティションのサイズ。
///                         「3g」で3ギガバイトを割り当て
///                         「*」と力すると、残り全てを割り当てる。
/// 
/// user data encryption? [y/N] ->    ← データ保存用パーティションを
///                                      暗号化するか(別節を参)。
/// 
/// Create an extra FAT partition? [y/n] -> y    ← 残りの領域をFATに
///                                                 するかどうか
/// target disk: sd2
///   partition type=MBR
///        boot type=UEFI
/// 
/// -------------------- : ------
/// 	   partition :	 size
/// -------------------- : ------
/// 	  whole disk :	  7GB
///     partition tables :	 32KB
/// 	 UEFI system :	512KB
///       FuguIta system :	  1GB
/// 	FuguIta swap :	   0B
///    FuguIta user data :	  3GB
/// 	   MSDOS FAT :	  3GB
/// -------------------- : ------
/// 
/// ***THIS IS THE LAST CHANCE***
/// If you type 'Y' now, all the data on sd2 will be lost.
/// Are you sure to modify disk sd2? [y/N] -> y    ← 指定したUSBメモリに書き込むかどうかの
///                                                   最終確認
/// ========================================
/// = Clearing MBR, GPT and BSD disklabel
/// =
/// 1+0 records in
/// 1+0 records out
/// 1048576 bytes transferred in 0.005 secs (188870677 bytes/sec)
/// 
/// ========================================
/// = Setting up fdisk partitions
/// =
///   ~~省略~~
/// ** /dev/rsd2d
/// ** File system is already clean
/// ** Last Mounted on /mnt
/// ** Phase 1 - Check Blocks and Sizes
/// ** Phase 2 - Check Pathnames
/// ** Phase 3 - Check Connectivity
/// ** Phase 4 - Check Reference Counts
/// ** Phase 5 - Check Cyl groups
/// 5 files, 5 used, 1520722 free (18 frags, 190088 blocks, 0.0% fragmentation)
/// 
/// ? : ? ->quit
/// 
/// Bye bye...
/// fugu-demo$
///
///以上で、指定したデバイスにFuguItaのシステムが書き込まれ、使用可能となります。
///
///>&color(red){''【ご注意】''&br;''!!''書き込みのデバイス名は十分にご確認下さい。誤ったデバイスに書き込むと、そこに保存されているデータが失われます。};
///
///#ref(FuguItaガイド/fuguita-usb.png,around,right);
///今まで説明した容を図にすると、右のようになります。
///
///「Select boot method:」に対し「Legacy BIOS」あるいは「UEFI」を選択した場合は a パーティションが作成され、そこにFuguItaのシステムが書き込まれます。「none」を力した場合は a パーティションは作成されません。この場合はデータ保存専用のUSBメモリとなります。
///
///「Enter size for saving User Data」で力したサイズの d パーティションが作成され、usbfadm のデータ保存先となります。
///
///''a''パーティションと''d''パーティションの領域を確保したあとでまだ未使用領域があれば、「Create an extra FAT partition? [y/n] ->」と訊かれます。これに対し''y''と答えると''i''または''j''パーティションが確保されます。このパーティションはFATファイルシステムとしてフォーマットされ、Windowsなど他のOSからもアクセスできます。OpenBSDもFATをマウントできますから、FuguItaと他OSとのデータのやりとりに使用することもできます。
///#clear
///
///>''【メモ】''~
///''⇒''この節で説明したFuguItaのインストール方法は、USBメモリだけではなくOpenBSDが認識できる記録デバイス般に対して使用可能です。例えばSDカード、コンパクトフラッシュ、メモリスティックあるいはATAやSATAのハードディスクなどにも書き込むことが可能です。
///
///>''【メモ】''~
///''⇒''現在のPCは、起動方法として「BIOS」と「UEFI」の2種類があります。いままで説明してきたUSBメモリの作成方法は、BIOSでの起動に対応したものです。
///UEFI起動に対応したUSBメモリを作成するには、以下のように起動方法として「UEFI」を指定します。
/// Select boot method:
///   1:  Legacy BIOS
///   2: [UEFI]
///   3:  none (only for save data)
///   4:  Hybrid
/// ->2
///さらにパーティション形式として「MBR」を指定すると、Legacy BIOSのブートローダも書き込まれ、BIOS、UEFIのどちらでも起動が可能となります。
/// Select partition type:
///   1:  GPT
///   2: [MBR]
/// ->
///なお、起動方法「Hybrid」を指定しても、BIOS、UEFIのどちらでも起動できるUSBメモリを作成することができます。~
///だたし、「Hybrid」は規格に準拠していない作成方法です。加えて、作成後にfdiskコマンドでパーティションを変更すると不合が発生しますのでご注意下さい(Hybrid形式は、過去のリリースとの互換性のために残されています)。~
///#ref(FuguItaガイド/fuguita-usb-uefi.png,around,left);
///UEFI起動に対応したFuguItaLiveUSBのパーティション構成は左図のようになります。
///#clear
///
///#aname(autorun)
///**起動時の設定力を自動化する
///FuguItaでは起動途中で以下の設定を行う要があります:
///-どのデバイスを使用して運用を行うか? (Which is FuguIta's operating device?)
///-実メモリのどれくらいをmfsに割り当てるか? (Enter mfs size in MB.)
///-どの起動モードを使用するか? (Boot modes)
///-どの保存デバイスからファイルを復帰させるか?(モード3のみ) (Which is FuguIta's storage device?)
///-どの保存名からファイルを復帰させるか?(モード3のみ) (config name ->)
///
///上記の5目については入力を自動化する機能があります。~
///それには、LiveUSB版FuguItaの''d''パーティションにあるnoasksというファイルに設定値を書き込みます。
/// $ doas -s 
/// doas (yoshi@fugu-demo.localnet) password: 
/// # mount /dev/sd0d /mnt
/// # cd /mnt
/// # ls -l
/// total 4
/// drwxr-xr-x  5 root  wheel  512 Oct 23 19:29 livecd-config
/// # cd livecd-config/7.0/amd64                                           
/// # ls -l
/// drwxr-xr-x  11 root  wheel  512 Nov 10 17:08 fugu-demo
/// -rw-r--r--   1 root  wheel  422 Nov  9 22:19 noasks
///>''【メモ】''~
///''⇒''ディレクトリlivecd-configは、usbfadmによるデータ保存用のディレクトリです。
///
///noasksには、設定値の雛形がコメントの形で書かれていますので、テキストエディタで設定行のコメントを外し、設定したい値を書き込みます。
/// # vi noasks
///
/// #
/// # noasks - parameter settings for non-interactive boot
/// #
/// # Make statements uncommented
/// # Then assign real values
/// #
/// #
/// # FuguIta system device
/// #   - Use one of two lines                     FuguItaのシステムデバイス
/// #noask_rdev=sd2a  # device name format         通常のデバイス名、あるいは
/// #noask_rdev=f24c0ae78bb7e0e4.a  # DUID format  DUIDフォーマットのどちらかを指定して
/// #                                              コメントをはずします。
/// # mfs size in MB
/// #noask_umem=75%  実メモリからMFSに割り当てる量を指定します。(数字のみはメガバイト
/// #                単位、%は実メモリ、%%は実装メモリ+スワップに対する割合です)
/// #               
/// # boot mode
/// #noask_setup_rw_mode=3  自動で起動するモード
/// #
/// # storage device
/// #   - Use one of two lines                        ファイルを保存するデバイス
/// #noask_confdev=sd2d  # device name format         通常のデバイス名、あるいは
/// #noask_confdev=f24c0ae78bb7e0e4.d  # DUID format  DUIDフォーマットのどちらかを指定して
/// #                                                 コメントをはずします。
/// # data set name in USB flash drive
/// #noask_confdir=fugu-demo
///>''【メモ】''~
///''⇒''設定値の代文で、「=」の前後にはスペースを入れないようにして下さい(noasksファイルはシェルスクリプトとして解釈されます)。
///
///編集が終了したら''d''パーティションをアンマウントしてシステムを再起動します。
/// # cd
/// # umount /mnt
/// # /sbin/shutdown -r now
///#aname(noasks-intr)
///noasksファイルによる値の設定がされている場合、次のようなメッセージが表示されます;
/// ============================================
/// =     ______               __   _
/// =    / ____/              |  |_| |__
/// =   / /____  ______  __  _|  /_   _/_____
/// =  / ___/ / / / __ \/ / / |  | | | /  _  |
/// = / /  / /_/ / /_/ / /_/ /|  | | |_| (_) |__
/// =/_/   \____/\__  /\____/ |__| \___/____/__/
/// =            __/ /
/// =           /___/
/// =
/// = Welcome to FuguIta!  -  OpenBSD Live System
/// =                 http://fuguita.org/?FuguIta
/// =============================================
/// scanning partitions: wd0i wd0j sd0a sd0d
/// FuguIta's operating device(s): sd0a.
/// Press ^C to cancel non-interactive boot
///この「Press ^C to cancel non-interactive boot」が表示されてから5秒つと自動起動が実施されます。~
///5秒以に''<Control>-C''を入力するとnoasksファイルによる自動起動は中止され、通常の動作に戻ります。
///
///>''【メモ】''~
///''⇒''noasksファイルの中に未設定の目がある場合は、自動起動中にその項目設定の箇所でユーザからの入力を待ちます。
///
///>''【メモ】''~
///''⇒''設定目のうち、noask_rdevとnoask_confdevについてはsd0aといったような通常のデバイス名の他、DUID (Disklabel Unique IDentifiers) による指定も可能です。DUIDはディスクデバイスに自動的に付けられるランダムで固有な16進文字列です。~
///DUIDは、disklabelコマンドの出力から確認できます。
/// # disklabel sd0
/// # /dev/rsd0c:
/// type: ESDI
/// disk: ESDI/IDE disk
/// label: QEMU HARDDISK   
/// duid: eac6323f6d34c465  ←DUID
/// flags:
/// ~略~
///例えば、FuguItaの起動デバイスをnoasksファイル中で指定する場合、
/// noask_confdev=sd0d
///と書く替わりに、
/// noask_confdev=eac6323f6d34c465.d
///というように「DUID.パーティション」というように指定することもできます。~
///通常のデバイス名による指定は、ディスクデバイスの接続状況が変わるとsd0がsd1などに変わり、自動起動に失敗するおそれがありますが、DUIDによる指定ではデバイスの接続状況に関係なく常に同じディスクを指定することができます。
///
///#aname(autosave)
///**終了時にデータが自動で保存されるようにする [#kf5ead2c]
///前節の [[起動時の設定力を省略できるようにする>#autorun]] ではFuguIta起動時の自動化について説明しましたが、終了時に自動でデータを保存することもできます。
///
///OpenBSDではシステム終了時に /etc/rc.shutdown というスクリプトを実行するようになっています。~
///FuguItaでは、/etc/rc.shutdownにデータ保存の処理が記述されています。
/// force_umount=No  # set Yes for forced umount /ram at shutdown
/// force_resync=No  # set Yes to re-sync at shutdown
/// ~ 略 ~
///ファイル2行目のforce_resyncの設定値を「No」から「Yes」に変更することで、終了時にデータ保存が行われるようになります。
///
///>''【メモ】''~
///''⇒''この処理では保存処理が繰返し失敗した場合、シェルが立ち上がります。このシェルを用いて失敗の原因を取り除き、手動でusbfadm -rを実行して下さい。&br;シェルから抜けると保存処理が再実行されます。
///>&color(red){''【ご注意】''&br;''!!''運用中に重要な処理を行った場合は、シャットダウン前に別途、手動でデータを保存しておくことをお勧めします。};
///
///#aname(encrypt)
///**データの保存領域を暗号化する [#g0ced005]
///基本編の[[設定やファイルを保存する>fg2:usbfadm_sync]]で説明したとおり、FuguItaのUSBメモリにはデータの保存用パーティションがあります。
///
///保存領域を暗号化する機能を使うと、USBメモリに保存した報を盗難や紛失などのアクシデントから保護することができます。
///
///[[usbfadmコマンドでLiveUSBを作成する>#liveusb_remaster]]時には、usbfadmコマンドのnewdrive機能を使用しますが、
///以下のように指定を行うと、暗号化パーティションを作成することができます。
/// # usbfadm
/// 
/// Welcome to usbfadm.
/// USB flash drive administration tool for FuguIta
/// 
///   Version/Arch: 6.7/amd64  (FuguIta-6.7-amd64-202006142)
///      Boot mode: manual
/// Data stored in: not set
///  Data Saved as: not set
/// 
/// Type ? for help.
/// 
/// ? : ? ->newdrive
/// ~~ 略 ~~ 
/// Enter sizes for swap, user data and extra FAT.
///   You can add suffix K, M, G or T (otherwise considered 'bytes').
///   '*' implies 'all'
///   '0' doesn't make this partition.
/// 
/// 589MB (604128KB) (1208256sectors) free
/// swap->64m
/// 
/// 
/// 525MB (538592KB) (1077184sectors) free
/// userrdata->*
/// 
/// user data encryption? [y/N] -> y       ← 「y」を力しデータ保存領域の暗号化を指定
/// 
/// Enter passphrase twice. They'll be not echoed.
/// 
/// //// CAUTION ////////////////////////////
/// ////   If you lost this passphrase,    ← パスフレーズを失念すると、保存したデータを
/// ////   you'll never access sd0d.       ← 取り出す方法はありません。ご注意下さい。
/// /////////////////////////////////////////
/// 
/// Passphrase:           ← 暗号化のパスフレーズを力します(入力内容は表示されません)。
/// Passphrase:           ← 確認のため、再度パスフレーズを力します
/// ~~ 続く ~~ 
///暗号化されたパーティションにデータを保存するには以下のように、2段階の手順を踏みます。
///+usbfadmのtarget機能で暗号化されているパーティションを指定し、パスフレーズを力します。~
///~
///+パスフレーズの力が正しいと新たにディスクが現れるので、再度target機能を呼出し、このディスクを指定します。
///-usbfadmのsync機能でデータの保存を実行します。
/// ? : ? ->target
/// 
/// Searching storage device
/// Please make sure the device inserted.
/// Then press ENTER ->
/// sd0a ?sd0d                             ← 「?」の付いているものが暗号化された
///                                           パーティションです(このままでは読めません)。
/// target device->sd0d                    ← このパーティションを指定して、
/// Passphrase:                            ← パスフレーズを力します。
/// sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006>
/// sd1: 525MB, 512 bytes/sector, 1076656 sectors
/// softraid0: CRYPTO volume attached as sd1
/// sd0a ?sd0d +sd1d                       ← パスフレーズが正しいと新しいディスク
///                                           sd1dが現れます。
/// target device->sd1d                    ← sd1dを保存に指定し、
///                                           以下、通常の手順で保存を実行します。
///  sd1d : ? ->saveas
/// Name of avedd ata->fugu-demo
/// 
/// Your data will be saved as ``fugu-demo''.
/// 
/// sd1d : fugu-demo ->sync
/// 
/// Sync current mfs as ``fugu-demo'' , OK? [y/N] -> y
/// 
/// copying /ram to /mnt/livecd-config/6.7/amd64/fugu-demo (30688KB approx.):
/// 25.0MiB 0:00:38 [9673KiB/s][[===========================>      ] 83% ETA 0:00:07
/// waiting for pax to finish ... syncing ... done.
/// 
/// sd1d : fugu-demo ->bye
///
///保存されたデータを以降の起動時に読み込む時も保存の場合と同様、2段階の手順を踏みます。
///+起動モード3を指定し、暗号化されているパーティションを指定し、パスフレーズを力します。~
///~
///+パスフレーズの力が正しいと新たにディスクが現れるので、再度モード3を呼出し、そのディスクを指定します。
/// ============================================
/// =     ______               __   _
/// =    / ____/              |  |_| |__
/// =   / /____  ______  __  _|  /_   _/_____
/// =  / ___/ / / / __ \/ / / |  | | | /  _  |
/// = / /  / /_/ / /_/ / /_/ /|  | | |_| (_) |__
/// =/_/   \____/\__  /\____/ |__| \___/____/__/
/// =            __/ /
/// =           /___/
/// =
/// =  Welcome to FuguIta  -  OpenBSD Live System
/// =                         http://fuguita.org/
/// =============================================
/// 
/// scanning partitions: sd0a sd0b sd0d cd0a
/// FuguIta's operating device(s): sd0a cd0a.
/// Which is FuguIta's operating device? -> sd0a
/// activating swap partition: /dev/sd0b
///   user memory: 239 MB
/// Enter mfs size in MB. (0MB is auto)
/// [default: 0MB] ->
/// mfs size will be automatically allocated
/// Boot modes:
///   0: fresh boot - standard mode as a live system
///   1: fresh boot - less memory, faster boot (/usr is non-writable, can't pkg_add)
///   2: fresh boot - works using only RAM (about 1GB or more of RAM required)
///   3: boot with retrieving saved files from storage device
///      or enter passphrase for an encrypted volume
///   4: boot with retrieving saved files from floppy disk
///   5: interactive shell for debugging
/// ->3                                    ← 起動モード3を選択
/// scanning partitions: sd0a sd0b sd0d cd0a
/// Device(s) found:
///       encrypted: sd0d    ← This is the encrypted volume.
/// Which is FuguIta's storage device? -> sd0d
/// Passphrase:                            ← パスフレーズを///  ↓ パスフレーズが正しいと、新たにディスクが現れます。
/// sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006>
/// sd1: 525MB, 512 bytes/sector, 1076656 sectors
/// softraid0: CRYPTO volume attached as sd1
/// Passphrase successful: Select boot mode again...
/// Boot modes:
///   0: fresh boot - standard mode as a live system
///   1: fresh boot - less memory, faster boot (/usr is non-writable, can't pkg_add)
///   2: fresh boot - works using only RAM (about 1GB or more of RAM required)
///   3: boot with retrieving saved files from storage device
///      or enter passphrase for an encrypted volume
///   4: boot with retrieving saved files from floppy disk
///   5: interactive shell for debugging
/// ->3                                    ← 再度起動モード3を指定します。
/// scanning partitions: sd0a sd0b sd0d cd0a sd1d
/// Device(s) found:
///   loadable from: sd1d                  ← 新たに現れたディスクから読み込めます。
///       encrypted: sd0d
/// Which is FuguIta's storage device? [default: sd1d] -> sd1d  ← 指定して読み込み
/// /dev/sd1d : available data;
/// 
/// fugu-demo
/// 
/// config name -> fugu-demo
/// Copying files from flash to ram ...
/// done
/// ~~ 続く ~~ 
///
///このディスクは起動完了後も見えているので、データを保存する時に改めてパスフレーズを力する必要はありません。
///
///**スワップパーティションを有効にする [#k1f4b248]
///通常、FuguItaはスワップを使用せずメインメモリだけで動作しますが、[[ノーマルなOpenBSDとFuguItaが存している>#coexist_obsd]] ような環境では、OpenBSDのスワップパーティションを検出し、さらにそれを有効化します。
/// Which is FuguIta's operating device? -> wd0a
/// activating swap partition: /dev/wd0b
/// activating swap partition: /dev/wd1b
///この例では、/dev/wd0b と /dev/wd1b の2つのスワップパーティションが見つかり、両方とも有効になっています。~
///スワップパーティションは検出と同時に有効化されます。これを無効/有効にする設定はありません。
///>''【メモ】''~
///''⇒''何らかの理由でスワップを使用したくない場合(例えば、スワップパーティションにバッドセクタが存在するためプロセスが異常終了するおそれがある、ディスク上にメモリイメージを残したくない、など)場合は、起動モード5「interactive shell for debugging」を選択します。~
///選択後、シェルが立ち上がったら[[swapctl>man:swapctl.8]]コマンドを-dオプション付きで実行し、スワップを無効化します。~
///シェルを抜けると再度起動モードの選択になりますので本来の起動モードを選択し、処理を再開します。
///
///#aname(fstab_tail)
///**マウントするパーティションを追加する [#ta1cb743]
///通常Unix系のOSでは、/etc/fstabというファイルでマウントするパーティションを指定します。~
///そのため、ユーザがマウントするパーティションを追加や変更したい場合は、fstabの記述容を変更します。
///
///ところがFuguItaでは、fstabファイルの容を変更し再起動してもその内容はファイルシステムのマウント状況に反映させません。
///
///FuguItaでは起動時の初期化中、PCに接続されているてのディスクデバイスが調査され、システムパーティションの検出などが行われます。また、必要に応じてユーザからの指定も受け取ります。~
///最後に、その結果を受けてfstabが自動的に生成され、それを基にファイルシステムのマウントが行われます。~
///そのため、ユーザがfstabを変更し保存を行っても、その容は次回起動時に上書きされてしまいます。
///
///マウントするパーティションを追加したい場合は、/etc/fuguita/fstab.tailというファイルにその容を記述します。~
///例として、sd2というディスクのeパーティションを/ram/optというディレクトリに追加でマウントしたい場合、以下のような手順になります。
///
///- /etc/fuguita/fstab.tail を作成します。このファイルの書式は/etc/fstabと同じです。
/// /dev/sd2e /ram/opt ffs rw 0 1
///
///- /ram/optディレクトリがない場合、あらかじめ作成しておきます。
/// # mkdir /ram/opt
///
///- usbfadmコマンドのsync機能を使い、ファイルを保存します。
///
///- システムを最起動し起動モード3で起ち上げ、指定したパーティションがマウントされていることを確認します。
///
////etc/fuguita/fstab.tailファイルの容は自動生成された/etc/fstabファイルの末尾に追加され、その後ファイルシステムのマウントが行われるようになっています。
///
///>''【メモ】''~
///''⇒''マウントポイントはmfs(/ramディレクトリより下)に作成する必要があります。~
///''⇒''/ramディレクトリ直下のディレクトリやファイルは、起動時にルートディレクトリから自動的にシンボリックリンクが張られます。従って、/ram/optは/optとしてアクセスすることができます。
///
///*その他 [#tae288e6]
///#aname(multidevice)
///**複数のFuguItaを併用する [#sfee92b8]
///いままではほとんどの場面で、LiveDVD版かLiveUSB版のFuguItaのどちらか一方を使う想定で説明を行ってきましたが、もしPCにLiveDVDとLiveUSBの両方を着して起動したらどうなるでしょうか? あるいは、LiveUSBを2つ作って、それを二つとも装着して起動したら?
///
///FuguItaはそのような場合にもうまく動作するように設計されています。
///
///LiveDVDとLiveUSBの両方を着して起動した場合について説明します。
///
///まず、電源をれた直後にDVDとUSBのどちらが起動するかですが、これは [[起動時の設定>fg1:bootdevice]] で説明したようにPCのBIOSメニューの設定によります。
///
///次に、運用デバイス(ディレクトリ /fuguita にマウントされ、OSとして使用されるデバイス)ですが、FuguItaのシステムが書き込まれたデバイスが2つ以上検出された場合は、
/// scanning partitions: wd0i wd0j cd0a sd0a sd0d
/// FuguIta's operating device(s): cd0a sd0a.
/// Which is FuguIta's operating device? ->
///のように使用可能なデバイスを列挙し、どれを使用するかユーザに尋ねるようになっています。
///>''【メモ】''~
///''⇒''上の例ではwd0iとwd0jは蔵ハードディスクという想定です。内蔵ハーディスクにはWindowsがインストールされていて、CドライブとDドライブの2つのパーティションが存在しているような場合、このような表示になります。
///
///保存されたデータを読み込む場合も同様に候補が複数ある場合はどれを使うかユーザに尋ねます。例えばLiveUSBが2本挿された状で起動モード3を選択した場合、以下のようにsd0d、sd1dの2つの候補が表示されます;
/// Boot modes:
///   0: fresh boot - standard mode as a live system
///   1: fresh boot - less memory, faster boot (/usr is non-writable, can't pkg_add)
///   2: fresh boot - works using only RAM (about 1GB or more of RAM required)
///   3: boot with retrieving saved files from storage device
///      or enter passphrase for an encrypted volume
///   4: boot with retrieving saved files from floppy disk
///   5: interactive shell for debugging
/// ->3
/// scanning partitions: wd0i wd0j sd0a sd0d sd1a sd1d
/// Device(s) found:
///   loadable from: sd0d sd1d
/// Which is FuguIta's storage device?  -> 
///usbfadmコマンドでデータを保存する場合も、[[設定やファイルを保存する>fg2:usbfadm_sync]] で説明したように、usbfadmのtargetコマンドを使用して保存のデバイスを指定できます。
///
///以上のことを応用すると、以下に挙げるような運用が可能となります。
///
///:SDカード版のFuguItaで運用|[[USBメモリの容量に合わせてLiveUSBを作成する>#liveusb_remaster]]で説明したように、usbfadmコマンドでは、USBメモリ以外の記憶デバイスにもFuguItaをインストールできます。~
///SDカードからの起動をサポートしているPCはほとんど存在しませんが、LiveDVD版とSDカード版のFuguItaの2つを着してPCを起動すると、システムの起動をLiveDVDで行い、運用デバイスをSDカードとすることで、SDカード版FuguItaによる運用が可能となります。
///
///:LiveDVD版FuguItaをモード3で起動|LiveDVD版FuguIta単体では、データの保存・復帰はできませんが、LiveUSBなどと併用することでDVDで運用しながら、データを保存して終了し、次回起動時に復帰するといった使い方ができます。
///>''【メモ】''~
///''⇒''USBメモリはデータの保存時/復帰時にのみマウントされるので、それ以外の時ははずしておけます。
///
///この、FuguItaの「起動と運用は別のデバイスで行える」という特徴をさらに活かし、[[OpenBSDとFuguItaを共存させる>#coexist_obsd]] ことや [[WindowsやLinuxとFuguItaを共存させる>#coexist_other]] ことも可能になっています。これらについては次節以降で紹介します。
///>''【メモ】''~
///''⇒''なお、[[起動時の設定力を省略できるようにする>#autorun]] で説明した設定入力の自動化は、全パーティション中に noasks ファイルが1つしかない場合に実行されます。2つ以上の noasks ファイルが検出された場合は安全のため自動実行は中止され、手動入力に移行します。
///
///#aname(coexist_obsd)
///**OpenBSDとFuguItaを存させる
///FuguItaを実行しようとしているPCにすでにOpenBSDがインストールされている場合、そのインストール済みのOpenBSDにFuguItaのファイルを置くことでLiveDVDやLiveUSBを装着していなくてもFuguItaを起動することができます。
///
///原理としては、既存のOpenBSDパーティションにFuguItaのカーネルとISOイメージを置き、既存のブートローダを利用してFuguItaのカーネルを起動する、という方法になります。
///
///以下、設置と起動の方法を説明します。~
///まず既存のOpenBSDを起動し、rootでログインします。
///
///次に、ルートディレクトリ直下に「ISO」というディレクトリを作成します。~
///この /ISO ディレクトリにFuguItaのサイトからISOイメージをダウンロードし、展開します。
/// # mkdir /ISO
/// # cd /ISO
/// # ftp http://mirror.ginzado.ne.jp/pub/FuguIta/FuguIta-6.0-amd64-201612251.iso.gz
/// Trying 110.92.1.251...
/// Requesting http://mirror.ginzado.ne.jp/pub/FuguIta/FuguIta-6.0-amd64-201612251.iso.gz
/// 100% |**************************************************|   322 MB    07:48
/// 
/// 338634465 bytes received in 468.48 seconds (705.90 KB/s)
/// # ls -l
/// total 661632
/// -rw-r--r--  1 root  wheel  338634465 Dec 29 00:55 FuguIta-6.0-amd64-201612251.iso.gz
/// # gunzip FuguIta-6.0-amd64-201612251.iso.gz
/// # ls -l
/// total 1427648
/// -rw-r--r--  1 root  wheel  730744832 Dec 29 00:55 FuguIta-6.0-amd64-201612251.iso
///ISOイメージの中に含まれているFuguItaのカーネルをルートディレクトリ直下にコピーします。
///[[vnconfig>man:vnconfig.8]]はISOやUSBメモリのイメージファイルを記憶デバイスとしてアクセスできるようにするコマンドです。
/// # vnconfig vnd0 FuguIta-6.0-amd64-201612251.iso
/// # vnconfig -l
/// vnd0: covering FuguIta-6.0-amd64-201612251.iso on wd0a, inode 25986
/// vnd1: not in use
/// vnd2: not in use
/// vnd3: not in use
/// # mount -r /dev/vnd0a /mnt
/// # ls -l /mnt
/// total 1427119
/// -r-xr-xr-x  1 root  bin        71452 Apr  4  2015 boot
/// -rwxr--r--  1 root  wheel       2048 Dec 27 11:59 boot.catalog
/// -rw-r--r--  1 root  wheel    5569179 Dec 27 19:19 bsd-fi
/// -rw-r--r--  1 root  wheel    5577796 Dec 27 19:19 bsd-fi.mp
/// -r-xr-xr-x  1 root  wheel      72328 Dec 27 19:19 cdboot
/// -r-xr-xr-x  1 root  wheel       2048 Dec 27 19:19 cdbr
/// drwxr-xr-x  2 root  wheel       2048 Apr 18  2014 etc
/// -rw-r--r--  1 root  wheel  719388672 Dec 27 19:19 fuguita-5.8.ffsimg
/// # cp -p /mnt/bsd-fi /mnt/bsd-fi.mp  /
/// # umount /mnt
/// # vnconfig -u vnd0
/// # vnconfig -l
/// vnd0: not in use
/// vnd1: not in use
/// vnd2: not in use
/// vnd3: not in use
/// #
///以上で設置作業は完了です。
///>''【メモ】''~
///''⇒''データの保存と復帰を行いたい場合は livecd-config というディレクトリを作成します。ただし、ISO ディレクトリと同じ場所には作れません。なぜなら、ISO ディレクトリが作成されたパーティションは、FuguIta稼動中は書込み不可でマウントされるからです。従って、livecd-config の作成に適切なパーティションは、例えば /home や /var など、別パーティションのマウントポイント直下ということになります。
///
///次に起動方法ですが、PCが起動し、カーネルメッセージが表示される直前に「boot>」というプロンプトが数秒間表示されます。~
///ここで何もしないと既設のOpenBSDシステムが起動しますが、起動したいカーネルを力すると、そのカーネルが立ち上がります。
/// boot> bsd-fi.mp
///この「bsd-fi.mp」がマルチプロセッサ用のFuguItaカーネルです。
///シングルプロセッサ用のFuguItaカーネルを起動したい場合は「bsd-fi」と力します。
///>''【メモ】''~
///''⇒''以上の説明では ISO ディレクトリと livecd-config ディレクトリはルートディレクトリ直下に作成しましたが、OpenBSDのファイルシステムが作成されているパーティションの直下であれば、ルートディレクトリ直下でなくとも動作します。
///
///#aname(coexist_other)
///**WindowsやLinuxとFuguItaを存させる
///FuguItaではWindowsのNTFSやFAT、LinuxのEXT-2, EXT-4ファイルシステムでフォーマットされたパーティションも運用デバイスとして用いることができます。~
///この方法は [[OpenBSDとFuguItaを存させる>#coexist_obsd]] で説明した手順とほぼ同様な方法です。つまり、
///-運用デバイスとして用いるOSを起動させ、
///
///-そのOS上のファイルシステム直下(WindowsならCドライブやDドライブ、Linuxならルートディレクトリやその他のマウントポイント)にISOというフォルダを作成し、
///
///-そのフォルダにFuguItaのISOイメージを置きます。
///
///だたし、WindowsやLinuxのファイルシステムからFuguItaを使用する場合は、以下のような制限があります。
///
///-現段階ではWindowsやLinuxのファイルシステムに置かれたOpenBSDのカーネルを起動することはできません。従って、カーネル起動用にのみLiveDVD版やLiveUSB版のFuguItaを使用することになります。
///
///-WindowsやLinuxのファイルシステムは、データの保存・復帰も対応していませんので、データの保存と復帰にはLiveUSB版のFuguItaを使用します。
///
#aname(update)
** Update FuguIta [#oa558bdd]
OpenBSD has a major release every six months, and at that time the version changes like OpenBSD 7.1 → OpenBSD 7.2. ~
And in half a year, fixes related to security and stability improvements have been made, and the fix information is provided on the official OpenBSD website at http://www.openbsd.org/errata72.html.

FuguIta also follows this modified information, and the currently published version has all the modified information applied so far (actually, application work and operation check Therefore, there is a time lag of several days after the correction information is released.)

In addition, to check the version of the OS currently in operation on FuguIta, execute the command as follows.
 fugu-demo$ uname -a                                       ← version of OS
 OpenBSD fugu-demo.localnet 5.8 RDROOT.MP#2 i386
 fugu-demo$ sysctl kern.version                            ← version of kernel
 kern.version=OpenBSD 5.8-stable (RDROOT.MP) #2: Wed Nov 11 13:18:48 JST 2015
     root@nimbus5.localnet:/opt/fi/5.8/sys/arch/i386/compile/RDROOT.MP
 
 fugu-demo$ cat /usr/fuguita/version                       ← version of FuguIta
 5.8-201512272
This section explains how to update your current version ofFuguIta to the latest version;

***When a major release of OpenBSD is upgraded [#z301780e]
This is when a major release of OpenBSD, on which FuguIta is based, is made. for example,

 Fuguita-5.8-amd64-201504161

 Fuguita-5.9-amd64-201510255

However, the OS that FuguIta is based on has changed from OpenBSD 5.8 to OpenBSD 5.9.

It is difficult to update the system if OpenBSD major release changes. ~
The reason is that when OpenBSD is upgraded, system call specifications are changed, shared libraries are not compatible with version upgrades, commands are added/deleted, and specifications are changed significantly. This is because it is not realistic to migrate versions while maintaining them.

To migrate across OpenBSD major releases, the following methods are recommended;

+Create a new LiveDVD or LiveUSB.
+Start the new version of FuguIta and migrate various settings and user-created files from the old version of FuguIta.

#aname(fiupdate)
***Unchanged OpenBSD major release [#t9677dff]
this is,
 Fuguita-6.0-amd64-201511297

 Fuguita-6.0-amd64-201512051
You can check that the "6.0" part, which indicates the OpenBSD version like, has not changed.

In this case, the system changes are only partial, so there is no need to migrate user data.
To migrate the system, follow the steps below.

''LiveDVD migration procedure''~
In the case of LiveDVD, partial rewriting of the media is not possible, so we will create a new version of LiveDVD version FuguIta and use it. ~
The data saved in the USB memory can be read and used as it is in startup mode 3.

#aname(fiupdate)
''LiveUSB migration procedure''~
For LiveUSB, you can update the active LiveUSB by using the command fiupdate (Fuguita
update).
To use fiupdate, boot the LiveUSB to be updated in mode 0, 1 or 2. ~
Then download the ISO image and SHA256 file of the new version from the distribution site, then launch fiupdate.
>''[Memo]''~
''⇒''Use LiveUSB for update is ISO image file. Please note that these are not *.img files. ~
''⇒''The SHA256 file is used by fiupdate to check that the contents of the downloaded file are not corrupted.
 fugu-demo# ls -l
 total 606752
 -rw-r--r--  1 root  wheel  310651490 Oct  7 01:12 FuguIta-6.7-amd64-202010071.iso.gz
 -rw-r--r--  1 root  wheel	 562 Oct  8 06:25 SHA256
 
 fugu-demo# cat /usr/fuguita/version
 6.7-amd64-20209041
 
 fugu-demo# fiupdate 202010071
 
 fiupdate - Live Updater for FuguIta LiveUSB
   Version/Arch: 6.7/amd64  (FuguIta-6.7-amd64-20209041)
 
 Checking...
      environment: ok
 
 Note: This software is currently in beta testing.
       Use this at YOUR OWN RISK.
 
       We recommend that you run this command in fresh boot (boot mode
       0, 1, or 2).
       Alternatively, you must quit all application software and save
       all your data before updating this FuguIta device.
 
       All daemons, including xenodm, will be stopped before the update.
       Please note that all X sessions will be aborted.
 
 Do you proceed? [y/N] -> y
 
 Checking...
 	checksum: (SHA256) FuguIta-6.7-amd64-202010071.iso.gz: OK
      file layout: liveusb
   existing files: ok
 
 decompressing FuguIta-6.7-amd64-202010071.iso.gz...
 9296MiB 0:00:31 [9.51MiB/s] [================================>] 100% ETA 0:00:00
 Now ready to update FuguIta-6.7-amd64-20209041 to FuguIta-6.7-amd64-202010071.
 
 This machine will reboot immediately after update completed.
 
 Do you proceed? [y/N] -> y
 
 stopping all daemons...
 cron(ok)
 ntpd(ok)
 pflogd(ok)
 slaacd(ok)
 smtpd(ok)
 sndiod(ok)
 sshd(ok)
 syslogd(ok)
 
 overwriting uniprocessor kernel...
 8.66MiB 0:00:06 [1.37MiB/s] [================================>] 100% ETA 0:00:00
 overwriting multiprocessor kernel...
 8.69MiB 0:00:04 [1.84MiB/s] [================================>] 100% ETA 0:00:00
 overwriting filesystem image...
 9864MiB 0:05:30 [3.05MiB/s] [================================>] 100% ETA 0:00:00
 
 update completed.
 now rebooting...
 syncing disks... done
After the update is complete, the PC will restart automatically. ~
Operation after the LiveUSB update is the same as before, and there is no need to migrate data.

>''[Memo]''~
''⇒''When fiupdate is run over the network or on the X Window System, the following warning is displayed.
 It seems you are running this script on X Window System,
 via network or something like this.
 In this situation, during update, corresponding processes
 will be killed and then update may fail.
 
 Running this on direct console device is highly recommended.
 
 Continue anyway? [y/N] ->
fiupdate stops all daemons before updating system files. At this time, the network may be disconnected or the X session may be terminated, causing the update to fail. ~
So fiupdate should be run directly on the console device.

**Using FuguIta in a mobile environment [#g9078caa]
In order to use FuguIta as a terminal in a mobile environment, the basic part is not much different from operation in a fixed environment.

However, considering the unique circumstances of the mobile environment, there are aspects that can be operated more efficiently by adding settings.

In this section, we will explain the power supply related items of the notebook PC as such setting items.

*** Power related settings [#xac12294]
Current PCs, especially laptops, have mechanisms called ACPI (Advanced Configuration and Power
Interface) and APM (Advanced Power Management), which can monitor and control power supplies such as batteries. ~
In OpenBSD, these mechanisms are implemented as [[acpi(4)>man:acpi.4]] and [[apm(4)>man:apm.4]], and through administrative commands can access.

acpi and apm are managed by a daemon called [[apmd>man:apmd.8]]. ~
Check status and configure apmd:
 fugu-demo$ doas -s
 Password:
 fugu-demo# rcctl get apmd
 apmd_class=daemon
 apmd_flags=NO      ← apmd is disabled
 apmd_timeout=30
 apmd_user=root
Enable apmd:
 fugu-demo# rcctl enable apmd
 fugu-demo# rcctl set apmd flags -A  ← Automatically change the CPU clock frequency
 fugu-demo# rcctl start apmd            according to the CPU load
 fugu-demo# rcctl get apmd
 apmd_class=daemon
 apmd_flags=
 apmd_timeout=30
 apmd_user=root
 fugu-demo# 
After completing the settings, [[usbfadm command to save >fge2:usbfadm_sync]] and [[reboot in mode 3 >fge2:boot_mode3]] Fuguita.

When apmd is running, you can monitor and control its status with the command [[apm>man:apm.8]].
 fugu-demo$ apm
 Battery state: high, 89% remaining, 57 minutes life estimate
 A/C adapter state: not connected
 Performance adjustment mode: auto (1000 MHz)
In the example below, I gave the apm command the -L flag to set the CPU to always run at low clock
 fugu-demo$ apm -L
 fugu-demo$ apm
 Battery state: high, 88% remaining, 42 minutes life estimate
 A/C adapter state: not connected
 Performance adjustment mode: manual (1000 MHz)
The status of hardware such as the battery can also be monitored using the sysctl command and the [[systat>man:systat.1]] command.
 fugu-demo$ sysctl hw.sensors
 hw.sensors.acpitz0.temp0=55.50 degC (zone temperature)
 hw.sensors.acpiac0.indicator0=Off (power supply)
 hw.sensors.acpibat0.volt0=14.80 VDC (voltage)
 hw.sensors.acpibat0.volt1=15.30 VDC (current voltage)
 hw.sensors.acpibat0.current0=1.19 A (rate)
 hw.sensors.acpibat0.amphour0=1.12 Ah (last full capacity)
 hw.sensors.acpibat0.amphour1=0.21 Ah (warning capacity)
 hw.sensors.acpibat0.amphour2=0.07 Ah (low capacity)
 hw.sensors.acpibat0.amphour3=0.92 Ah (remaining capacity), OK
 hw.sensors.acpibat0.amphour4=2.15 Ah (design capacity)
 hw.sensors.acpibat0.raw0=1 (battery discharging), OK
 hw.sensors.acpibtn0.indicator0=On (lid open)
 hw.sensors.acpidock0.indicator0=Off (not docked), UNKNOWN
 hw.sensors.cpu0.temp0=55.00 degC

 fugu-demo$ systat sensors
     3 users    Load 0.40 0.42 0.37                     Wed Dec 30 04:18:11 2015
 
 SENSOR                                 VALUE  STATUS  DESCRIPTION
 acpitz0.temp0                     56.50 degC          zone temperature
 acpiac0.indicator0                       Off          power supply
 acpibat0.volt0                    14.80 V DC          voltage
 acpibat0.volt1                    15.26 V DC          current voltage
 acpibat0.current0                     1.08 A          rate
 acpibat0.amphour0                    1.12 Ah          last full capacity
 acpibat0.amphour1                    0.21 Ah          warning capacity
 acpibat0.amphour2                    0.07 Ah          low capacity
 acpibat0.amphour3                    0.90 Ah    OK    remaining capacity
 acpibat0.amphour4                    2.15 Ah          design capacity
 acpibat0.raw0                          1 raw    OK    battery discharging
 acpibtn0.indicator0                       On          lid open
 acpidock0.indicator0                     Off unknown  not docked
 cpu0.temp0                        56.00 degC
By default, the systat command updates the status every 5 seconds and continues to display it. Type 'q' to exit.

The apm command can also hibernate your PC. ~
In addition to the apm command, commands such as [[zzz>man:zzz.8]] and [[ZZZ>man:ZZZ.8]] can also be used to hibernate. In addition, depending on the PC model, some keys are assigned to pause operations. ~
The method of resuming from hibernation differs depending on the model, but it seems that there are many that press the power button briefly or press the hibernation key again.
>&color(red){''[Caution]''&br;''!!''Hibernation actions such as standby, sleep, and hibernate will disconnect the USB device and reconnect it on wakeup. Therefore, please note that the LiveUSB version of FuguIta, which mounts the file system on the USB device, will not work properly after the system is restored. &br;''!!''Depending on the model of the PC, hibernation operation may not work well (standby can be performed but suspend or hibernate cannot be performed, it cannot be resumed from hibernation, or the operation is unstable and sometimes resume fails, etc.). Please check the operation before using.};

When using X, you can control the display with the xset command. Add the following line in .xinitrc under your home directory:
 xset s on   ← enable screensaver
 xset s 180  ← Screen saver operation start time (seconds)
 xset +dpms  ← Switch display to power saving mode

With this example setting, the display will go into power saving mode if there is no mouse or keyboard activity for 180 seconds or more.

#aname(netconf)
*** Switch between multiple network settings [#h0480456]
As explained in [[Basic network settings>#netconfig]], network settings are made in several files under the /etc directory. can be generated. ~
In addition, you can have multiple network settings, and you can switch between them with the chnetconf command.

In Fuguita, network-related configuration files are stored in subdirectories under /etc/fuguita/netconfs, and before starting the network, the files in that subdirectory are copied to /etc, and then
the network is is set. ~
Settings made at initial boot are in /etc/fuguita/netconfs/default.

As an example, let's add two settings, "home" for home and "office" for work.

First, from the office. It is intended for use with Ethernet connections and fixed address settings. To add a new configuration, invoke gennetconfs with the configuration name "office".

 fugu-demo# gennetconfs office
 ===================================================
 = gennetconfs: generate network configuration files
 ===================================================
 
 Hostname with domain part (FQDN):
 only host name without domain part is also OK.
 -> fuguita.office.local
 
 IP protocol version(s) to be enabled: 4, 6, 46, 64 or "none"
   4: enable only IPv4
   6: enable only IPv6
   46: give priority to IPv4 name resolution
   64: give priority to IPv6 name resolution
   none: operate as standalone
 [64] -> 4
 
 Network Interfaces: Choose one
 
   NIC	 type	   Name
 -------- ----- ------------
     bge0 ether Broadcom BCM57765
   urtwn0 wifi  GW-USValue-EZ GW-USValue-EZ
 [bge0] -> bge0
 
 IPv4 - address and routing:
   Enter "auto" or "IPv4_address[/mask] [default_gateway]"
   "auto" is an automatic setting by DHCP.
   The "/mask" part can be specified in either format, such as "/255.255.255.0" or "/24".
   If there is no default gateway, set the second field to "none" or leave it blank.
 [auto] -> 192.168.20.115/24 192.168.20.254
 
 DNS servers: up to 3 IP addresses, separated by spaces
 -> 192.168.20.254
 
 writing configured values to:
   /etc/fuguita/netconfs/office/myname
   /etc/fuguita/netconfs/office/mygate
   /etc/fuguita/netconfs/office/hosts
   /etc/fuguita/netconfs/office/hostname.bge0
   /etc/fuguita/netconfs/office/resolv.conf
 
 ======================================================
 = end of gennetconfs:
 = Use chnetconf utility to activate this configuration
 ======================================================
When setting with gennetconfs is completed, a setting file is created in "/etc/fuguita/netconfs/setting name".
 fugu-demo# cd /etc/fuguita/netconfs/
 fugu-demo# ls -l
 total 24
 drwxr-xr-x  2 root  wheel  144 Nov 25 05:46 default
 drwxr-xr-x  2 root  wheel  240 Nov 25 07:00 office
 drwxr-xr-x  2 root  wheel   96 Nov 18 05:49 templ.head
 drwxr-xr-x  2 root  wheel    0 Nov 18 05:49 templ.tail
 fugu-demo# ls -l office
 total 40
 -rw-r-----  1 root  wheel  23 Nov 25 07:00 hostname.bge0
 -rw-r--r--  1 root  wheel  36 Nov 25 07:00 hosts
 -rw-r--r--  1 root  wheel  15 Nov 25 07:00 mygate
 -rw-r--r--  1 root  wheel  21 Nov 25 07:00 myname
 -rw-r--r--  1 root  wheel  56 Nov 25 07:00 resolv.conf
 fugu-demo# ls -l /etc/ | grep netconfs
 lrwxr-xr-x  1 root  wheel	  28 Nov 25 06:56 myname -> /etc/fuguita/netconfs/default/myname
 drwxr-xr-x  6 root  wheel	 192 Nov 25 06:59 netconfs
Use the chnetconf utility to actually apply these settings. ~
After executing chnetconf, after copying the specified configuration file to /etc, it internally executes "sh /etc/netstart" to change the network settings.
>''[Memo]'' ~
''⇒'' Of the configuration files, only the myname file will be a symbolic link instead of a copy. This is to indicate which settings in /etc/fuguita/netconfs are used by the network settings in /etc.

 fugu-demo# chnetconf -l    ← Show all settings
 *default                   ← This settng is active.
  office
 fugu-demo# chnetconf office
 fuguita# chnetconf -l
  default
 *office              ← This configuration is active now.
 fuguita# ifconfig    ← Check interface settings
 bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
 	lladdr 10:9a:dd:6c:11:0c
 	index 1 priority 0 llprio 3
 	groups: egress
 	media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
 	status: active
 	inet 192.168.20.115 netmask 0xffffff00 broadcast 192.168.20.255
 urtwn0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
 	lladdr 00:22:cf:46:6d:e6
 	index 4 priority 4 llprio 3
 	groups: wlan
 	media: IEEE802.11 autoselect (OFDM54 mode 11g)
 	status: no network
 	ieee80211: nwid ""
 fugu-demo# ping www.google.com    ← 疎通を確認
 PING www.google.com (172.217.175.68): 56 data bytes
 64 bytes from 172.217.175.68: icmp_seq=0 ttl=115 time=28.318 ms
 64 bytes from 172.217.175.68: icmp_seq=1 ttl=115 time=25.842 ms
 64 bytes from 172.217.175.68: icmp_seq=2 ttl=115 time=26.137 ms
 ^C
 --- www.google.com ping statistics ---
 3 packets transmitted, 3 packets received, 0.0% packet loss
 round-trip min/avg/max/std-dev = 25.842/26.765/28.318/1.104 ms
Continue to create the setting "home" in the same way. This assumes that the address can be automatically set using a Wi-Fi connection using SLAAC for IPv6 and DHCP for IPv4.
 fuguita# gennetconfs home
 ===================================================
 = gennetconfs: generate network configuration files
 ===================================================
 
 Hostname with domain part (FQDN):
 only host name without domain part is also OK.
 -> fuguita.home.local
 
 IP protocol version(s) to be enabled: 4, 6, 46, 64 or "none"
   4: enable only IPv4
   6: enable only IPv6
   46: give priority to IPv4 name resolution
   64: give priority to IPv6 name resolution
   none: operate as standalone
 [64] ->
 
 Network Interfaces: Choose one
 
   NIC	 type	   Name
 -------- ----- ------------
     bge0 ether Broadcom BCM57765
   urtwn0 wifi  GW-USValue-EZ GW-USValue-EZ
 [bge0] -> urtwn0
 
 Wi-Fi settings:
   SSID -> my-wifinet
   WPA Key -> my-wpa-secret-key
 
 IPv6 - address and routing:
   Enter "auto" or "IPv6_address[/prefixlen] [default_gateway]"
   "auto" is an automatic setting by SLAAC.
   The "/prefixlen" part can be an integer between 0 and 128.
   If there is no default gateway, set the second field to "none" or leave it blank.
 [auto] ->
 
 IPv4 - address and routing:
   Enter "auto" or "IPv4_address[/mask] [default_gateway]"
   "auto" is an automatic setting by DHCP.
   The "/mask" part can be specified in either format, such as "/255.255.255.0" or "/24".
   If there is no default gateway, set the second field to "none" or leave it blank.
 [auto] ->
 
 writing configured values to:
   /etc/fuguita/netconfs/home/myname
   /etc/fuguita/netconfs/home/hostname.urtwn0
   /etc/fuguita/netconfs/home/resolv.conf
 
 ======================================================
 = end of gennetconfs:
 = Use chnetconf utility to activate this configuration
 ======================================================
 fuguita# chnetconf -l
  default
  home
 *office
 fuguita# chnetconf home
 fuguita# chnetconf -l
  default
 *home
  office
 fuguita# ifconfig
 bge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
 	lladdr 10:9a:dd:6c:11:0c
 	index 1 priority 0 llprio 3
 	media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
 	status: active
 urtwn0: flags=a48843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6TEMP,AUTOCONF6,AUTOCONF4> mtu 1500
 	lladdr 00:22:cf:46:6d:e6
 	index 4 priority 4 llprio 3
 	groups: wlan egress
 	media: IEEE802.11 autoselect (OFDM54 mode 11g)
 	status: active
 	ieee80211: nwid my-wpa-secret-key chan 10 bssid 1c:b1:7f:27:5c:de -62dBm wpakey wpaprotos wpa2
        wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
 	inet6 fe80::222:cfff:fe46:6de6%urtwn0 prefixlen 64 scopeid 0x4
 	inet 192.168.10.113 netmask 0xffffff00 broadcast 192.168.10.255
 	inet6 2409:........:8d47 prefixlen 64 autoconf pltime 604795 vltime 2591995
 	inet6 2409:........:1974 prefixlen 64 autoconf temporary pltime 77241 vltime 172795
 pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33136
 	index 5 priority 0 llprio 3
 	groups: pflog
Now, 3 network settings are created, including the traditional default.

These settings can be toggled at any time using the chnetconf utility.

#aname(fwupdate_wifi)
***Use a Wi-Fi device that requires a firmware download [#rd1c3a11]
This section describes how to deploy Wi-Fi devices as an application of the gennetconfs and chnetconf commands.

OpenBSD supports a variety of Wi-Fi devices, some of which are not available out of the box and require firmware download and installation.
>''[Memo]''~
''⇒''The OpenBSD site has the
following description about the reasons why you need to download the
firmware;~
~
OpenBSD FAQ - Wireless Networking ~
https://www.openbsd.org/faq/faq6.html#Wireless ~
~
In order to use some wireless cards, you will need to acquire firmware files with fw_update. Some manufacturers refuse to allow free distribution of their firmware, so it can't be included with OpenBSD.

Such Wi-Fi devices
- first set up on a firmware-free device and connect to the internet
- download firmware and install
- change the network settings for the desired Wi-Fi device

can be used. Here are the specific steps:

''1. Set up a firmware-free device and connect to the internet''~
At startup, configure the device to connect to the Internet using a firmware-free device as follows. ~
Most wired LAN (Ethernet) devices and some WiFi devices do not require firmware. [Listen]
 Network Interfaces: Choose one
 
   NIC	 type	   Name
 -------- ----- ------------
     bge0 ether Broadcom BCM57766
   urtwn0 wifi  GW-USValue-EZ GW-USValue-EZ
 [bge0] -> bge0
''2. Download and install the firmware''~
Log in as root and execute the [[fw_update>man:fw_update]] command. Download and install firmware.
 fugu-demo# fw_update -v
 Path to firmware: http://firmware.openbsd.org/firmware/7.0/
 Installing: inteldrm-firmware intel-firmware urtwn-firmware
 inteldrm-firmware-20201218:100%|OK
 intel-firmware-20210608v0:100%|OK
 urtwn-firmware-20180103p0:100%|OK
 fugu-demo# 
>''[Memo]'' ~
''⇒''fw_update is automatically executed at startup, but just in case, it is manually executed again.

''3. Change the connection settings to the Wi-Fi device you want to use''~
Once the firmware is installed, change the connection setting to Wi-Fi Device and check the operation.
 fugu-demo# gennetconfs wifi  ← generate configuration file
 ===================================================
 = gennetconfs: generate network configuration files
 ===================================================
 ~ omitted ~
 Network Interfaces: Choose one
 
   NIC	 type	   Name
 -------- ----- ------------
     bge0 ether Broadcom BCM57766
   urtwn0 wifi  GW-USValue-EZ GW-USValue-EZ
 [bge0] -> urtwn0                ← select Wi-Fi device
 
 Wi-Fi settings:
   SSID -> my-wifinet            ← enter Wi-Fi SSID
   WPA Key -> my-wpa-secret-key  ← and password
 ~ omitted ~
 ======================================================
 = end of gennetconfs:
 = Use chnetconf utility to activate this configuration
 ======================================================
 fugu-demo# chnetconf wifi       ← change the network to the settings
                                    you just made
 fugu-demo# ping www.google.com  ← check connection
 PING www.google.com (216.58.220.100): 56 data bytes
 64 bytes from 216.58.220.100: icmp_seq=0 ttl=114 time=33.656 ms
 64 bytes from 216.58.220.100: icmp_seq=1 ttl=114 time=28.933 ms
 64 bytes from 216.58.220.100: icmp_seq=2 ttl=114 time=26.193 ms
 64 bytes from 216.58.220.100: icmp_seq=3 ttl=114 time=21.949 ms
 ^C
 --- www.google.com ping statistics ---
 4 packets transmitted, 4 packets received, 0.0% packet loss
 round-trip min/avg/max/std-dev = 21.949/27.683/33.656/4.253 ms
This completes the Wi-Fi firmware installation.
[[Save using the usbfadm command >fge2:usbfadm_sync]] the last modified content. If you specify this setting [[Reboot in mode 3>fge2:boot_mode3]], you can continue to use this setting.
 fugu-demo# usbfadm -r
 
 ========================================
 = Sync current mfs as fugu-demo into /dev/sd1d
 =
     :
     :

* Manage LiveUSB [#n37d4d33]
#aname(liveusb_remaster)
** LiveUSB remastering [#la40e41f]
This section describes how to create a new FuguItaLiveUSB with another USB memory using FuguIta that
is already running. ~
With this method, you can allocate a swap partition, a data storage area, a FAT partition for data exchange with other OS, etc. by specifying the size of each.
You can also specify data storage encryption. ~
The example below assumes that you are installing to a USB memory with a size of 4GB.

First, start FuguIta in mode 0 or mode 1. You can use either the LiveDVD version or the LiveUSB version of FuguIta to start.

Once booting is complete, run the usbfadm command with root privileges.
 fugu-demo$ doas usbfadm
 doas (yoshi@fugu-demo.localnet) password:
 
 Welcome to usbfadm.
 USB flash drive administration tool for FuguIta
 
  Version/Arch: 7.2/amd64  (FuguIta-7.2-amd64-202302081)
     Boot mode: usbflash
 Target device: /dev/sd1d
 Data saved as: fugu-demo
 
 readline capability available
 TAB to complete the reserved words
 
 Type ? for help.
 
 sd1d : fugu-demo ->newdrive    ← Instruct LiveUSB creation
 
 Please make sure the device inserted.
 Then press ENTER ->    ← After confirming that the USB memory is installed,
                           press <Enter>.
       A list of recognized disk devices is displayed in chronological order.

 ==== disk(s) and vnode devices ============================
 sd0 at scsibus1 targ 0 lun 0: <VirtIO, Block Device, >
 sd0: 65536MB, 512 bytes/sector, 134217728 sectors
 sd1 at scsibus2 targ 0 lun 0: <VirtIO, Block Device, >
 sd1: 4096MB, 512 bytes/sector, 8388608 sectors
 vnd0: not in use
 vnd1: not in use
 vnd2: not in use
 vnd3: not in use
 vnd4: not in use
 vnd5: covering /sysmedia/fuguita-7.2-amd64.ffsimg on cd0a, inode 48172
 ============================================================
 Enter the name of device which FuguIta will be installed->sd1    ← Specify device to create LiveUSB
 swapctl: no swap devices configured
 
 Disk: sd1      geometry: 522/255/63 [8388608 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 boot method:
   1:  Legacy BIOS
   2: [UEFI]
   3:  none (only for save data)
   4:  Hybrid
 ->
 
 Select partition type:
   1: [MBR]
   2:  GPT
 ->
 
 Type of /ram:
   1: [MFS]
   2:  TMPFS
 ->
 
 Enter sizes for swap, user data and extra FAT.
   You can add suffix K, M, G or T (otherwise considered 'bytes').
   '*' implies 'all'
   '0' doesn't make this partition.
 
 3GB (3085MB) (6319040sectors) free
 swap->16M   ← Create swap with 16MB by default
 
 3GB (3085MB) (6319040sectors) free
 user data->2g        ← Allocate 3 gigabytes with "2g"
                           Type "*" to assign all the rest.
 
 user data encryption? [y/N] ->    ← See another section for details
 
 Create an extra FAT partition? [y/n] -> y
 
 target disk: sd1
   partition type=MBR
        boot type=UEFI
 
 -------------------- : ------
            partition :   size
 -------------------- : ------
           whole disk :    4GB
     partition tables :   32KB
          UEFI system :  512KB
       FuguIta system : 1010MB
         FuguIta swap :     0B
    FuguIta user data :    2GB
            MSDOS FAT :    1GB
 -------------------- : ------
 
 ***THIS IS THE LAST CHANCE***
 If you type 'Y' now, all the data on sd1 will be lost.
 Are you sure to modify disk sd1? [y/N] -> y
 ========================================
 = Clearing MBR, GPT and BSD disklabel
 =
 1+0 records in
 1+0 records out
 1048576 bytes transferred in 0.009 secs (110136197 bytes/sec)
 
 ========================================
 = Setting up fdisk partitions
 =
   ~ omitted ~
 ** /dev/rsd1d
 ** File system is already clean
 ** Last Mounted on /mnt
 ** Phase 1 - Check Blocks and Sizes
 ** Phase 2 - Check Pathnames
 ** Phase 3 - Check Connectivity
 ** Phase 4 - Check Reference Counts
 ** Phase 5 - Check Cyl groups
 5 files, 5 used, 1012714 free (18 frags, 126587 blocks, 0.0% fragmentation)
 
 sd1d : fugu-demo ->quit
 
 Bye bye...
 fugu-demo$
The above will write the Fugu board system to the specified device and it will be ready for use.

>&color(red){''[Caution]''&br;''!!''Please check the device name of the write destination. Writing to the wrong device will result in the loss of data stored there.};

#ref(河豚板ガイド/fuguita-usb-uefi.png,around,right);
If you make a diagram of what you have explained so far, it will look like the one on the right.

The i partition at the beginning of the media is created when UEFI is selected as the boot method.~
In the a partition at the beginning of the media, the system of FuguIta is written. If you select "none" for "Select boot method:", the i partition and a partition will not be created because the media will be used exclusively for saving data.

Next, a d partition with the size you entered in "Enter size for saving User Data" will be created and used as the data destination for usbfadm.

If there is still unused space after allocating space for the above partitions, you will be asked "Create an extra FAT partition? [y/n] ->".~
If you answer ''y'' to this, the ''j'' partition will be reserved. This partition is formatted as a FAT file system and can be accessed by other operating systems such as Windows. OpenBSD can also mount FAT, so it can be used to exchange data between FuguIta and other OS.
#clear

>''[Memo]''~
''⇒''The remastering of FuguIta described in this section can be used not only for USB memory but also for all recording devices that can be written from OpenBSD. For example, you can write to SD cards, compact flash, memory sticks or even ATA and SATA hard disks.

>''[Memo]''~
''⇒''Currently, there are two types of boot methods for PCs, "BIOS" and "UEFI". The methods described so far work for both boot methods. ~
If you specify "Legacy BIOS" as the boot method and "MBR" as the partition format, the media will support the "BIOS-only boot method.
#ref(河豚板ガイド/fuguita-usb.png,around,left);

The partition configuration in this case is as shown in the left figure.
The UEFI boot partition is not created, and the FAT area becomes the i partition.
#clear

>''[Memo]''~
''⇒'' Even if you specify the boot method "Hybrid", you can create a USB memory
that can boot with either BIOS or UEFI. ~
However, "Hybrid" is a non-standard creation method. In addition, please note that changing the partition with the fdisk command after creation will cause problems (Hybrid format is left for compatibility with past releases).

#aname(autorun)
** Automate setting input at startup [#l299f679]
FuguIta requires the following settings during startup:
-Which is FuguIta's operating device?
-Enter mfs size in MB.
-Boot modes
-Which is FuguIta's storage device?
-config name

There is a function to automate the input for the above 5 items. ~
For that, write the settings to a file called noasks in the ``d'' partition of the LiveUSB version of FuguIta.
 fugu-demo$ doas -s 
 doas (yoshi@fugu-demo.localnet) password: 
 fugu-demo# mount /dev/sd0d /mnt
 fugu-demo# cd /mnt
 fugu-demo# ls -l
 total 4
 drwxr-xr-x  5 root  wheel  512 Oct 23 19:29 livecd-config
 fugu-demo# cd livecd-config/7.0/amd64                                           
 fugu-demo# ls -l
 drwxr-xr-x  11 root  wheel  512 Nov 10 17:08 fugu-demo
 -rw-r--r--   1 root  wheel  422 Nov  9 22:19 noasks
>''[Memo]''~
''⇒'' Directory livecd-config is a directory for saving data by usbfadm.

In noasks, the setting value template is written in the form of comments, so use a text editor to uncomment the setting line and write the value you want to set.
 fugu-demo# vi noasks

 #
 # noasks - parameter settings for non-interactive boot
 #
 # Make statements uncommented
 # Then assign real values
 #
 #
 # FuguIta system device
 #   - Use one of two lines                    ← FuguIta's system device:
 #noask_rdev=sd2a  # device name format             Uncomment specifying either
 #noask_rdev=f24c0ae78bb7e0e4.a  # DUID format      a regular device name or a DUID format.
 #                                              
 # mfs size in MB
 #noask_umem=75%  ← Specifies the amount of memory to allocate to MFS from the on-board
                     memory. (Only numbers are in megabytes, % is installed memory, %% is
                     percentage of installed memory + swap)
 #               
 # boot mode
 #noask_setup_rw_mode=3  ← boot mode for auto start
 #
 # storage device
 #   - Use one of two lines
 #noask_confdev=sd2d  # device name format
 #noask_confdev=f24c0ae78bb7e0e4.d  # DUID format
 #
 # data set name in USB flash drive
 #noask_confdir=fugu-demo
>''[Memo]''~
''⇒''Please do not put spaces before and after "=" in the setting value assignment statement (the noasks file is interpreted as a shell script).

After editing, unmount the ''d'' partition and reboot the system.
 fugu-demo# cd
 fugu-demo# umount /mnt
 fugu-demo# /sbin/shutdown -r now
#aname(noasks-intr)
If the value is set by the noasks file, you will see the following
 ============================================
 =     ______               __   _
 =    / ____/              |  |_| |__
 =   / /____  ______  __  _|  /_   _/_____
 =  / ___/ / / / __ \/ / / |  | | | /  _  |
 = / /  / /_/ / /_/ / /_/ /|  | | |_| (_) |__
 =/_/   \____/\__  /\____/ |__| \___/____/__/
 =            __/ /
 =           /___/
 =
 = Welcome to FuguIta!  -  OpenBSD Live System
 =                 http://fuguita.org/?FuguIta
 =============================================
 scanning partitions: wd0i wd0j sd0a sd0d
 FuguIta's operating device(s): sd0a.
 Press ^C to cancel non-interactive boot
Wait 5 seconds after this "Press ^C to cancel non-interactive boot" is displayed and automatic boot will be performed. ~
If you enter ``<Control>-C'' within 5 seconds, the automatic startup by the noasks file will be aborted and normal operation will resume.

>''[Memo]''~
''⇒''If there is an unconfigured item in the noasks file, wait for input from the user at the item configuration during autostart.

>''[Memo]''~
''⇒'' Among the setting items, noask_rdev and noask_confdev can be specified by DUID (Disklabel Unique IDentifiers) in addition to normal device names such as sd0a. A DUID is a random, unique hexadecimal string automatically attached to a disk device. ~
The DUID can be found from the output of the disklabel command.
 fugu-demo# disklabel sd0
 # /dev/rsd0c:
 type: ESDI
 disk: ESDI/IDE disk
 label: QEMU HARDDISK   
 duid: eac6323f6d34c465  ←DUID
 flags:
 ~ omitted ~
For example, when specifying the FuguIta boot device in the noasks
file, instead of writing
 noask_confdev=sd0d
you can specify "DUID.partition" like
 noask_confdev=eac6323f6d34c465.d

With normal device name specification, if the connection status of the disk device changes, sd0 will change to sd1, etc., and automatic startup may fail, but with DUID specification, the same disk is always specified regardless of the device connection status. can do.

#aname(autosave)
**Automatically save data on exit [#l574cf8b]
In the previous section [[Make it possible to omit the setting input at startup>#autorun]], automation at FuguIta startup was explained, but it is also possible to automatically save data at the end.

OpenBSD runs a script called /etc/rc.shutdown when the system shuts down. ~
FuguIta describes the process of saving data in /etc/rc.shutdown.
 force_umount=No  # set Yes for forced umount /ram at shutdown
 force_resync=No  # set Yes to re-sync at shutdown
 ~ omitted ~
By changing the setting value of force_resync on the second line of the file from "No" to "Yes", data will be saved at the end.

>''[Memo]''~
''⇒'' In this process, if the save process fails repeatedly, a shell will be launched. Use this shell to remove the cause of the failure and manually run usbfadm -r. &br;When you exit the shell, the save process is re-executed.
>&color(red){''[Caution]''&br;''! ! ''If important processing is performed during operation, it is recommended to manually save thedata separately before shutting down. };

#aname(encrypt)
** Encrypt data storage [#i23536ae]
As explained in [[Save settings and files>fge2:usbfadm_sync]] in the Basics section, FuguIta's USB memory has a partition for saving data.

By using the function to encrypt the storage area, the information stored in the USB memory can be protected from accidents such as theft or loss.

[Creating a LiveUSB with the usbfadm command >#liveusb_remaster]] When using the newdrive function of the usbfadm command, You can create an encrypted partition by specifying as follows.
 fugu-demo# usbfadm
 
 Welcome to usbfadm.
 USB flash drive administration tool for FuguIta
 
   Version/Arch: 6.7/amd64  (FuguIta-6.7-amd64-202006142)
      Boot mode: manual
 Data stored in: not set
  Data Saved as: not set
 
 Type ? for help.
 
 ? : ? ->newdrive
 ~ omitted ~ 
 Enter sizes for swap, user data and extra FAT.
   You can add suffix K, M, G or T (otherwise considered 'bytes').
   '*' implies 'all'
   '0' doesn't make this partition.
 
 589MB (604128KB) (1208256sectors) free
 swap->64m
 
 
 525MB (538592KB) (1077184sectors) free
 userrdata->*
 
 user data encryption? [y/N] -> y       ← Specify data storage encryption
 
 Enter passphrase twice. They'll be not echoed.
 
 //// CAUTION ////////////////////////////
 ////   If you lost this passphrase,
 ////   you'll never access sd0d.
 /////////////////////////////////////////
 
 Passphrase:           ← Your input will not be displayed
 Passphrase:           ← again for confirmation
 ~ omitted ~ 
To store data in an encrypted partition, there are two steps as below.
+Specify the encrypted partition with the target function of usbfadm and enter the passphrase. ~
~
+If the passphrase is entered correctly, a new disk will appear, so call the target function again and specify this disk.
- Execute data saving with the sync function of usbfadm.
 ? : ? ->target
 
 Searching storage device
 Please make sure the device inserted.
 Then press ENTER ->
 sd0a ?sd0d                             ← The one with "?" at the beginning
                                           is the encrypted partition.
 target device->sd0d                    ← Specify this partition
 Passphrase:                            ← and enter the passphrase.
 sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006>
 sd1: 525MB, 512 bytes/sector, 1076656 sectors
 softraid0: CRYPTO volume attached as sd1
 sd0a ?sd0d +sd1d                       ← A new disk sd1d appears if the passphrase is correct.
 target device->sd1d                    ← Specify sd1d as the save destination,
                                           and then save using the normal procedure.
  sd1d : ? ->saveas
 Name of avedd ata->fugu-demo
 
 Your data will be saved as ``fugu-demo''.
 
 sd1d : fugu-demo ->sync
 
 Sync current mfs as ``fugu-demo'' , OK? [y/N] -> y
 
 copying /ram to /mnt/livecd-config/6.7/amd64/fugu-demo (30688KB approx.):
 25.0MiB 0:00:38 [9673KiB/s][[===========================>      ] 83% ETA 0:00:07
 waiting for pax to finish ... syncing ... done.
 
 sd1d : fugu-demo ->bye
Loading saved data on subsequent launches is a two-step process similar to saving.
+Specify boot mode 3, specify an encrypted partition, and enter a passphrase. ~
~
+If the passphrase input is correct, a new disk will appear, so call mode 3 again and specify that disk.
 ============================================
 =     ______               __   _
 =    / ____/              |  |_| |__
 =   / /____  ______  __  _|  /_   _/_____
 =  / ___/ / / / __ \/ / / |  | | | /  _  |
 = / /  / /_/ / /_/ / /_/ /|  | | |_| (_) |__
 =/_/   \____/\__  /\____/ |__| \___/____/__/
 =            __/ /
 =           /___/
 =
 =  Welcome to FuguIta  -  OpenBSD Live System
 =                         http://fuguita.org/
 =============================================
 
 scanning partitions: sd0a sd0b sd0d cd0a
 FuguIta's operating device(s): sd0a cd0a.
 Which is FuguIta's operating device? -> sd0a
 activating swap partition: /dev/sd0b
   user memory: 239 MB
 Enter mfs size in MB. (0MB is auto)
 [default: 0MB] ->
 mfs size will be automatically allocated
 Boot modes:
   0: fresh boot - standard mode as a live system
   1: fresh boot - less memory, faster boot (/usr is non-writable, can't pkg_add)
   2: fresh boot - works using only RAM (about 1GB or more of RAM required)
   3: boot with retrieving saved files from storage device
      or enter passphrase for an encrypted volume
   4: boot with retrieving saved files from floppy disk
   5: interactive shell for debugging
 ->3                                    ← select boot mode 3
 scanning partitions: sd0a sd0b sd0d cd0a
 Device(s) found:
       encrypted: sd0d
 Which is FuguIta's storage device? -> sd0d
 Passphrase:
  ↓ If the passphrase is correct, a new disk will appear.
 sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006>
 sd1: 525MB, 512 bytes/sector, 1076656 sectors
 softraid0: CRYPTO volume attached as sd1
 Passphrase successful: Select boot mode again...
 Boot modes:
   0: fresh boot - standard mode as a live system
   1: fresh boot - less memory, faster boot (/usr is non-writable, can't pkg_add)
   2: fresh boot - works using only RAM (about 1GB or more of RAM required)
   3: boot with retrieving saved files from storage device
      or enter passphrase for an encrypted volume
   4: boot with retrieving saved files from floppy disk
   5: interactive shell for debugging
 ->3                                    ← Specify boot mode 3 again
 scanning partitions: sd0a sd0b sd0d cd0a sd1d
 Device(s) found:
   loadable from: sd1d                  ← You can read from the newly appeared disk.
       encrypted: sd0d
 Which is FuguIta's storage device? [default: sd1d] -> sd1d
 /dev/sd1d : available data;
 
 fugu-demo
 
 config name -> fugu-demo
 Copying files from flash to ram ...
 done
 ~ omitted ~ 
This disk will be visible after boot completes, so you don't need to enter the passphrase again when saving data.

** Enable swap partition [#fb5282c1]
Usually, FuguIta does not use swap and runs only in main memory, but in an environment like [[normal OpenBSD and FuguIta coexisting>#coexist_obsd]], the OpenBSD swap partition is detected. , and also enable it.
 Which is FuguIta's operating device? -> wd0a
 activating swap partition: /dev/wd0b
 activating swap partition: /dev/wd1b
In this example, we found two swap partitions /dev/wd0b and /dev/wd1b and both are enabled. ~
Swap partitions are enabled upon detection. There is no setting to disable/enable this.
>''[Memo]''~
''⇒''If you don't want to use swap for some reason (e.g. your swap partition might have bad sectors that might cause the process to crash, you don't want to leave a memory image on disk, etc.) In this case, select startup mode 5 "interactive shell for debugging". ~
After selection, execute the [[swapctl>man:swapctl.8]] command with the -d option to disable the swap when the shell starts up. ~
After exiting the shell, the boot mode will be selected again, so select the original boot mode and resume processing.

#aname(fstab_tail)
** Add partition to mount [#e241d5b0]
Usually in Unix OS, the partition to be mounted is specified in a file called /etc/fstab. ~
So if a user wants to add or change which partitions are mounted, change what is written in fstab.

However, in FuguIta, even if you change the contents of the fstab file and restart, the contents will not be reflected in the mount status of the file system.

During startup initialization, FuguIta probes all disk devices connected to the PC to detect system partitions, etc. It also receives specifications from users as needed. ~
Finally, the resulting fstab is automatically generated, based on which the filesystem is mounted. ~
Therefore, even if the user changes and saves fstab, the contents will be overwritten at the next boot.

If you want to add a partition to mount, write it in the file /etc/fuguita/fstab.tail. ~
As an example, if you want to additionally mount the e partition of the disk named sd2 to the directory named /ram/opt, the procedure is as follows.
- Create /etc/fuguita/fstab.tail. The format of this file is the same as /etc/fstab.
 /dev/sd2e /ram/opt ffs rw 0 1
- If the /ram/opt directory does not exist, create it in advance.
 fugu-demo# mkdir /ram/opt
- Save the file using the sync function of the usbfadm command.
- Reboot the system into boot mode 3 and make sure the specified partition is mounted.
The content of the /etc/fuguita/fstab.tail file is added to the end of the automatically generated /etc/fstab file, after which the file system is mounted.

>''[Memo]''~
''⇒''The mount point must be created inside mfs (under the /ram directory). ~
''⇒''/ram The directories and files directly under the /ram directory are automatically symbolically linked from the root directory at startup. Thus /ram/opt can be accessed as /opt.

*Other [#d14857c1]
#aname(multidevice)
**Using multiple Fuguita [#b4686050]
Until now, most of the explanations have been based on the assumption that either the LiveDVD version or the LiveUSB version of Fuguita is used, but what happens if both the LiveDVD and LiveUSB are installed in the PC and booted? Huh? Or what if you make two LiveUSBs, insert them both and boot?

FuguIta is designed to work well in such cases.

I will explain the case where both LiveDVD and LiveUSB are installed and booted.

First, whether the DVD or USB boot immediately after turning on the power depends on the setting of the PC's BIOS menu as described in [[Boot settings>fge1:bootdevice]].

Next is the operational device (the device mounted in the directory /fuguita and used as the OS).
 scanning partitions: wd0i wd0j cd0a sd0a sd0d
 FuguIta's operating device(s): cd0a sd0a.
 Which is FuguIta's operating device? ->
enumerates the available devices like  and asks the user which one to use.
>''[Memo]''~
''⇒'' In the above example, wd0i and wd0j are assumed to be internal hard disks. If Windows is installed on the internal hard disk and there are two partitions, C drive and D drive, it will be displayed like this.

When reading the saved data, if there are multiple candidates, ask the user which one to use. For example, if you select boot mode 3 with two LiveUSBs inserted, two candidates sd0d and sd1d are displayed as follows;
 Boot modes:
   0: fresh boot - standard mode as a live system
   1: fresh boot - less memory, faster boot (/usr is non-writable, can't pkg_add)
   2: fresh boot - works using only RAM (about 1GB or more of RAM required)
   3: boot with retrieving saved files from storage device
      or enter passphrase for an encrypted volume
   4: boot with retrieving saved files from floppy disk
   5: interactive shell for debugging
 ->3
 scanning partitions: wd0i wd0j sd0a sd0d sd1a sd1d
 Device(s) found:
   loadable from: sd0d sd1d
 Which is FuguIta's storage device?  -> 
When saving data with the usbfadm command, you can specify the destination device using the target command of usbfadm as described in [[Saving settings and files>fge2:usbfadm_sync]].

By applying the above, the following operations are possible.

:Operation with the SD card version of FuguIta|[[Create a LiveUSB according to the capacity of the USB memory>#liveusb_remaster]] You can install it. ~
There are almost no PCs that support booting from an SD card, but if you install both the LiveDVD version and the SD card version of FuguIta and start the PC, the system will start up with LiveDVD and operate. By using an SD card as the device, it is possible to operate with the SD card version of FuguIta.
:Start the LiveDVD version of FuguIta in mode 3|Data cannot be saved/restored with the LiveDVD version of FuguIta alone, but by using it in combination with LiveUSB, etc., you can save the data and finish it while operating on DVD, and next time. You can use it to restore at startup.
>''[Memo]''~
''⇒''The USB memory is mounted only when saving/restoring data, so you can remove it at other times.

This feature of FuguIta that "startup and operation can be performed on separate devices" can be further utilized to [[OpenBSD and FuguIta coexist>#coexist_obsd]] and [[Windows or Linux and FuguIta coexist> #coexist_other]] is also possible. These will be introduced in the following sections.
>''[Memo]''~
''⇒'' Note that the automation of setting input described in [[Make it possible to omit setting input at startup>#autorun]] is only possible when there is only one noasks file in all partitions. It will be executed. If two or more noasks files are detected, the automatic execution will stop for safety and shift to manual input.

#aname(coexist_obsd)
** Let OpenBSD and FuguIta coexist [#a5e14952]
If OpenBSD is already installed on the PC on which you are going to run FuguIta, you can start FuguIta by placing the FuguIta files in the installed OpenBSD even if LiveDVD or LiveUSB is not attached. can.

The principle is to put the FuguIta kernel and ISO image on an existing OpenBSD partition and use the existing bootloader to boot the FuguIta kernel.

Here's how to install and start. ~
First start your existing OpenBSD and login as root.

Next, create a directory called "ISO" directly under the root directory. ~
 Download the ISO image from the FuguIta site to this /ISO directory and expand it.
 fugu-demo# mkdir /ISO
 fugu-demo# cd /ISO
 fugu-demo# ftp http://mirror.ginzado.ne.jp/pub/FuguIta/FuguIta-6.0-amd64-201612251.iso.gz
 Trying 110.92.1.251...
 Requesting http://mirror.ginzado.ne.jp/pub/FuguIta/FuguIta-6.0-amd64-201612251.iso.gz
 100% |**************************************************|   322 MB    07:48
 
 338634465 bytes received in 468.48 seconds (705.90 KB/s)
 fugu-demo# ls -l
 total 661632
 -rw-r--r--  1 root  wheel  338634465 Dec 29 00:55 FuguIta-6.0-amd64-201612251.iso.gz
 fugu-demo# gunzip FuguIta-6.0-amd64-201612251.iso.gz
 fugu-demo# ls -l
 total 1427648
 -rw-r--r--  1 root  wheel  730744832 Dec 29 00:55 FuguIta-6.0-amd64-201612251.iso
Copy the FuguIta kernel included in the ISO image directly under the root directory.
[[vnconfig>man:vnconfig.8]] is a command that allows you to access ISO or USB memory image files as storage devices.
 fugu-demo# vnconfig vnd0 FuguIta-6.0-amd64-201612251.iso
 fugu-demo# vnconfig -l
 vnd0: covering FuguIta-6.0-amd64-201612251.iso on wd0a, inode 25986
 vnd1: not in use
 vnd2: not in use
 vnd3: not in use
 fugu-demo# mount -r /dev/vnd0a /mnt
 fugu-demo# ls -l /mnt
 total 1427119
 -r-xr-xr-x  1 root  bin        71452 Apr  4  2015 boot
 -rwxr--r--  1 root  wheel       2048 Dec 27 11:59 boot.catalog
 -rw-r--r--  1 root  wheel    5569179 Dec 27 19:19 bsd-fi
 -rw-r--r--  1 root  wheel    5577796 Dec 27 19:19 bsd-fi.mp
 -r-xr-xr-x  1 root  wheel      72328 Dec 27 19:19 cdboot
 -r-xr-xr-x  1 root  wheel       2048 Dec 27 19:19 cdbr
 drwxr-xr-x  2 root  wheel       2048 Apr 18  2014 etc
 -rw-r--r--  1 root  wheel  719388672 Dec 27 19:19 fuguita-5.8.ffsimg
 fugu-demo# cp -p /mnt/bsd-fi /mnt/bsd-fi.mp  /
 fugu-demo# umount /mnt
 fugu-demo# vnconfig -u vnd0
 fugu-demo# vnconfig -l
 vnd0: not in use
 vnd1: not in use
 vnd2: not in use
 vnd3: not in use
 fugu-demo#
The installation is now complete.
>''[Memo]''~
''⇒''If you want to save and restore data, create a directory called livecd-config. However, it cannot be created in the same location as the ISO directory. This is because the partition where the ISO directory is created is mounted as non-writable while FuguIta is running. Therefore, a suitable partition for creating a livecd-config is directly under another partition's mount point, eg /home or /var.

Next is the boot method, the PC boots and the "boot>" prompt is displayed for a few seconds just before the kernel message is displayed. ~
If you do nothing here, the existing OpenBSD system will boot, but if you enter the kernel you want to boot, that kernel will boot.
 boot> bsd-fi.mp
This "bsd-fi.mp" is the FuguIta kernel for multiprocessors.
Enter "bsd-fi" if you want to launch the FuguIta kernel for a single processor.
>''[Memo]''~
''⇒''In the above explanation, the ISO directory and livecd-config directory were created directly under the root directory, but if it is directly under the partition where the OpenBSD file system is created, it is not directly under the root directory. also works.

#aname(coexist_other)
** Let FuguIta coexist with Windows or Linux [#m5d76f26]
FuguIta can also use partitions formatted with Windows NTFS or FAT, Linux EXT-2, EXT-4 file systems as operating devices. ~
This method is almost the same as the procedure explained in [[OpenBSD and FuguIta coexisting>#coexist_obsd]]. in short,
- boot the OS used as the operational device,
- Create a folder called ISO directly under the file system on that OS (C drive and D drive for Windows, root directory and other mount points for Linux),
- Place the ISO image of FuguIta inside that folder.

However, when using FuguIta from a Windows or Linux file system, there are the following limitations.
- Currently it is not possible to boot an OpenBSD kernel placed in a Windows or Linux filesystem. Therefore, you will use the LiveDVD version or LiveUSB version of FuguIta only for kernel
booting.
- Windows and Linux file systems do not support saving and restoring data, so use the LiveUSB version of FuguIta to save and restore data.

#aname(use_tmpfs)
**Change /ram file system to TMPFS [#e78a60b2]
On FuguIta, [[MFS>man:mount_mfs]] is created as a file system on memory and mounted on /ram, but this MFS can be changed to [[TMPFS>man:mount_tmpfs]].

Both MFS and TMPFS hold files in memory, but there are differences as follows.
| |MFS |TMPFS|h
|file holding|user process|kernel space|
|Memory usage |Once acquired, it is not released even if the file is deleted&br;(It is reused in subsequent file creation)|Memory is dynamically acquired and released by creating and deleting files|
|Capacity upper limit|There is a maximum value for each architecture&br;(i386:1GB, arm64:15GB, amd64:30GB)|Depends on amount of memory + swap|
| Works | Stable | May be unstable (see below) |
FuguIta adopts MFS because it emphasizes the stability of operation, but by specifying it when remastering, it is possible to create a media of FuguIta that uses TMPFS.
To generate an ISO image of the LiveDVD, use a tool called remaster_dvd.sh, where you can specify the file system to use with the -m option.
 fugu-demo# cp -pR /sysmedia .
 fugu-demo# cd sysmedia
 fugu-demo# remaster_dvd.sh -h
 /usr/fuguita/sbin/remaster_dvd.sh: -h: unknown option
 Usage: remaster_dvd.sh [-m mfs|tmpfs]
 fugu-demo# remaster_dvd.sh -m tmpfs
 Changing file system of /ram: from mfs to tmpfs
 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: 1028
 Total directory bytes: 2048
 Path table size(bytes): 22
 512760 extents written (1001 Mb)
 fugu-demo# cd ..
 fugu-demo# ls -l
 total 2053057
 -rw-r--r--  1 root  wheel  1050132480 Mar 14 03:57 FuguIta-7.2-amd64-202303133.iso
 drwxr-xr-x  3 root  wheel	  512 Oct 22 17:09 sysmedia
 fugu-demo#
When remastering LiveUSB, specify the newdrive subcommand of usbfadm as follows.
 fugu-demo$ doas usbfadm
 doas (yoshi@fugu-demo.localnet) password:
 
 Welcome to usbfadm.
 USB flash drive administration tool for FuguIta
 
  Version/Arch: 7.2/amd64  (FuguIta-7.2-amd64-202302081)
     Boot mode: usbflash
 Target device: /dev/sd1d
 Data saved as: fugu-demo
 
 readline capability available
 TAB to complete the reserved words
 
 Type ? for help.
 
 sd1d : fugu-demo ->newdrive
 ~ abbreviated ~
 Type of /ram:
 1: [MFS]
 2:  TMPFS
 ->2
 ~ abbreviated ~
In FuguIta media with TMPFS enabled, the file system capacity settings at startup are as follows.
 Enter tmpfs size (0 is auto).
   You can add suffix K, M, or G.
   % is a percentage of memory size.
   and %% is a percentage of the total memory and swap.
   otherwise considered "megabytes"
 
 [default: 0M] -> 
In this way, the default setting value is "0", and if this is specified, the capacitance value is automatically set.
>''[Memo]''~
''⇒''Switching between MFS and TMPFS does not affect system operation. You can also save data by usbfadm sync on MFS, then start up in mode 3 on the system switched to TMPFS and read the data. The reverse (TMPFS → MFS) is also possible.

>''[Memo]''~
''⇒'' Note that TMPFS is not completely stable as [[documented in man page>man:mount_tmpfs#BUGS]]. TMPFS can cause a kernel panic under frequent page-out/page-in situations.

#navi(FuguItaGuide)


Front page   New Page list Search Recent changes   Help   RSS of recent changes