1 |
Hi, |
2 |
|
3 |
on one of several machines I have a problem with initramfs. |
4 |
|
5 |
The machine has a single SATA drive. When the kernel boots it shows |
6 |
that it is called /dev/sda,.... |
7 |
Now, within the init script of my initramfs it tries to mount /dev/sda2 |
8 |
as root but fails. |
9 |
Since the initramfs spawns a shell (busybox) I can see the device files |
10 |
for /dev/sda? |
11 |
but fdisk /dev/sda fails. |
12 |
As it turns out, the harddisk is now named /dev/sdb with /dev/sdb? |
13 |
partition names. |
14 |
|
15 |
Since this setup is identical to that of several other machines where |
16 |
it just works, |
17 |
I'm puzzled. |
18 |
|
19 |
Has anybody an idea what might be going on? |
20 |
|
21 |
Many thanks, |
22 |
Helmut. |
23 |
|
24 |
This is my init script |
25 |
|
26 |
#!/bin/busybox sh |
27 |
|
28 |
rescue_shell() { |
29 |
echo "$@" |
30 |
echo "Something went wrong. Dropping you to a shell." |
31 |
busybox --install -s |
32 |
exec /bin/sh |
33 |
} |
34 |
|
35 |
uuidlabel_root() { |
36 |
for cmd in $(cat /proc/cmdline) ; do |
37 |
case $cmd in |
38 |
root=*) |
39 |
type=$(echo $cmd | cut -d= -f2) |
40 |
echo "Mounting rootfs" |
41 |
if [ $type == "LABEL" ] || [ $type == "UUID" ] ; then |
42 |
uuid=$(echo $cmd | cut -d= -f3) |
43 |
mount -o ro $(findfs "$type"="$uuid") /mnt/root |
44 |
else |
45 |
mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root |
46 |
fi |
47 |
;; |
48 |
esac |
49 |
done |
50 |
} |
51 |
|
52 |
check_filesystem() { |
53 |
# most of code coming from /etc/init.d/fsck |
54 |
|
55 |
local fsck_opts= check_extra= RC_UNAME=$(uname -s) |
56 |
|
57 |
# FIXME : get_bootparam forcefsck |
58 |
if [ -e /forcefsck ]; then |
59 |
fsck_opts="$fsck_opts -f" |
60 |
check_extra="(check forced)" |
61 |
fi |
62 |
|
63 |
echo "Checking local filesystem $check_extra : $1" |
64 |
|
65 |
if [ "$RC_UNAME" = Linux ]; then |
66 |
fsck_opts="$fsck_opts -C0 -T" |
67 |
fi |
68 |
|
69 |
trap : INT QUIT |
70 |
|
71 |
# using our own fsck, not the builtin one from busybox |
72 |
/sbin/fsck ${fsck_args--p} $fsck_opts $1 |
73 |
|
74 |
case $? in |
75 |
0) return 0;; |
76 |
1) echo "Filesystem repaired"; return 0;; |
77 |
2|3) if [ "$RC_UNAME" = Linux ]; then |
78 |
echo "Filesystem repaired, but reboot needed" |
79 |
reboot -f |
80 |
else |
81 |
rescue_shell "Filesystem still have errors; |
82 |
manual fsck required" |
83 |
fi;; |
84 |
4) if [ "$RC_UNAME" = Linux ]; then |
85 |
rescue_shell "Fileystem errors left |
86 |
uncorrected, aborting" |
87 |
else |
88 |
echo "Filesystem repaired, but reboot needed" |
89 |
reboot |
90 |
fi;; |
91 |
8) echo "Operational error"; return 0;; |
92 |
12) echo "fsck interrupted";; |
93 |
*) echo "Filesystem couldn't be fixed";; |
94 |
esac |
95 |
rescue_shell |
96 |
} |
97 |
|
98 |
# temporarily mount proc and sys |
99 |
mount -t proc none /proc |
100 |
mount -t sysfs none /sys |
101 |
|
102 |
echo /sbin/mdev > /proc/sys/kernel/hotplug |
103 |
mdev -s |
104 |
|
105 |
# only do this if you've built devtmpfs support into your kernel |
106 |
# mount -t devtmpfs none /dev HJ: done by the kernel itself |
107 |
|
108 |
# disable kernel messages from popping onto the screen |
109 |
echo 0 > /proc/sys/kernel/printk |
110 |
|
111 |
# clear the screen |
112 |
# clear |
113 |
|
114 |
|
115 |
# ====================== start doing stuff |
116 |
|
117 |
# mounting rootfs on /mnt/root |
118 |
uuidlabel_root || rescue_shell "Error with uuidlabel_root" |
119 |
|
120 |
btrfs device scan |
121 |
|
122 |
# space separated list of mountpoints that ... |
123 |
mountpoints="/usr" |
124 |
|
125 |
# ... we want to find in /etc/fstab ... |
126 |
# ln -s /mnt/root/etc/fstab /etc/fstab |
127 |
|
128 |
# ... to check filesystems and mount our devices. |
129 |
for m in $mountpoints ; do |
130 |
check_filesystem $m |
131 |
|
132 |
echo "Mounting $m" |
133 |
# mount the device and ... |
134 |
mount $m || rescue_shell "Error while mounting $m" |
135 |
|
136 |
# ... move the tree to its final location |
137 |
mount --move $m "/mnt/root"$m || rescue_shell "Error while moving |
138 |
$m" |
139 |
done |
140 |
|
141 |
echo "All done. Switching to real root." |
142 |
|
143 |
# ====================== end doing stuff |
144 |
|
145 |
mount -o remount,rw /mnt/root |
146 |
cp /proc/mounts /mnt/root/mtab |
147 |
|
148 |
# clean up. The init process will remount proc sys and dev later |
149 |
umount /proc |
150 |
umount /sys |
151 |
# umount /dev # fails, since it's automounted by the kernel |
152 |
|
153 |
# switch to the real root and execute init |
154 |
exec switch_root /mnt/root /sbin/init "$@" |