8000 init done · codebug8/build-linux@42bbfcf · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

8000
Appearance settings

Commit 42bbfcf

Browse files
init done
1 parent 93d532c commit 42bbfcf

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,15 @@ absolute path, but they work just fine from within the booted system.
230230
231231
Lastly, we'll copy some files from ``../filesystem`` to the image that will be
232232
some use to us later.
233-
234-
* ``passwd`` that contains information about users
235-
236-
* ``shadow`` that contains the hashed passwords of the users. It is best to
237-
``chmod 600`` the file so normal users can't read it.
238-
239-
* ``fstab`` where
233+
```bash
234+
$ cp ../filesystem/{passwd,shadow,group,issue,profile,locale.sh,hosts,fstab} etc
235+
$ install -Dm755 ../filesystem/simple.script usr/share/udhcpc/default.script
236+
# optional
237+
$ install -Dm644 ../filesystem/be-latin1.bmap usr/share/keymaps/be-latin1.bmap
238+
```
239+
These are the basic configuration files for a UNIX system. The .script file is
240+
required for running a dhcp client, which we'll get to later. The keymap file is
241+
a binary keymap file for belgian azerty I use.
240242
241243
The Boot Loader
242244
---------------
@@ -339,14 +341,13 @@ is not just a number and has some special implications for this process. The
339341
most important thing to note is that when this process ends, you'll end up with
340342
a kernel panic. PID 1 can never ever die or exit during the entire runtime of
341343
your system. A second and less important consequence of being PID 1 is when
342-
another process 'reparents' like when a process forks to the background PID 1
344+
another process 'reparents' e.g. when a process forks to the background PID 1
343345
will become the parent process.
344346
345347
This implies that PID 1 has a special role to fill in our operating system.
346348
Namely that of starting everything, keeping everything running, and shutting
347349
everything down because it's the first and last process to live.
348350
349-
% TODO better init intro
350351
This also makes this ``init`` process very suitable to start and manage services
351352
as is the case with the very common ``sysvinit`` and the more modern
352353
``systemd``. But this isn't strictly necessary and some other process can cary
@@ -366,7 +367,12 @@ $ mount / -o remount,rw
366367
``busybox`` provides only two ways of editing files: ``vi`` and ``ed``. If you
367368
are not confortable using either of those you could always shutdown the VM,
368369
mount the image again, and use your favorite text editor on your host machine.
369-
% TODO keymap
370+
371+
If you don't use an qwerty keyboard you might have noticed that the VM uses a
372+
qwerty layout which is the default, you might want to change it to azerty with
373+
``loadkmap < /usr/share/keymaps/be-latin1.bmap``. You can dump the layout you
374+
are using on your host machine with ``busybox dumpkmap > keymap.bmap`` in a
375+
virtual console (not in X) and put this on your image instead.
370376
371377
First, we'll create a script that handles the initialisation of the system
372378
itself like mounting filesystems and configuring devices, etc. I called it
@@ -412,6 +418,9 @@ echo /sbin/mdev > /proc/sys/kernel/hotplug
412418
# make local network connections
413419
ip link set up dev lo
414420
421+
# you could add the following to change the keyboard layout at boot
422+
loadkmap < /usr/share/keymaps/be-latin1.bmap
423+
415424
# mounts all filesystems in /etc/fstab
416425
mount -a
417426
# make the root writable if this hasn't been done already
@@ -448,17 +457,22 @@ of the ``getty``'s do ``::askfirst:-/bin/sh``. ``askfirst`` does the same as
448457
figure out what the console is. And the ``-`` infront of ``-/bin/sh`` means that
449458
the shell is started as a login shell. ``/bin/login`` usually does this for us
450459
but we have to specify it here. Starting the shell as a login shell means that
451-
it configures certain things it otherwise assumes already to be configured.
460+
it configures certain things it otherwise assumes already to be configured. E.g.
461+
it sources ``/etc/profile``.
452462
453-
We can you start our system with ``init``. You can remove the ``init=/bin/sh``
463+
We can now start our system with ``init``. You can remove the ``init=/bin/sh``
454464
entry in ``/boot/grub/grub.cfg`` because it defaults to ``/sbin/init``. And if
455-
you reboot the system you should see a login screen. Instead of rebooting, you
456-
could also do
465+
you reboot the system you should see a login screen. But if you run ``reboot``,
466+
you'll notice it won't do anything. This happens because normally ``reboot``
467+
tells the running ``init`` to reboot. You know, the ``init`` that isn't running
468+
right now. So we have two options, we could run ``reboot -f`` which skips the
469+
``init``, or we could do this:
457470
```bash
458471
$ exec init
459472
```
460473
Because the shell we are currently using is PID 1 and you could just replace the
461-
shell process with ``init``
474+
shell process with ``init`` and our system should be properly booted now
475+
presenting you a login prompt.
462476
463477
The root password should be empty so it should only ask for a username.
464478

0 commit comments

Comments
 (0)
0