As seen in chapter two, the make install
of busybox
has created some directories containing dozens of symlinks. We've
only created two directories: /dev/pts and /proc.
Now, it's time to set up all the other needed directories.
$ cd /home/christian/Dreamcast $ cd INITRD $ ls bin dev etc linuxrc proc sbin usr $
The Filesystem Hierarchy Standard proposes the following directories:
/bin
Essential user command binaries (for use by all users). For example,
our /bin
contains cp
, df
, rm
,...
/boot
Static files of the boot loader. We don't need this
directory due to the use of a sh-specific, external bootloader.
/dev
Device files. Here, we create all device nodes, we need to
communicate with the kernel.
/etc
Host-specific system configuration. This folder will contain
the configuration files, such as passwd
, inittab
among others.
/home
User home directories (optional). We'll create this directory
"on the fly", i.e. if the user plugs in the VMU.
/lib
Essential shared libraries and kernel modules. This directory
will only contain the kernel modules caused by the lack of a dynamic loader
for dynamic libraries.
/mnt
Mount point for a temporarily mounted filesystem. We need this
folder for mounting the VMU.
/opt
Add-on application software packages. We don't need this folder.
/root
Home directory for the root user (optional). We create this directory
for the super user.
/sbin
System binaries. This directory contains essential system software,
such as insmod
, ifconfig
and others.
/tmp
Temporary files.
/usr/bin
Most user commands. This Folder contains cut
, du
,...
/usr/sbin
Non-essential standard system binaries. This folder will
contain sshd
and other service tools.
/var/lib
Variable state information. This directory will contain
files about DHCP.
/var/log
Log files and directories. This folder contains logging
information.
/var/run
Run-time variable data. Here, some process create some kind
of "cookies", often their process id.
As you notice, we don't cover all proposed directories due to the limited amount of free inodes.
Let's go and create all needed directories and configuration files.
Remember, that you've chown
'ed all files to the super user, so
change your user userid to the super user:
$ su #
/dev
First, we create the device nodes and set up their mode and ownership:
# cd dev # chmod 600 console # chown 0.1 console # mknod gdrom0 b 250 0 # chmod 640 gdrom0 # chown 0.2 gdrom0 # mknod mtdblock0 b 31 0 # chmod 660 mtdblock0 # chown 0.2 mtdblock0 # mknod null c 1 3 # chmod 666 null # chown 0.0 null # mknod ppp c 108 0 # chmod 660 ppp # chown 0.3 ppp # mknod ptmx c 5 2 # chmod 666 ptmx # chown 0.1 ptmx # mknod random c 1 8 # chmod 666 random # chown 0.0 random # mknod tty c 5 0 # chmod 600 tty # chown 0.0 tty # mknod tty0 c 4 0 # chmod 600 tty0 # chown 0.0 tty0 # mknod tty1 c 4 1 # chmod 600 tty1 # chown 0.0 tty1 # mknod tty2 c 4 2 # chmod 600 tty2 # chown 0.0 tty2 # mknod tty3 c 4 3 # chmod 600 tty3 # chown 0.0 tty3 # mknod tty4 c 4 4 # chmod 600 tty4 # chown 0.0 tty4 # mknod ttySC0 c 204 8 # chmod 600 ttySC0 # chown 0.3 ttySC0 # mknod ttySC1 c 204 9 # chmod 600 ttySC1 # chown 0.3 ttySC1 # mknod urandom c 1 9 # chmod 444 urandom # chown 0.0 urandom # mknod zero c 1 5 # chmod 666 zero # chown 0.0 zero # cd ..
As you notice, we've set different group ids. These ids have to
correspond with our entries in /etc/group
later.
/etc
This directory comprises the configuration files. So, be careful with your entries and chmodes!
# cd etc # cat <<. >group root:x:0: tty:x:1: disk:x:2: dip:x:3: shadow:x:4: . # chmod 644 group # cat <<. >gshadow root:*:: tty:!:: disk:!:: dip:!:: shadow:!:: . # chmod 640 gshadow # chown 0.4 gshadow # cat <<. >hosts 127.0.0.1 localhost 192.168.1.1 dreamcast.localdomain dreamcast . # chmod 640 hosts # mkdir init.d # cd init.d cat <<. > rcS #!/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin echo "Mounting /proc filesystem..." mount -t proc none /proc echo "Mounting /dev/pts filesystem..." mount -t devpts none /dev/pts echo "Loading eth0 module..." modprobe lan_adapter modprobe mii modprobe 8139too echo "Loading mtd modules..." modprobe mtdcore 2>&1 > /dev/null modprobe mtdblock 2>&1 > /dev/null modprobe chipreg 2>&1 > /dev/null modprobe vmu-flash 2>&1 > /dev/null echo "Loading netfilter modules..." for mod in ip_conntrack ip_conntrack_ftp \ ip_conntrack_irc ip_tables iptable_filter \ iptable_nat ipt_limit ipt_state ip_nat_ftp \ ip_nat_irc ipt_LOG ipt_MASQUERADE; do modprobe $mod 2>&1 > /dev/null done echo "Setting up routing..." iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE echo 1 > /proc/sys/net/ipv4/ip_forward echo "Setting hostname..." hostname dreamcast echo "Configuring lo..." ifconfig lo 127.0.0.1 up echo "Configuring eth0..." ifconfig eth0 192.168.1.1 up echo "Starting klogd..." klogd echo "Starting syslogd..." syslogd #echo "Starting udhcpd..." #udhcpd #echo "Starting yaku-ns..." #/usr/yaku-ns/yaku-ns -c \ # /usr/yaku-ns/yaku-ns.conf -l \ # /usr/yaku-ns/yaku-ns.log -u yaku -d #echo "Starting sshd..." #sshd -f /etc/ssh/sshd_config /bin/sleep 1 echo "Everything's done. Have fun." . # chmod 744 rcS
The file /etc/init.d/rcS
starts all initial services. As you notice, some
services are disabled by #
because we haven't compiled them yet.
# cd .. # cat <<. >inittab # Initial startup file ::once:/etc/init.d/rcS # Start four ask first login prompts tty1::askfirst:/bin/login tty2::askfirst:/bin/login tty3::askfirst:/bin/login tty4::askfirst:/bin/login ::ctrlaltdel:/sbin/reboot . # chmod 644 inittab # cat <<. >passwd root:x:0:0:root:/root:/bin/sh . # chmod 644 passwd # cat <<. >shadow root:*:12091:0:99999:7::: nobody:*:12091:0:99999:7::: . # chmod 640 shadow # chown 0.4 shadow
The shadow
and passwd
contain the usernames and passwords.
If you need the same usernames and passwords like your host, just copy
the files /etc/passwd
, /etc/shadow
, /etc/gshadow
and
/etc/group
to your initial ramdisk.
# mkdir ppp # touch resolv.conf # chmod 644 resolv.conf # cat <<. >services tcpmux 1/tcp # TCP port service multiplexer echo 7/tcp echo 7/udp ftp-data 20/tcp ftp 21/tcp fsp 21/udp fspd ssh 22/tcp # SSH Remote Login Protocol ssh 22/udp # SSH Remote Login Protocol telnet 23/tcp smtp 25/tcp mail domain 53/tcp nameserver # name-domain server domain 53/udp nameserver www 80/tcp http # WorldWideWeb HTTP www 80/udp # HyperText Transfer Protocol pop3 110/tcp pop-3 # POP version 3 pop3 110/udp pop-3 ntp 123/tcp ntp 123/udp # Network Time Protocol . # chmod 644 services # mkdir ssh # cd ..
Now, you have a correct configure /etc
- directory.
/home
# mkdir /home
/mnt
# mkdir /mnt
/root
# mkdir root # chmod 700 root
/tmp
# mkdir /tmp
/var/lib
# mkdir -p /var/lib
/var/log
# mkdir /var/log
/var/run
# mkdir /var/run
Now, you've got a proper set up initial ramdisk directory layout.