📜 ⬆️ ⬇️

Configuring OS Inferno

FAQ: What is OS Inferno and why is it needed?

So, we have just installed hosted OS Inferno in our home directory, and we can proceed to setting up the system.

Content



For impatient


The article turned out not small, because it describes not only “what” to do, but why, why, and what other options are there, plus additional explanations for working with inferno for beginners. If you just want to quickly set up your system, then simply download the recommended / lib / sh / profile , plus if you have Linux or FreeBSD, make yourself wrapper scripts for running inferno .

Starting and exiting inferno


Hosted Inferno is started with the emu or emu-g command (without support for graphics mode). By default, sh starts and displays the command line prompt " ; ":
 $ emu ; 

You can exit sh using the exit or by marking the end of the input with the Ctrl-D combination (under Windows, after Ctrl-D you must also press Enter ). You can exit inferno with the command shutdown -h or (only under Linux / Win) interrupting the work on Ctrl-C .
')
Right now, you will not notice any difference between all these methods - they all stop working inferno. The fact is that the inferno works while there are active processes, and at the moment there is only one such process - sh . If you run additional processes, for example ndb/cs (a service resolver needed for working with the network), then after exiting sh inferno will continue to work, but you will not be able to influence it. Under Linux / Win, you will also be able to turn off the inferno via Ctrl-C , and under FreeBSD / MacOSX you will only have to kill the emu process using the main OS. Of course, if you first start the rstyx service (analogous to ssh for remote access), then you can connect to this emu from another and remotely execute shutdown -h .

Another difference is under Linux and FreeBSD - after the inferno is completed, the message “Killed” is displayed in the console:
 powerman@Ubuntu:~$ emu-g echo ok ok  powerman@Ubuntu:~$ [powerman@freebsd ~]$ emu-g echo ok ok Killed: 9 [powerman@freebsd ~]$ 
No harm from him, and there is a way to solve this problem. To do this, you will need to run emu and emu-g through the wrapper scripts ~ / bin / emu and ~ / bin / emu-g:
 powerman@Ubuntu:~$ cat ~/bin/emu-g #!/bin/bash $INFERNO_ROOT/Linux/386/bin/emu-g "$@" </dev/stdin & wait 2>/dev/null [powerman@freebsd ~]$ cat bin/emu-g #!/usr/local/bin/bash $INFERNO_ROOT/FreeBSD/386/bin/emu-g "$@" </dev/stdin & wait 2>/dev/null 
Under Linux, it is enough to create these scripts and make them executable, and under FreeBSD, you must additionally install bash and modify the PATH value in ~/.bash_profile so that the directory /home/_/bin in front of the directory with inferno.

Emu options


Some parameters are specified when starting inferno. They can be specified either explicitly on the command line, or entered into the EMU environment variable. There is only one mandatory parameter among these parameters: -r//// and we have already registered it in the EMU variable during the installation process. Of the useful optional parameters, the following are worth mentioning:
You can read more about emu options in the emu (1) man page.

The current values ​​of some parameters can be found inside the inferno:
 ; echo $emuroot /home/powerman/inferno ; echo $emuargs emu -g1024x768 -c1 ; cat /dev/memory 277568 33554432 328032 3303 1490 1 33276852 main 52544 33554432 78496 1650 1271 1 33501876 heap 0 33554688 0 0 0 0 33554676 image 
As you can see (the last but one column), the default inferno uses no more than 32MB for each memory pool.
 ; cat /dev/jit 0; echo 1 >/dev/jit ; cat /dev/jit 1; echo 0 >/dev/jit ; cat /dev/jit 0; 
Although JIT can be dynamically enabled / disabled, the modified JIT value will only affect the modules (in inferno there is no difference between programs and libraries, they are all simply loadable modules) that will be loaded after this change. Therefore, it is better to specify the JIT value with the emu parameter.

/ lib / sh / profile


When an inferno starts, emuinit launched by emuinit , which in turn starts sh -l . The -l tells sh to execute commands from /lib/sh/profile . This file is analogous to the * NIX boot scripts, and that’s where we’ll add commands to configure and initialize inferno (there are no commands in this file now).

Keep in mind that if you specify the name of the application to be started with the emu parameter when you start the inferno, then the commands from /lib/sh/profile will not be executed (unless you explicitly load them). Example:
 $ emu-g ; cat /lib/sh/profile # emu sh initialisation here ; echo 'echo executing /lib/sh/profile' >> /lib/sh/profile ; shutdown -h $ emu-g executing /lib/sh/profile ; shutdown -h $ emu-g sh ; shutdown -h $ emu-g sh -l executing /lib/sh/profile ; shutdown -h $ emu-g sh -c 'run /lib/sh/profile; echo ok; shutdown -h' executing /lib/sh/profile ok 

Timezone

The current zone is determined by the file /locale/timezone , available options can be seen by viewing the names of other files in the directory /locale/ . In traditional OSs, we would simply copy the file /locale/_ over /locale/timezone . In inferno, you can also do this, but a more natural way for an inferno to change the timezone is to modify the namespace with bind (1) :
 ; date Sun Jun 17 19:00:28 BST 2012 ; bind /locale/EET /locale/timezone ; date Sun Jun 17 21:00:39 EEST 2012 
So we find our zone and add it to /lib/sh/profile :
 bind /locale/_ /locale/timezone 


/ chan

Another useful command to add to /lib/sh/profile is:
 bind -b '#s' /chan 
It connects the srv (3) driver to the / chan directory. According to the agreement adopted in the inferno, virtual files are created in this directory, the read / write of which is converted by the srv driver into messages sent via the channel to the process serving these files. Using such files (created via file2chan (2) from Limbo or file2chan (1) from sh) is the easiest way to implement a file server in inferno.

Home directory

Inferno users home directories are located in the /usr/ directory. By default, there is only one subdirectory inferno/ , which is essentially a template for creating home directories of other users. Therefore, if only your account in the main OS is not called inferno, :) then you do not yet have your home directory in inferno:
 $ emu ; pwd / ; cd cd: /usr/powerman: '/usr/powerman' does not exist ; 
The easiest way to create one is to simply copy /usr/inferno/ to /usr/__/ (in fact, this is the way to add a new user account to the inferno). But we will go the other way, in a more flexible and efficient way - as a home directory of the user, we’ll connect the user's real home directory to the main OS (and files and subdirectories from / usr / inferno / can be copied to the real home directory to the main OS).
 $ pwd /home/powerman $ emu ; mount {mntgen&} /usr ; bind -c '#U*/home/powerman' /usr/powerman ; cd ; pwd /usr/powerman 
The mntgen (4) file server is needed in order not to create directories (mount points), they will appear automatically in the directory where mntgen is connected at the moment when someone contacts them. In our case (when the Inferno OS is installed in our home directory), instead of using mntgen, it would be easy to create the directory ~/inferno/usr/powerman/ , but if the inferno was set by the root system-wide in /usr/local/inferno/ , then we would not have enough permissions to create the /usr/local/inferno/usr/powerman/ and would need root privileges to add a new user to the inferno. And mntgen allowed this problem to be solved without root and creating physical directories where you can get by with virtual ones.

For more flexibility, add support for the environment variable INFERNO_HOME - if it is not empty, then the path specified in this variable will be connected to the home directory. So, add to /lib/sh/profile :

... * NIX

 ( home unused ) := `{os sh -c 'echo $INFERNO_HOME $HOME' </dev/null} home = '#U*'^$home user := `{cat /dev/user} mount {mntgen&} /usr bind -c $home /usr/$user cd 

... Win

 home := `{os cmd /C 'IF DEFINED INFERNO_HOME ( echo %INFERNO_HOME:\=/% ) ELSE ( echo %USERPROFILE:\=/% )'} home = '#U'^$home user := `{cat /dev/user} mount {mntgen&} /usr bind -c $home /usr/$user cd 

Custom settings

The last thing that makes sense to add to /lib/sh/profile is the support for advanced user settings:
 load std and {ftest -d tmp} {bind -c tmp /tmp} and {ftest -e namespace} {nsbuild} and {ftest -e profile} {run profile} 
The std module must be loaded in order to be able to use the and command (an analogue of if-a and &&). If the user's home directory has a subdirectory tmp/ - it will be connected to the system /tmp/ (in this case, there is no special need, but if we installed the inferno in /usr/local/inferno/ system-wide, we would not have write permissions to /usr/local/inferno/tmp/ and this command would be necessary). If there are namespace and profile files in the user's home directory, they will be executed.

Download

For convenience, you can download the recommended /lib/sh/profile : * NIX , Win (do not forget to change the zone in it from GMT to yours).

GUI (wm / wm)


When you start wm / wm, it will execute /lib/wmsetup and, if there is, ./lib/wmsetup in the user's home directory. The plumber settings are in ./lib/plumbing in the user's home directory (don't forget to copy them into your home directory from /usr/inferno/ ). Right now, there is no need to set up these files, I just mentioned them just so that you know where they are and see what is in them).

Authentication Keys


The default keys will be recorded and used from the ./keyring/ subdirectory in the home directory. In the old article I have already told how authentication is arranged in the inferno , and I don’t see the point of copying all this here.

Network


In principle, it is not necessary to configure the hosted inferno network. For example, download ya.ru (by IP):
 $ emu ; webgrab -rv -o /dev/null 87.250.251.3 connecting to 87.250.251.3 writing request: GET / HTTP/1.0 Host: 87.250.251.3 User-agent: Inferno/webgrab Cache-Control: no-cache Pragma: no-cache response: HTTP/1.1 200 Ok created /dev/null, 7383 bytes 

But to support the conversion of names to IP, you need to start the ndb/cs :
 ; ndb/cs ; webgrab -rv -o /dev/null ya.ru connecting to ya.ru writing request: GET / HTTP/1.0 Host: ya.ru User-agent: Inferno/webgrab Cache-Control: no-cache Pragma: no-cache response: HTTP/1.1 200 Ok created /dev/null, 7689 bytes 

The cs (8) service uses the files /lib/ndb/common (equivalent to /etc/services in * NIX), /lib/ndb/inferno (complements /lib/ndb/common with inferno-specific ports) and /lib/ndb/local .

The /lib/ndb/local file is the main one - not only local settings are described in it, but the rest of the above mentioned files are also included. In the infernosite= section, you can configure infernosite= between short server names and their real names or IP addresses. The most commonly used short names are SIGNER and registry to indicate servers with CA (certificate authority) and registry (4) services. To connect by a short name in front of him you need to add the symbol " $ ". For example, let's add a name for Yandex:
 $ emu ; cat /lib/ndb/local ... infernosite= ... Yandex=www.yandex.ru ; ndb/cs ; webgrab -rv -o /dev/null '$Yandex' connecting to $Yandex writing request: GET / HTTP/1.0 Host: $Yandex User-agent: Inferno/webgrab Cache-Control: no-cache Pragma: no-cache response: HTTP/1.1 200 Ok created /dev/null, 7378 bytes 

The file /lib/ndb/services contains the description of inferno-specific ports in the * NIX /etc/services format. It makes sense to add it to /etc/services in the main OS so that it is more convenient to connect from the main OS to the Infernovian services:
 cat ~/inferno/lib/ndb/services | sudo bash -c 'cat >>/etc/services' 

OS Inferno Update


To update the system, you simply need to repeat the same commands that were used during the installation:

... * NIX

 cd ~/inferno hg pull -uv mk nuke mk install #       X-  GUI mk CONF=emu-g install 

... Win

Run the "Windows SDK 7.1 Command Prompt" (or "Visual Studio Command Prompt (2010)" - depending on what you installed).
 cd \inferno hg pull -uv mk nuke mk install 

Source: https://habr.com/ru/post/145986/


All Articles