Setting up MNIX

From the first boot to a system with your own account, packages and an ssh key. Each step is a few commands.

  1. What you need
  2. The first boot
  3. Install onto a hard disk
  4. The first login on the disk
  5. Users, root and sudo
  6. Network and packages
  7. Your own init.conf, new drivers
  8. ssh keys and git
  9. When something goes wrong

1. What you need

2. The first boot

Boot the floppy (download). In QEMU, with an empty hard disk image for step 3 already attached:

qemu-img create -f raw mnix-disk.img 1G
qemu-system-x86_64 -m 256 -vga std \
  -drive file=mnix-x86_64.img,format=raw,if=floppy \
  -drive file=mnix-disk.img,format=raw,if=ide,index=0 -boot a \
  -netdev user,id=net0 -device ne2k_isa,netdev=net0,iobase=0x300,irq=9

The kernel asks two kinds of questions, in its own text mode:

Then the login prompt: type root. On the floppy there is no password, because a read-only floppy has nowhere to keep one; whoever boots the floppy owns the machine anyway.

mnix login: root
Read-only system (no disk): root has no password here.
root@mnix:~#

3. Install onto a hard disk

root@mnix:~# mnix-install

It lists the disks, asks which one, and wants yes before it erases anything. It writes an 8 MB boot partition (loader, kernel, your sealed driver approvals) and an ext2 partition for /, and asks whether to keep your passphrase and approvals (say yes). The first time it also asks you to approve the disk driver.

Then boot from the disk: poweroff, and start QEMU again without the floppy, with -boot c (on a real PC, take the floppy out).

4. The first login on the disk

Type your passphrase, log in as root, and MNIX asks for what the floppy could not keep:

mnix login: root

This system has no root password yet. Choose one now: it protects
everything that needs root (sudo, su, drivers, /etc).
New password:
Retype new password:
Root has a password now.

Create an account for yourself? Name (Enter to skip): alice
Password for alice:
New password:
Retype new password:
User alice (uid 1000) created, home /home/alice.
alice may use sudo (group wheel).

Log out with exit and log in as yourself. Use root only through sudo from now on.

5. Users, root and sudo

The prompt ends in $ for you and # for root. Only root may change /etc, load or stop drivers, talk to drivers directly, install packages, bind ports below 1024 and reboot. Everybody may look: drv, ps, net, ls -l.

CommandWhat
id, whoami, groupswho you are
sudo CMD ...run CMD as root, with your own password (members of wheel)
sudo -ia root shell
su [-] [USER]become another user, with their password
passwdchange your password
sudo adduser [--admin] NAMEa new user with a home in /home; --admin: may use sudo
sudo adduser NAME wheelgive an existing user sudo (at the next login)
sudo deluser [--remove-home] NAMEremove a user
chmod, chown, chgrpmodes and owners

sudo also runs the shell's own commands, so sudo drv load /drv/rtc.drv and sudo mode 1024x768x32 work as they read. The accounts are the usual Unix files, /etc/passwd, /etc/group and /etc/shadow (readable by root only), so Linux programs find you the usual way.

6. Network and packages

The network comes up by itself (DHCP). net shows the address. Packages come from barn, over HTTPS from this site:

alice@mnix:~$ sudo barn update
alice@mnix:~$ sudo barn install busybox edit git
alice@mnix:~$ barn list

BusyBox brings ash (a full shell with pipes and &&), vi, grep, tar and the rest; edit is a small editor with nano's keys.

7. Your own init.conf, new drivers

/etc/init.conf says what starts at boot: drivers, the disk, the network, the login. To change it:

alice@mnix:~$ sudo edit /etc/init.conf

The shipped file comes from the boot area; the first save puts a copy on the disk, and from then on init reads that one once the disk is mounted. Keep the shipped lines and add yours, for example a driver from the disk:

driver   /usr/lib/drv/mycard.drv
service  /usr/bin/myserver --port 8080

At the next boot the kernel asks you to approve the new driver, at its own prompt, like the first ones. init only uses the file while root owns it and nobody else may write it or /etc; otherwise it says ignoring /etc/init.conf on the disk and boots with the shipped one.

8. ssh keys and git

alice@mnix:~$ sudo barn install git        # brings openssh along
alice@mnix:~$ ssh-keygen -t ed25519
alice@mnix:~$ cat ~/.ssh/id_ed25519.pub

Give the public key to GitHub (Settings, SSH and GPG keys) or put it into ~/.ssh/authorized_keys on another machine. Your private key stays in ~/.ssh, readable by you only; ssh refuses keys that others could read, and MNIX's permissions make sure they cannot.

alice@mnix:~$ ssh -T git@github.com
alice@mnix:~$ git config --global user.name "Alice"
alice@mnix:~$ git config --global user.email alice@example.org
alice@mnix:~$ git clone git@github.com:alice/project.git
alice@mnix:~$ git clone https://github.com/octocat/Hello-World.git

scp, sftp and ssh-keyscan come with it. Not there yet: ssh-agent and logging into MNIX over ssh.

9. When something goes wrong

More detail is in the documentation that comes with the source: docs/users.md, docs/packages.md, docs/installation.md.