@@ -230,13 +230,15 @@ absolute path, but they work just fine from within the booted system.
230
230
231
231
Lastly, we' ll copy some files from ``../filesystem`` to the image that will be
232
232
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.
240
242
241
243
The Boot Loader
242
244
---------------
@@ -339,14 +341,13 @@ is not just a number and has some special implications for this process. The
339
341
most important thing to note is that when this process ends, you' ll end up with
340
342
a kernel panic. PID 1 can never ever die or exit during the entire runtime of
341
343
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
343
345
will become the parent process.
344
346
345
347
This implies that PID 1 has a special role to fill in our operating system.
346
348
Namely that of starting everything, keeping everything running, and shutting
347
349
everything down because it' s the first and last process to live.
348
350
349
- % TODO better init intro
350
351
This also makes this ` ` init` ` process very suitable to start and manage services
351
352
as is the case with the very common ` ` sysvinit` ` and the more modern
352
353
` ` systemd` ` . But this isn' t strictly necessary and some other process can cary
@@ -366,7 +367,12 @@ $ mount / -o remount,rw
366
367
``busybox`` provides only two ways of editing files: ``vi`` and ``ed``. If you
367
368
are not confortable using either of those you could always shutdown the VM,
368
369
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.
370
376
371
377
First, we' ll create a script that handles the initialisation of the system
372
378
itself like mounting filesystems and configuring devices, etc. I called it
@@ -412,6 +418,9 @@ echo /sbin/mdev > /proc/sys/kernel/hotplug
412
418
# make local network connections
413
419
ip link set up dev lo
414
420
421
+ # you could add the following to change the keyboard layout at boot
422
+ loadkmap < /usr/share/keymaps/be-latin1.bmap
423
+
415
424
# mounts all filesystems in /etc/fstab
416
425
mount -a
417
426
# 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
448
457
figure out what the console is. And the ` ` -` ` infront of ` ` -/bin/sh` ` means that
449
458
the shell is started as a login shell. ` ` /bin/login` ` usually does this for us
450
459
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` ` .
452
462
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` `
454
464
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:
457
470
```bash
458
471
$ exec init
459
472
```
460
473
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.
462
476
463
477
The root password should be empty so it should only ask for a username.
464
478
0 commit comments