# Initramfs to mount seperate /usr - fsck fails[solved]

## tenspd137

Hi all,

I have /usr on a software raid volume (raid-1) and am using the instructions found:

http://wiki.gentoo.org/wiki/Early_Userspace_Mounting

to make an initramfs image.  Since it is on raid and on a 64 bit system, I made the following changes to the initramfs_list:

```

# directory structure

dir /proc       755 0 0

dir /usr        755 0 0

dir /bin        755 0 0

dir /sys        755 0 0

dir /var        755 0 0

dir /lib64      755 0 0

dir /sbin       755 0 0

dir /mnt        755 0 0

dir /mnt/root   755 0 0

dir /etc        755 0 0

dir /root       700 0 0

dir /dev        755 0 0

# busybox

file /bin/busybox /bin/busybox 755 0 0

# libraries required by /sbin/fsck.ext4 and /sbin/fsck

file    /lib64/ld-linux-86-64.so.2 /lib64/ld-linux-x86-64.so.2           755 0 0

file    /lib64/libext2fs.so.2      /lib64/libext2fs.so.2                 755 0 0

file    /lib64/libcom_err.so.2     /lib64/libcom_err.so.2                755 0 0

file    /lib64/libpthread.so.0     /lib64/libpthread.so.0                755 0 0

file    /lib64/libblkid.so.1       /lib64/libblkid.so.1                  755 0 0

file    /lib64/libuuid.so.1        /lib64/libuuid.so.1                   755 0 0

file    /lib64/libe2p.so.2         /lib64/libe2p.so.2                    755 0 0

file    /lib64/libc.so.6           /lib64/libc.so.6                      755 0 0

file    /sbin/fsck               /sbin/fsck                          755 0 0

file    /sbin/fsck.ext4          /sbin/fsck.ext4                     755 0 0

file    /sbin/mdadm              /sbin/mdadm                         755 0 0

file    /etc/mdadm.conf          /etc/mdadm.conf                     755 0 0

# our init script

file    /init                    /usr/src/initramfs/init             755 0 0

```

mdadm is built statically, and mdadm.conf contains:

```

DEVICE /dev/sd??*

ARRAY /dev/md0 metadata=1.2 UUID=7e077f14:d2571554:76e86aaa:0f82936a

ARRAY /dev/md1 metadata=1.2 UUID=8ab8e422:94e16775:694d5652:ea676e97

ARRAY /dev/md2 metadata=1.2 UUID=a53c28ee:a118bc53:702babff:8faaef9a

ARRAY /dev/md3 metadata=1.2 UUID=f6375cf5:ddb727d4:7c356dd0:5311d16f

```

.

My init script just adds the lines:

```

...

# mounting rootfs on /mnt/root

uuidlabel_root || rescue_shell "Error with uuidlabel_root"

# mounted root, spin up raid drives using our mdadm

/sbin/mdadm --assemble --scan /dev/md1

# space separated list of mountpoints that ...

mountpoints="/usr"

# ... we want to find in /etc/fstab ...

ln -s /mnt/root/etc/fstab /etc/fstab

...

```

Because to get to /usr, I need to activate the raid volume first, which is md1 (md0 is home, md2 and 3 are other directories)  Actually, raid starts up and gives a message that md1 starts with two disks, but I have the problem everyone else seems to have with this - /sbin/fsck isn't found.  All the fixes I have read say to change /lib to /lib64 and adjust accordingly, which I have done.  Here is the output from my initramfs archive. (I named it genkernel so that grub-mkconfig -o /boot/grub2/grub.cfg would pick it up)

```

 cpio -idv < initramfs-genkernel-3.7.8                  

proc

usr

bin

sys

var

lib64

sbin

mnt

mnt/root

etc

root

dev

bin/busybox

lib64/ld-linux-86-64.so.2

lib64/libext2fs.so.2

lib64/libcom_err.so.2

lib64/libpthread.so.0

lib64/libblkid.so.1

lib64/libuuid.so.1

lib64/libe2p.so.2

lib64/libc.so.6

sbin/fsck

sbin/fsck.ext4

sbin/mdadm

etc/mdadm.conf

init

11826 blocks

```

It looks like everything is ok with that.  Can someone tell me what step I missed?  I have done this numerous times now with no luck, and the rescue shell isn't incredibly helpful (I'll need to work on that later)  It looks as though it isn't finding libraries because the static mdadm works, but I haven't got a clue why.

Thanks.Last edited by tenspd137 on Sun Feb 17, 2013 8:44 am; edited 1 time in total

----------

## netfab

Please paste output of :

```

$ ldd /sbin/fsck.ext4

$ ldd /sbin/fsck

```

----------

## NeddySeagoon

tenspd137

My initramfs_list on  /no-multilib/ reads:- 

```
# directory structure

dir /proc       755 0 0

dir /usr        755 0 0

dir /bin        755 0 0

dir /sys        755 0 0

dir /var        755 0 0

#dir /lib        755 0 0

dir /lib64      755 0 0

dir /sbin       755 0 0

dir /mnt        755 0 0

dir /mnt/root   755 0 0

dir /etc        755 0 0

dir /root       700 0 0

dir /dev        755 0 0

# busybox

file /bin/busybox /bin/busybox  755 0 0

# for raid on lvm

file /sbin/mdadm                /sbin/mdadm              755 0 0 

file /sbin/lvm.static           /sbin/lvm.static         755 0 0 

# libraries required by /sbin/fsck.ext4 and /sbin/fsck

slink   /lib                            /lib64                          777 0 0

file    /lib64/ld-linux-x86-64.so.2     /lib64/ld-linux-x86-64.so.2     755 0 0

file    /lib64/libext2fs.so.2           /lib64/libext2fs.so.2           755 0 0

file    /lib64/libcom_err.so.2          /lib64/libcom_err.so.2          755 0 0

file    /lib64/libpthread.so.0          /lib64/libpthread.so.0          755 0 0

file    /lib64/libblkid.so.1            /lib64/libblkid.so.1            755 0 0

file    /lib64/libuuid.so.1             /lib64/libuuid.so.1             755 0 0

file    /lib64/libe2p.so.2              /lib64/libe2p.so.2              755 0 0

file    /lib64/libc.so.6                /lib64/libc.so.6                755 0 0

file    /sbin/fsck              /sbin/fsck                      755 0 0

file    /sbin/fsck.ext4         /sbin/fsck.ext4                 755 0 0

# our init script

file    /init                   /root/initrd/init               755 0 0
```

Note that this does not use bb fsck.

My init script is

```
#!/bin/busybox sh

rescue_shell() {

    echo "$@"

    echo "Something went wrong. Dropping you to a shell."

    /bin/busybox --install -s

    exec /bin/sh

}

# allow the use of UUIDs or filesystem lables

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 -p $fsck_opts $1

    ret_val=$?

    #case $? in

    case $ret_val 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;;

        16)     echo "Use or Syntax Error"; return 16;;

        32)     echo "fsck interrupted";;

        127)    echo "Shared Library Error"; sleep 20; return 0;;

        *)      echo $ret_val; echo "Some random fsck error - continuing anyway"; sleep 20; return 0;;

    esac

# rescue_shell can't find tty so its broken

    rescue_shell

}

# start for real here

# temporarily mount proc and sys

mount -t proc none /proc

mount -t sysfs none /sys

mount -t devtmpfs none /dev

# assemble the raid set(s) - they got renumbered from md1, md5 and md6

# /boot

/sbin/mdadm --assemble /dev/md125 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

# don't care if /boot fails to assemble

# /  (root)  I wimped out of root on lvm for this box

/sbin/mdadm --assemble /dev/md126 /dev/sda5 /dev/sdb5 /dev/sdc5 /dev/sdd5 || rescue_shell

# if root won't assemble, we are stuck

# LVM for everything else

/sbin/mdadm --assemble /dev/md127 /dev/sda6 /dev/sdb6 /dev/sdc6 /dev/sdd6 || rescue_shell

# and if the LVM space won't assemble there is no /usr or /var so we are really in a mess

# TODO could auto cope with degraded raid operation

# lvm runs as whatever its called as

ln -s /sbin/lvm.static /sbin/vgchange

# start the vg volume group - we only have one volume group

/sbin/vgchange -ay vg || rescue_shell

# if this failed we have no /usr or /var

# get here with raid sets assembled and logical volumes available

# mounting rootfs on /mnt/root

uuidlabel_root || rescue_shell "Error with uuidlabel_root"

# space separated list of mountpoints that ...

mountpoints="/usr /var"

# ... 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

#echo $m

    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."

# clean up. The init process will remount proc sys and dev later

umount /proc

umount /sys

umount /dev

# switch to the real root and execute init

exec switch_root /mnt/root /sbin/init
```

Remove the lvm stuff as you don't need it.

I don't use an mdadm.conf anywhere - I use the UUIDs of the raid set. That is not te same as the UUID of the filesystem on the raid set.

----------

## tenspd137

@netfab -

I am on a different computer right now, but the libraries in my list match.

@neddy

After using your script, it will boot, but I still get errors about /sbin/fsck - it tells me there is a shared library error - could it be because I am running a multilib configuration?

----------

## NeddySeagoon

tenspd137,

You are missing a library for fsck from your initrd, or its in the wrong path, so its not found.

```
 $ ldd /sbin/fsck

   linux-vdso.so.1 (0x00007ffffddff000)

   libmount.so.1 => /lib64/libmount.so.1 (0x00007fc86adab000)

   libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fc86ab76000)

   libc.so.6 => /lib64/libc.so.6 (0x00007fc86a7cd000)

   /lib64/ld-linux-x86-64.so.2 (0x00007fc86afe4000)

   libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fc86a5c8000)
```

shows the libraries and paths my fsck uses.  If you get different results, you need to fix your file list.

Beware of the symlink trap.  Some of those libraries may be symlinks.  

If so, you need both the link and the real library it points to.

With the shared library error fsck does not run but it allows you to boot so you can fix it.

----------

## tenspd137

I finally found the problem - I had a typo in one of my files in the initramfs_list.  All is good (finally).

Thanks for everyone's help.

----------

## eurabilis

Hello once again friends. I followed the tutorial https://wiki.gentoo.org/wiki/Early_Userspace_Mounting but I am getting 

```
checking /usr... /sbin/fsck error while loading shared library libmount.so.1 filesystem could not be fixed. dropping you to a shell. 
```

 So after running ldd like I seen in this thread, I added this to initramfs_list.. 

```
file    /lib/libmount.so.1      /lib/libmount.so.1                  755 0 0

file    /lib/libmount.so.1.1.0  /lib/libmount.so.1.1.0              755 0 0

```

 as thats where they are. But I am still getting the error. Any help is appreciated.

So you know I am only using an initrd because of the recent news here. I dont have any special setup whatsoever and haven't needed it until now.

```
2013-09-27-initramfs-required

  Title                     Separate /usr on Linux requires initramfs

  Author                    William Hubbs <williamh@gentoo.org>

  Posted                    2013-09-27

  Revision                  1

Linux systems which have / and /usr on separate file systems but do not

use an initramfs will not be supported starting on 01-Nov-2013.

If you have / and /usr on separate file systems and you are not

currently using an initramfs, you must set one up before this date.

Otherwise, at some point on or after this date, upgrading packages

will make your system unbootable.

For more information on setting up an initramfs, see this URL:

https://wiki.gentoo.org/wiki/Initramfs/HOWTO

```

I do have / and /usr on seperate partitions.

----------

## 188562

 *tenspd137 wrote:*   

> Hi all,
> 
> I have /usr on a software raid volume (raid-1) and am using the instructions found:
> 
> http://wiki.gentoo.org/wiki/Early_Userspace_Mounting
> ...

 

Try it initramfs

----------

## netfab

@eurabilis : please paste your emerge --info and your initramfs_list file.

----------

## eurabilis

```
gentoo mike # emerge --info

Portage 2.2.1 (default/linux/x86/13.0/desktop/kde, gcc-4.6.3, glibc-2.15-r3, 3.10.9 i686)

=================================================================

System uname: Linux-3.10.9-i686-Intel-R-_Pentium-R-_4_CPU_2.80GHz-with-gentoo-2.2

KiB Mem:     1027288 total,    259732 free

KiB Swap:     489944 total,    489944 free

Timestamp of tree: Sun, 29 Sep 2013 01:45:01 +0000

ld GNU ld (GNU Binutils) 2.23.1

app-shells/bash:          4.2_p45

dev-lang/python:          2.7.5-r2, 3.2.5-r2

dev-util/cmake:           2.8.10.2-r2

dev-util/pkgconfig:       0.28

sys-apps/baselayout:      2.2

sys-apps/openrc:          0.11.8

sys-apps/sandbox:         2.6-r1

sys-devel/autoconf:       2.13, 2.69

sys-devel/automake:       1.11.6, 1.12.6, 1.13.4

sys-devel/binutils:       2.23.1

sys-devel/gcc:            4.6.3

sys-devel/gcc-config:     1.7.3

sys-devel/libtool:        2.4.2

sys-devel/make:           3.82-r4

sys-kernel/linux-headers: 3.9 (virtual/os-headers)

sys-libs/glibc:           2.15-r3

Repositories: gentoo proaudio

ACCEPT_KEYWORDS="x86"

ACCEPT_LICENSE="*"

CBUILD="i486-pc-linux-gnu"

CFLAGS="-O2 -march=i486 -pipe"

CHOST="i486-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-O2 -march=i486 -pipe"

DISTDIR="/usr/portage/distfiles"

FCFLAGS="-O2 -march=i686 -pipe"

FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"                                             

FFLAGS="-O2 -march=i686 -pipe"                                                                                                                                

GENTOO_MIRRORS="http://mirrors.rit.edu/gentoo/"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/var/lib/layman/pro-audio"

SYNC="rsync://rsync5.us.gentoo.org/gentoo-portage"

USE="X a52 aac acl acpi alsa apache2 berkdb bindist bluetooth branding bzip2 cairo cdda cdr cgi cleartype cli consolekit corefonts cracklib crypt curl cxx dbus declarative device-mapper dri dri2 dts dvd dvdr emboss emerald encode evdev exif extras fam fbcondecor firefox flac fortran ftp gd gdbm gif git gnutls gpm hal hash iconv innodb jpeg kde kdrive kipi lcms ldap libnotify mad mbox mng modules mp3 mp4 mpeg mudflap mysql mysqli ncurses nls nptl ogg opengl openmp pam pango pcre pdf pdo phonon php plasma png policykit ppds pulseaudio qt3support qt4 radeon readline samba sdl secure-delete semantic-desktop session simplexml sip soap spell sqlite ssl startup-notification static-libs subversion suhosin svg tcpd threads tidy tiff truetype type1 udev udisks unicode upower usb vorbis wav wxwidgets x264 x86 xcb xcomposite xinerama xml xml2 xscreensaver xv xvid zip zlib" ABI_X86="32" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby19 ruby18" USERLAND="GNU" VIDEO_CARDS="radeon vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

gentoo mike # 

```

```
gentoo initramfs # more *list*

# directory structure

dir /proc       755 0 0

dir /usr        755 0 0

dir /bin        755 0 0

dir /sys        755 0 0

dir /var        755 0 0

dir /lib        755 0 0

dir /sbin       755 0 0

dir /mnt        755 0 0

dir /mnt/root   755 0 0

dir /etc        755 0 0

dir /root       700 0 0

dir /dev        755 0 0

# busybox

file /bin/busybox /bin/busybox 755 0 0

# libraries required by /sbin/fsck.ext4 and /sbin/fsck

file    /lib/libmount.so.1      /lib/libmount.so.1                  755 0 0

file    /lib/libmount.so.1.1.0  /lib/libmount.so.1.1.0              755 0 0

file    /lib/ld-linux.so.2      /lib/ld-linux.so.2                  755 0 0

file    /lib/libext2fs.so.2     /lib/libext2fs.so.2                 755 0 0

file    /lib/libcom_err.so.2    /lib/libcom_err.so.2                755 0 0

file    /lib/libpthread.so.0    /lib/libpthread.so.0                755 0 0

file    /lib/libblkid.so.1      /lib/libblkid.so.1                  755 0 0

file    /lib/libuuid.so.1       /lib/libuuid.so.1                   755 0 0

file    /lib/libe2p.so.2        /lib/libe2p.so.2                    755 0 0

file    /lib/libc.so.6          /lib/libc.so.6                      755 0 0

file    /sbin/fsck              /sbin/fsck                          755 0 0

file    /sbin/fsck.ext4         /sbin/fsck.ext4                     755 0 0

# our init script

file    /init                   /usr/src/initramfs/init             755 0 0

gentoo initramfs # 

```

I added these two lines myself should I remove them.

```
file    /lib/libmount.so.1      /lib/libmount.so.1                  755 0 0

file    /lib/libmount.so.1.1.0  /lib/libmount.so.1.1.0              755 0 0
```

Thanks.

----------

## eurabilis

Bump

----------

## eurabilis

Can someone help me out im stuck.

----------

