]> git.ipfire.org Git - thirdparty/dracut.git/blame - init
Add the basics for LVM support
[thirdparty/dracut.git] / init
CommitLineData
ec9315e5 1#!/bin/bash
a5e56335
JK
2#
3# Licensed under the GPLv2
4#
5# Copyright 2008, Red Hat, Inc.
6# Jeremy Katz <katzj@redhat.com>
ec9315e5
JK
7
8emergency_shell()
9{
10 echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
11 echo
12 bash
13}
14trap "emergency_shell" 0 2
15
16echo "Starting initrd..."
17export PATH=/sbin:/bin:/usr/sbin:/usr/bin
18export TERM=linux
19
20# /dev/console comes from the built-in initramfs crud in the kernel
21# someday, we may need to mkdir /dev first here
22exec > /dev/console 2>&1
23
24# mount some important things
ec9315e5 25mount -t proc /proc /proc
ec9315e5
JK
26mount -t sysfs /sys /sys
27mount -t tmpfs -omode=0755 udev /dev
28
29# start up udev and trigger cold plugs
30/sbin/udevd --daemon
31/sbin/udevadm trigger
32# FIXME: should we really wait for the queue to settle or just try to
33# find the rootfs?
35c5d61b 34#/sbin/udevadm settle --timeout=30 || :
ec9315e5 35
ec9315e5 36# mount the rootfs
35c5d61b 37NEWROOT="/sysroot"
ec9315e5 38
35c5d61b
JK
39# FIXME: there's got to be a better way ...
40# it'd be nice if we had a udev rule that just did all of the bits for
41# figuring out what the specified root is and linking it /dev/root
42for o in `cat /proc/cmdline` ; do
43 case $o in
44 root=*)
45 root=${o#root=}
46 ;;
47 esac
48done
49echo -n "Going to mount rootfs ($root)"
50if [ -z "$root" ]; then
51 echo "Warning: no root specified"
52 root="/dev/sda1"
53elif [ "${root#LABEL=}" != $root ]; then
54 root="/dev/disk/by-label/${root#LABEL=}"
55elif [ "${root#UUID=}" != $root ]; then
56 root="/dev/disk/by-uuid/${root#UUID=}"
57fi
58# should we have a timeout?
59tries=0
60while [ ! -e $root ]; do
61 echo -n "."
62 sleep 1
63 tries=$(($tries + 1))
64done
65echo -e "\n\nMounted rootfs after $tries seconds"
66ln -s "$root" /dev/root
67mount -o ro -t ext3 /dev/root $NEWROOT
65e66984 68
ec9315e5
JK
69# now we need to prepare to switchroot
70mount --bind /dev $NEWROOT/dev
71
72# FIXME: now for a bunch of boiler-plate mounts. really, we should have
73# some like /etc/fstab.sys that's provided by filesystem/initscripts
74# and then do mount -f /etc/fstab.sys -a
75mount -t proc /proc $NEWROOT/proc
76mount -t sysfs /sys $NEWROOT/sys
77
78# FIXME: load selinux policy
79
35c5d61b
JK
80# kill off udev
81kill `pidof udevd`
ec9315e5
JK
82# FIXME: nash die die die
83exec /sbin/switch_root
84# davej doesn't like initrd bugs
85echo "Something went very badly wrong in the initrd. Please "
86echo "file a bug against mkinitrd."
87exit 1