next up previous contents index
Next: Where are we? Up: Setting up an initial Previous: Setting up an initial   Contents   Index


Directory structure

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:

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
#

  1. /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.

  2. /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.

  3. /home

    # mkdir /home

  4. /mnt

    # mkdir /mnt

  5. /root

    # mkdir root
    # chmod 700 root
    

  6. /tmp

    # mkdir /tmp

  7. /var/lib

    # mkdir -p /var/lib

  8. /var/log

    # mkdir /var/log

  9. /var/run

    # mkdir /var/run

Now, you've got a proper set up initial ramdisk directory layout.


next up previous contents index
Next: Where are we? Up: Setting up an initial Previous: Setting up an initial   Contents   Index
Christian Berger 2004-10-19