view sources/native/sbin/ @ 741:1b6acc6cf349

We already added an /etc/resolv.conf with the qemu default value, so don't have overwrite it (which outputs an error message on read only filesystems).
author Rob Landley <>
date Sun, 31 May 2009 02:35:41 -0500
parents 78cbd428d60e
children db06a8c1bfed
line wrap: on
line source


# If you're doing a Linux From Scratch build, the /tools directory is
# sufficient.  (Start by installing kernel headers and building a C library.)

# Otherwise, building source packages wants things like /bin/bash and
# running the results wants /lib/, so set up some directories
# and symlinks to let you easily compile source packages.

# Add /tools to $PATH if it's not there

if [ -d tools/bin ] && [ -z "$(echo :$PATH | tools/bin/grep :/tools/bin)" ]
  [ -z "$PATH" ] && PATH=/tools/bin || PATH="$PATH":/tools/bin
  export PATH
export HOME=/home

# Create some temporary directories at the root level
mkdir -p  proc sys dev etc tmp home
[ ! -e bin ] && ln -s tools/bin bin
[ ! -e lib ] && ln -s tools/lib lib
[ ! -e usr ] && ln -s tools usr

# Populate /dev
mountpoint -q sys || mount -t sysfs sys sys
mountpoint -q dev || mount -t tmpfs -o noatime dev dev
mdev -s

# Mount /proc is there
mountpoint -q proc || mount -t proc proc proc

# If we're running under qemu, do some more setup
if [ $$ -eq 1 ]

  # Note that forwards to on the host.

  # Setup networking for QEMU (needs /proc)
  ifconfig eth0
  route add default gw

  # If we have no RTC, try rdate instead:
  [ `date +%s` -lt 1000 ] && rdate # or

  # If there's a /dev/hdb or /dev/sdb, mount it on home

  [ -b /dev/hdb ] && HOMEDEV=/dev/hdb
  [ -b /dev/sdb ] && HOMEDEV=/dev/sdb
  if [ ! -z "$HOMEDEV" ]
    mount -o noatime $HOMEDEV /home

  mount -o noatime -t tmpfs /tmp /tmp

  echo Type exit when done.
  exec /tools/bin/oneit -c /dev/"$(dmesg | sed -n '/^Kernel command line:/s@.* console=\(/dev/\)*\([^ ]*\).*@\2@p')" /tools/bin/ash

# If we're not PID 1, it's probably a chroot.
  echo "nameserver" > /etc/resolv.conf

  # Switch to a shell with command history.

  echo Type exit when done.
  cd /
  umount ./dev
  umount ./home
  umount ./sys
  umount ./proc