]>
git.ipfire.org Git - ipfire-3.x.git/blob - src/mkinitramfs/mkinitramfs
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008, 2009 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 .
/usr
/lib
/mkinitramfs
/functions
25 MODULES
="$MODULES ehci-hcd ohci-hcd uhci-hcd"
27 # Get rootfs and options
28 rootdev
=$
(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' /etc
/fstab
)
29 rootfs
=$
(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc
/fstab
)
30 rootopts
=$
(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc
/fstab
)
31 [ -z "$rootopts" ] && rootopts
="defaults"
33 installmodule
--load $rootfs
35 if [[ "$rootdev" =~
"^(UUID=|LABEL=)" ]]; then
36 rootdev
=$
(resolve_device_name
"$rootdev")
39 rootopts
=$
(echo $rootopts |
sed -e 's/^r[ow],//' -e 's/,_netdev//' \
40 -e 's/_netdev//' -e 's/,r[ow],$//' -e 's/,r[ow],/,/' \
41 -e 's/^r[ow]$/defaults/' -e 's/$/,ro/')
42 physdev
=$
(findblockdevinsys
"$rootdev")
43 physdev
=${physdev##*/dev/}
44 if [ -n "$physdev" ]; then
45 vecho
"[INFO] Found root device $physdev for $rootdev"
50 if [ -n "$physdev" -a "$physdev" != "$rootdev" ]; then
51 findstoragedriver
${physdev##/dev/}
54 findstoragedriver
${rootdev##/dev/}
56 cat >> sbin
/real-init
<<EOF
63 cat >> sbin
/real-init
<<'EOF'
65 # Users can override rootfs target on the kernel commandline
66 for o in $(cat /proc/cmdline); do
72 rootflags=${o#rootflags=}
75 rootfstype=${o#rootfstype=}
80 vecho "Starting udevd..."
83 vecho "Creating devices..."
86 vecho "Mounting root filesystem $rootdev..."
87 [ -n "$rootopts" ] && rootopts="-o $rootopts"
88 [ -n "$rootfstype" ] && rootopts="-t $rootfstype $rootopts"
89 mount $rootdev /sysroot $rootopts
93 vecho "Switching to new root and running init..."
94 exec switchroot $(get_verbose) /sysroot
96 echo exec switchroot failed...