# initramfs mount /usr [SOLVED]

## LJM9000

Since recently upgrading udev I have been getting the alsactl error and some of my hardware not working correctly.

I tracked the issue down to the fact that I have /usr on a seperate partition. After doing some research it looks like the issue isn't going away anytime soon and the best way to fix it is to make an initramfs and mount /usr right after mounting /. 

I have tried every variation I can think of and am still unsuccessful and getting it to boot correctly. Currently the error I am getting is that is cannot find /etc/fstab

Here is my conf

```
#!/bin/busybox sh

# Mount the /proc and /sys filesystems.

mount -t proc none /proc

mount -t sysfs none /sys

mount -t devtmpfs none /dev

# Do your stuff here.

rescue_shell()

{

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

  busybox --install -s

  exec /bin/sh

}

# Mount the root filesystem.

lvm vgsan --mknodes

lvm lvchange -aly vg/usr

mount -t ext4 -o ro /dev/sda2 /mnt/root || rescue_shell

sleep 2

mount -t ext4 -ro /dev/vg/usr /mnt/root/usr || rescue_shell

sleep 2

# Clean up.

umount /proc

umount /sys

umount /dev

# Boot the real thing.

exec switch_root /mnt/root /sbin/init

```

Relevant configuration info from /etc/fstab

```

/dev/sda1   /boot        ext2   defaults,noatime        1 2

/dev/sda2   /            ext4   defaults,noatime        0 1

#Logical volumes

/dev/vg/usr     /usr     ext4   defaults,noatime        0 2

/dev/vg/portage /usr/portage    reiserfs        noatime,notail  0 2

/dev/vg/distfiles       /usr/portage/distfiles  ext4    defaults,noatime       0 2

/dev/vg/opt     /opt    ext4    defaults,noatime        0 2

/dev/vg/var     /var    reiserfs        noatime,notail  0 2

/dev/vg/tmp     /tmp    reiserfs        noatime,notail  0 2

/dev/vg/home    /home   ext4    defaults,noatime        0 2

```

Any help is appreciated.Last edited by LJM9000 on Tue Feb 14, 2012 3:05 am; edited 1 time in total

----------

## Hu

Please show the actual error message.  Also, I do not think that /dev/vg/usr is a valid mount option to ext4.

----------

## keenblade

How do you create initramfs? I have a a seperate /usr, too. And my gentoo boots fine with an initramfs created by dracut.

The latest way is to use sys-kernel/dracut. Edit /etc/dracut.conf for a seperate /usr like this:

```

cat /etc/dracut.conf

add_dracutmodules+="usrmount"

```

This will create an initramfs in your /boot:

```

dracut /boot/initramfs-x86_64-3.2.5-gentoo.img 3.2.5-gentoo

```

Also for a different approach,  take a look at the thread called  HOWTO: udev with separate /usr and no initramfs

----------

## LJM9000

I fixed the typo in the init script and am getting a little different results.

The error I am getting is the following

```
mount: mounting /dev/vg/usr on /mnt/root/usr failed: No such file or directory
```

Once it drops me into the rescue shell if I type out the commands by hand it works.

Here is the init I am using now.

```
#!/bin/busybox sh

# Mount the /proc and /sys filesystems.

mount -t proc none /proc

mount -t sysfs none /sys

mount -t devtmpfs none /dev

# Do your stuff here.

rescue_shell()

{

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

  busybox --install -s

  exec /bin/sh

}

# Mount the root filesystem.

mount -t ext4 -o ro /dev/sda2 /mnt/root || rescue_shell

lvm vgscan --mknodes

sleep 1

lvm lvchange -aly vg/usr

sleep 1

mount -o ro /dev/vg/usr /mnt/root/usr || rescue_shell

sleep 2

# Clean up.

umount /proc

umount /sys

umount /dev

# Boot the real thing.

exec switch_root /mnt/root /sbin/init

```

----------

## Hu

If you are sure you are typing exactly the same command as shown in the script, I suggest modifying the script so that, immediately before running mount, it prints the output of ls -la /dev/vg/ /mnt/root/.

----------

## LJM9000

Thanks Hu for the tip! Turns out that the nodes werent being created in /dev/vg when the commands were run manually, but when run from init they were being created in /dev/mapper/

Here is the final script I am using in case this helps someone else.

```

#!/bin/busybox sh

# Mount the /proc and /sys filesystems.

mount -t proc none /proc

mount -t sysfs none /sys

mount -t devtmpfs none /dev

# Do your stuff here.

remote_rescue_shell()

{

  # Bring up network interface

  ifconfig eth0 192.168.1.105 up

  # telnetd requires devpts

  mkdir -p /dev/pts

  mount -t devpts none /dev/pts

  # Start the telnet server

  telnetd

  # Continue with the local rescue shell

  rescue_shell

}

rescue_shell()

{

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

  busybox --install -s

  exec /bin/sh

}

# Mount the root filesystem.

mount -t ext4 -o ro /dev/sda2 /mnt/root || remote_rescue_shell

lvm vgscan --mknodes

lvm lvchange -ay /dev/vg

mount -o ro /dev/mapper/vg-usr /mnt/root/usr || rescue_shell

# Clean up.

umount /proc

umount /sys

umount /dev

# Boot the real thing.

exec switch_root /mnt/root /sbin/init

```

----------

## vroomanj

 *LJM9000 wrote:*   

> Thanks Hu for the tip! Turns out that the nodes werent being created in /dev/vg when the commands were run manually, but when run from init they were being created in /dev/mapper/
> 
> Here is the final script I am using in case this helps someone else.
> 
> 

 

I would be interested in knowing what you all had to copy into your initramfs folder in terms of libraries and the like. Is everything you need for /bin/sh, mount, mkdir, telnetd, etc. all included in busybox?

----------

## frostschutz

Busybox offers quite a lot. Incomplete list (you see this also when you type 'busybox' in console:

It's more than enough for initramfs needs usually, apart from some special areas (mdadm, lvm, cryptsetup).

```

   [, [[, acpid, addgroup, adduser, adjtimex, ar, arp, arping, ash, awk, base64, basename, bb, bbconfig, bbsh, blkid, blockdev, brctl, bunzip2, bzcat, bzip2, cal, cat, catv,

   chat, chattr, chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, conspy, cp, cpio, crond, cryptpw, cttyhack, cut, date, dd, deallocvt,

   delgroup, deluser, depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsdomainname, dos2unix, du, dumpkmap, dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid,

   ether-wake, expand, expr, false, fbset, fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flash_eraseall, flash_lock, flash_unlock, flashcp, flock, free, freeramdisk,

   fsck, fsync, ftpd, fuser, getopt, getty, grep, groups, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostname, httpd, hwclock, id, ifconfig, ifdown, ifenslave, ifplugd, ifup,

   init, insmod, install, ionice, iostat, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, last, less, linux32, linux64,

   linuxrc, ln, loadfont, loadkmap, logger, login, logread, losetup, lpq, lpr, ls, lsattr, lsmod, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, man, md5sum, mdev, mesg,

   microcom, mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.reiser, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mt, mv,

   nameif, nanddump, nandwrite, nbd-client, nc, netstat, nice, nmeter, nohup, nslookup, ntpd, openvt, passwd, patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill,

   pmap, popmaildir, poweroff, powertop, printenv, printf, ps, pscan, pstree, pwd, pwdx, raidautorun, rdate, readahead, readlink, realpath, reboot, renice, reset, resize, rev,

   rm, rmdir, rmmod, route, rtcwake, runlevel, rx, script, scriptreplay, sed, sendmail, seq, setarch, setconsole, setfont, setkeycodes, setlogcons, setserial, setsid, setuidgid,

   sh, sha1sum, sha256sum, sha512sum, showkey, sleep, softlimit, sort, split, start-stop-daemon, stat, strings, stty, su, sum, swapoff, swapon, switch_root, sync, sysctl,

   syslogd, tac, tail, tar, tee, telnet, telnetd, test, tftp, tftpd, time, timeout, top, touch, tr, traceroute, traceroute6, true, tty, ttysize, tunctl, tune2fs, ubiattach,

   ubidetach, ubimkvol, ubirmvol, ubirsvol, ubiupdatevol, udhcpc, udhcpd, umount, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, users, usleep,

   vconfig, vi, vlock, volname, wall, watch, watchdog, wc, wget, which, who, whoami, whois, xargs, xz, xzcat, yes, zcat, zcip

```

----------

