public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] hard disk name changes within initramfs
@ 2012-12-06 14:22 Helmut Jarausch
  2012-12-06 14:31 ` Todd Goodman
  2012-12-06 16:55 ` J. Roeleveld
  0 siblings, 2 replies; 6+ messages in thread
From: Helmut Jarausch @ 2012-12-06 14:22 UTC (permalink / raw
  To: gentoo-user

Hi,

on one of several machines I have a problem with initramfs.

The machine has a single SATA drive. When the kernel boots it shows  
that it is called /dev/sda,....
Now, within the init script of my initramfs it tries to mount /dev/sda2  
as root but fails.
Since the initramfs spawns a shell (busybox) I can see the device files  
for /dev/sda?
but fdisk /dev/sda fails.
As it turns out, the harddisk is now named /dev/sdb with /dev/sdb?  
partition names.

Since this setup is identical to that of several other machines where  
it just works,
I'm puzzled.

Has anybody an idea what might be going on?

Many thanks,
Helmut.

This is my init script

#!/bin/busybox sh

rescue_shell() {
     echo "$@"
     echo "Something went wrong. Dropping you to a shell."
     busybox --install -s
     exec /bin/sh
}​

uuidlabel_root() {
     for cmd in $(cat /proc/cmdline) ; do
         case $cmd in
         root=*)
             type=$(echo $cmd | cut -d= -f2)
             echo "Mounting rootfs"
             if [ $type == "LABEL" ] || [ $type == "UUID" ] ; then
                 uuid=$(echo $cmd | cut -d= -f3)
                 mount -o ro $(findfs "$type"="$uuid") /mnt/root
             else
                 mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root
             fi
             ;;
         esac
     done
}​

check_filesystem() {
     # most of code coming from /etc/init.d/fsck

     local fsck_opts= check_extra= RC_UNAME=$(uname -s)

     # FIXME : get_bootparam forcefsck
     if [ -e /forcefsck ]; then
         fsck_opts="$fsck_opts -f"
         check_extra="(check forced)"
     fi

     echo "Checking local filesystem $check_extra : $1"

     if [ "$RC_UNAME" = Linux ]; then
         fsck_opts="$fsck_opts -C0 -T"
     fi

     trap : INT QUIT

     # using our own fsck, not the builtin one from busybox
     /sbin/fsck ${fsck_args--p} $fsck_opts $1

     case $? in
         0)      return 0;;
         1)      echo "Filesystem repaired"; return 0;;
         2|3)    if [ "$RC_UNAME" = Linux ]; then
                         echo "Filesystem repaired, but reboot needed"
                         reboot -f
                 else
                         rescue_shell "Filesystem still have errors;  
manual fsck required"
                 fi;;
         4)      if [ "$RC_UNAME" = Linux ]; then
                         rescue_shell "Fileystem errors left  
uncorrected, aborting"
                 else
                         echo "Filesystem repaired, but reboot needed"
                         reboot
                 fi;;
         8)      echo "Operational error"; return 0;;
         12)     echo "fsck interrupted";;
         *)      echo "Filesystem couldn't be fixed";;
     esac
     rescue_shell
}​

# temporarily mount proc and sys
mount -t proc none /proc
mount -t sysfs none /sys

echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

# only do this if you've built devtmpfs support into your kernel
# mount -t devtmpfs none /dev  HJ: done by the kernel itself

# disable kernel messages from popping onto the screen
echo 0 > /proc/sys/kernel/printk

# clear the screen
# clear


# ====================== start doing stuff

# mounting rootfs on /mnt/root
uuidlabel_root || rescue_shell "Error with uuidlabel_root"

btrfs device scan

# space separated list of mountpoints that ...
mountpoints="/usr"

# ... we want to find in /etc/fstab ...
# ln -s /mnt/root/etc/fstab /etc/fstab

# ... to check filesystems and mount our devices.
for m in $mountpoints ; do
     check_filesystem $m

     echo "Mounting $m"
     # mount the device and ...
     mount $m || rescue_shell "Error while mounting $m"

     # ... move the tree to its final location
     mount --move $m "/mnt/root"$m || rescue_shell "Error while moving  
$m"
done

echo "All done. Switching to real root."

# ====================== end doing stuff

mount -o remount,rw /mnt/root
cp /proc/mounts /mnt/root/mtab

# clean up. The init process will remount proc sys and dev later
umount /proc
umount /sys
# umount /dev   # fails, since it's automounted by the kernel

# switch to the real root and execute init
exec switch_root /mnt/root /sbin/init "$@"


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-12-10 13:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <kdKCB-3q5-1@gated-at.bofh.it>
     [not found] ` <kdKMh-3zn-1@gated-at.bofh.it>
2012-12-10 13:29   ` [gentoo-user] hard disk name changes within initramfs Gregory Shearman
2012-12-06 14:22 Helmut Jarausch
2012-12-06 14:31 ` Todd Goodman
2012-12-06 15:54   ` Paul Hartman
2012-12-06 16:55 ` J. Roeleveld
2012-12-06 18:05   ` Helmut Jarausch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox