# making an initramfs for a custom kernel

## nightcast2000

Hi to all,

           I have downloaded and compiled a nouveau-kernel. I have downloaded it to my /home directory.

I have managed to compile it successfully. I have managed to run "grub2-mkconfig" on it. The trouble is that whenever I run

"sudo genkernel --install initramfs" I get this output: 

```
steve@mernivia ~/linux-2.6 $ sudo genkernel --install initramfs

Password: 

* Gentoo Linux Genkernel; Version 3.4.49

* Running with options: --install initramfs

* Using genkernel.conf from /etc/genkernel.conf

* Sourcing arch-specific config.sh from /usr/share/genkernel/arch/x86_64/config.sh ..

* Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load ..

* Linux Kernel 3.14.0-gentoo for x86_64...

* .. with config file /usr/share/genkernel/arch/x86_64/kernel-config

* mount: /boot mounted successfully!

* busybox: >> Using cache

* initramfs: >> Initializing...

*         >> Appending base_layout cpio data...

*         >> Appending auxilary cpio data...

*         >> Copying keymaps

*         >> Appending busybox cpio data...

*         >> Appending modules cpio data...

*         >> Appending blkid cpio data...

*         >> Appending modprobed cpio data...

*         >> Appending linker cpio data...

*         >> Finalizing cpio...

*         >> Compressing cpio data (.xz)...

* WARNING... WARNING... WARNING...

* Additional kernel cmdline arguments that *may* be required to boot properly...

* With support for several ext* filesystems available, it may be needed to

* add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.
```

I've looked into the /boot directory, but genkernel seems to wipe out the custom kernel I had installed there!

I've tried booting the kernel with just the grub entry, but that just ends up with a kernel panic.

Can somebody help me generate a initramfs for the custom kernel?

Thanks in advance,

Regards,

            Nightcast2000

----------

## John R. Graham

Genkernel will not wipe out an existing kernel unless it has exactly the same name, and (probably) not at all when your just asking it to generate an initramfs. Are you sure you have /boot mounted?

- John

----------

## nightcast2000

Hi John R. Graham,

                          I did "sudo mount -l" and I did see my /boot partition wasn't mounted. For future reference to someone, I just ran "sudo mount /dev/sb1 /boot" (replace the "s" number for your boot or other patition number) and got that mounted.

I cd'ed to the directory to where I have my cutom kernel, and ran "sudo genkernel --install in initramfs" again, it ran for a bit longer, but it still doesn't seem to generate a inittramfs for that kernel:

```
steve@mernivia ~ $ sudo mount /dev/sdb1 /boot

Password: 

steve@mernivia ~ $ cd linux-2.6

steve@mernivia ~/linux-2.6 $ sudo genkernel --install initramfs

* Gentoo Linux Genkernel; Version 3.4.49

* Running with options: --install initramfs

* Using genkernel.conf from /etc/genkernel.conf

* Sourcing arch-specific config.sh from /usr/share/genkernel/arch/x86_64/config.sh ..

* Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load ..

* Linux Kernel 3.14.0-gentoo for x86_64...

* .. with config file /usr/share/genkernel/arch/x86_64/kernel-config                                                                                                                                                                        

* busybox: >> Using cache                                                                                                                                                                                                                   

* initramfs: >> Initializing...                                                                                                                                                                                                             

*         >> Appending base_layout cpio data...                                                                                                                                                                                             

*         >> Appending auxilary cpio data...                                                                                                                                                                                                

*         >> Copying keymaps                                                                                                                                                                                                                

*         >> Appending busybox cpio data...                                                                                                                                                                                                 

*         >> Appending modules cpio data...                                                                                                                                                                                                 

*         >> Appending blkid cpio data...                                                                                                                                                                                                   

*         >> Appending modprobed cpio data...                                                                                                                                                                                               

*         >> Appending linker cpio data...                                                                                                                                                                                                  

*         >> Finalizing cpio...                                                                                                                                                                                                             

*         >> Compiling 3.14.0-gentoo bzImage...                                                                                                                                                                                             

*         >> Installing firmware ('make firmware_install') due to CONFIG_FIRMWARE_IN_KERNEL != y...                                                                                                                                         

                                                                                                                                                                                                                                            

* WARNING... WARNING... WARNING...                                                                                                                                                                                                          

* Additional kernel cmdline arguments that *may* be required to boot properly...                                                                                                                                                            

* With support for several ext* filesystems available, it may be needed to                                                                                                                                                                  

* add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.                                                                                                                                                                

                                                                                                                                                                                                                                            

* Do NOT report kernel bugs as genkernel bugs unless your bug                                                                                                                                                                               

* is about the default genkernel configuration...                                                                                                                                                                                           

*                                                                                                                                                                                                                                           

* Make sure you have the latest ~arch genkernel before reporting bugs.

```

And here the output of "ls -l /boot":

```
steve@mernivia ~/linux-2.6 $ ls -l /boot

total 31172                                                                                                                                                                                                                                 

-rw-r--r-- 1 root root 3518504 Apr  3 02:40 System.map-3.14.0-gentoo

-rw-r--r-- 1 root root 3546679 Apr  5 12:44 System.map-3.14.0-nouveau+

-rw-r--r-- 1 root root 3490481 Apr  5 18:10 System.map-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root   97695 Apr  3 02:40 config-3.14.0-gentoo

-rw-r--r-- 1 root root  103848 Apr  5 12:44 config-3.14.0-nouveau+

drwxr-xr-x 1 root root      78 Apr  5 17:05 grub

-rw-r--r-- 1 root root 1557832 Apr  5 17:09 initramfs-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 7962800 Apr  5 18:10 kernel-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 5782736 Apr  3 02:40 vmlinuz-3.14.0-gentoo

-rw-r--r-- 1 root root 5838304 Apr  5 12:44 vmlinuz-3.14.0-nouveau+

```

Regards,

            Nightcast2000

----------

## jpoland2003

Genkernel might be building against the default source location /usr/src/linux/ and just replacing the 3.14 initramfs with a new one. I didn't see anywhere you said you set the symbolic link or eselected your custom kernel. Have you tried passing --kerneldir=/usr/src/linux-2.6 along with --install initramfs?

----------

## nightcast2000

Hi jpoland,

              The kernel I'm trying to generate is located in my "/home/steve/linux-2.6" directory it is not located in the usual "/usr/src/linux" directory. I downloaded it using git from this url:

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git I was suing the instructions from the nouveau wiki page: http://nouveau.freedesktop.org/wiki/

Thank you for the tip on pointing genkernel to the right directory, I think it should work when I try it.

I've just tried that command, and it did seem to build it, but after running "ls -l /boot" again, the initramfs for that kernel doesn't seem to be there:

```
steve@mernivia ~ $ sudo genkernel --kerneldir=/home/steve/linux-2.6 --install initramfs

Password: 

* Gentoo Linux Genkernel; Version 3.4.49

* Running with options: --kerneldir=/home/steve/linux-2.6 --install initramfs

* Using genkernel.conf from /etc/genkernel.conf

* Sourcing arch-specific config.sh from /usr/share/genkernel/arch/x86_64/config.sh ..

* Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load ..

* Linux Kernel 3.14.0-nouveau+ for x86_64...

* .. with config file /usr/share/genkernel/arch/x86_64/kernel-config

* busybox: >> Using cache

* initramfs: >> Initializing...

*         >> Appending base_layout cpio data...

*         >> Appending auxilary cpio data...

*         >> Copying keymaps

*         >> Appending busybox cpio data...

*         >> Appending modules cpio data...

*         >> Appending blkid cpio data...

*         >> Appending modprobed cpio data...

*         >> Appending linker cpio data...

*         >> Finalizing cpio...

*         >> Compiling 3.14.0-nouveau+ bzImage...

*         >> Installing firmware ('make firmware_install') due to CONFIG_FIRMWARE_IN_KERNEL != y...

* WARNING... WARNING... WARNING...

* Additional kernel cmdline arguments that *may* be required to boot properly...

* With support for several ext* filesystems available, it may be needed to

* add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.

* Do NOT report kernel bugs as genkernel bugs unless your bug

* is about the default genkernel configuration...

* 

* Make sure you have the latest ~arch genkernel before reporting bugs.

steve@mernivia ~ $ ls -l /boot

total 42536

-rw-r--r-- 1 root root 3518504 Apr  3 02:40 System.map-3.14.0-gentoo

-rw-r--r-- 1 root root 3546679 Apr  5 12:44 System.map-3.14.0-nouveau+

-rw-r--r-- 1 root root 3490481 Apr  5 18:10 System.map-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 3546679 Apr  5 19:31 System.map-genkernel-x86_64-3.14.0-nouveau+

-rw-r--r-- 1 root root   97695 Apr  3 02:40 config-3.14.0-gentoo

-rw-r--r-- 1 root root  103848 Apr  5 12:44 config-3.14.0-nouveau+

drwxr-xr-x 1 root root      78 Apr  5 17:05 grub

-rw-r--r-- 1 root root 1557832 Apr  5 17:09 initramfs-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 7962800 Apr  5 18:10 kernel-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 8086448 Apr  5 19:31 kernel-genkernel-x86_64-3.14.0-nouveau+

-rw-r--r-- 1 root root 5782736 Apr  3 02:40 vmlinuz-3.14.0-gentoo

-rw-r--r-- 1 root root 5838304 Apr  5 12:44 vmlinuz-3.14.0-nouveau+
```

Would moving the kernel to /usr/src make any difference?

Regards,

            Nightcast2000

----------

## John R. Graham

It would, indeed. Sorry, I didn't pick up on that nuance on my first read. 

- John

----------

## jpoland2003

Well, I always use eselect to change the symbolic link but I thought that kerneldir option would work.  Looks like it just build an initramfs for the kernel you booted into (3.14.0-nouveau+).  If you have eselect emerged try "eselect kernel list" and see if your 2.6 shows up in the list.  You can then set that as the kernel to build against using "eselect kernel set #" where # is the number of the kernel.

I do see in the genkernel wiki this:  *Quote:*   

> The linux symlink can be changed in different ways.
> 
> If the symlink USE flag is set in /etc/portage/make.conf, the linux symlink is automatically updated to point to the newly emerged sources.
> 
> If the previous USE flag is not set, the user can change the destination of the symlink using the eselect kernel list command.
> ...

 

Which makes me wonder even more about that kerneldir option.

----------

## nightcast2000

Hi guys,

           I've moved the kernel and ran "eselect kernel list". It did indeed find the linux-2.6 as (1) in the list. I selected the linux-2.6 and ran "sudo genkernel --kerneldir=/usr/src/linux-2.6 --install initramfs"

It still built the initramfs, but it still doesn't show up in my /boot directory. Here is the full output:

```
steve@mernivia /usr/src/linux-2.6 $ eselect kernel list

Available kernel symlink targets:

  [1]   linux-2.6

  [2]   linux-3.14.0-gentoo *

steve@mernivia /usr/src/linux-2.6 $ eselect kernel set 1

rm: cannot remove '/usr/src/linux': Permission denied

!!! Error: Couldn't remove existing symlink

exiting

steve@mernivia /usr/src/linux-2.6 $ sudo eselect kernel set 1

Password: 

steve@mernivia /usr/src/linux-2.6 $ sudo genkernel --kerneldir=/usr/src/linux-2.6 --install initramfs

* Gentoo Linux Genkernel; Version 3.4.49

* Running with options: --kerneldir=/usr/src/linux-2.6 --install initramfs

* Using genkernel.conf from /etc/genkernel.conf

* Sourcing arch-specific config.sh from /usr/share/genkernel/arch/x86_64/config.sh ..

* Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load ..

* Linux Kernel 3.14.0-nouveau+ for x86_64...

* .. with config file /usr/share/genkernel/arch/x86_64/kernel-config

* busybox: >> Using cache

* initramfs: >> Initializing...

*         >> Appending base_layout cpio data...

*         >> Appending auxilary cpio data...

*         >> Copying keymaps

*         >> Appending busybox cpio data...

*         >> Appending modules cpio data...

*         >> Appending blkid cpio data...

*         >> Appending modprobed cpio data...

*         >> Appending linker cpio data...

*         >> Finalizing cpio...

*         >> Compiling 3.14.0-nouveau+ bzImage...

*         >> Installing firmware ('make firmware_install') due to CONFIG_FIRMWARE_IN_KERNEL != y...

* WARNING... WARNING... WARNING...

* Additional kernel cmdline arguments that *may* be required to boot properly...

* With support for several ext* filesystems available, it may be needed to

* add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.

* Do NOT report kernel bugs as genkernel bugs unless your bug

* is about the default genkernel configuration...

* 

* Make sure you have the latest ~arch genkernel before reporting bugs.

steve@mernivia /usr/src/linux-2.6 $ ls -l /boot

total 42532

-rw-r--r-- 1 root root 3518504 Apr  3 02:40 System.map-3.14.0-gentoo

-rw-r--r-- 1 root root 3546679 Apr  5 12:44 System.map-3.14.0-nouveau+

-rw-r--r-- 1 root root 3490481 Apr  5 18:10 System.map-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 3546679 Apr  5 20:13 System.map-genkernel-x86_64-3.14.0-nouveau+

-rw-r--r-- 1 root root   97695 Apr  3 02:40 config-3.14.0-gentoo

-rw-r--r-- 1 root root  103848 Apr  5 12:44 config-3.14.0-nouveau+

drwxr-xr-x 1 root root      78 Apr  5 17:05 grub

-rw-r--r-- 1 root root 1557832 Apr  5 17:09 initramfs-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 7962800 Apr  5 18:10 kernel-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 8085024 Apr  5 20:13 kernel-genkernel-x86_64-3.14.0-nouveau+

-rw-r--r-- 1 root root 5782736 Apr  3 02:40 vmlinuz-3.14.0-gentoo

-rw-r--r-- 1 root root 5838304 Apr  5 12:44 vmlinuz-3.14.0-nouveau+

steve@mernivia /usr/src/linux-2.6 $ 

```

I don't know if it will boot  "as is" or not. 

Regards,

            Nightcast2000

----------

## John R. Graham

From your listing, note

```
steve@mernivia /usr/src/linux-2.6 $ eselect kernel list

Available kernel symlink targets:

  [1]   linux-2.6

  [2]   linux-3.14.0-gentoo * 
```

and

```
* Linux Kernel 3.14.0-nouveau+ for x86_64...
```

This is an apparent genkernel bug. I'd set that symlink if I were you.

There also exists the remote possibility that genkernel will no longer handle 2.6 kernels, although I suspect it will.

- John

----------

## nightcast2000

Hi john,

          Ah ok, so for the symlink, would "sudo ln -s /usr/share/genkernel/gen_initramfs.sh /usr/src/linux-2.6" do? or what would be the best symlink do?

Regards,

            Nightcast2000

----------

## John R. Graham

No, it's the kernel symlink I'm talking about

```
eselect kernel set 1
```

- John

----------

## NeddySeagoon

nightcast2000,

If you have a custom kernel, why not a custom initrd too?

----------

## nightcast2000

Hi all,

       I want to thank you all for the kind advice, I have been looking at the wiki on how to build a custom initramfs. I don't have much time now, but I should be able to resume tomorrow.

Regards,

            Nightcast2000

----------

## nightcast2000

Hi all,

        I've read through the link that NeddySeagoon gave me. I believe I've set it up ok, but I've run into a snag. When I run" sudo scripts/gen_initramfs_list.sh -o /boot/initrd.cpio.gz /usr/src/initramfs/initramfs_list" I get this error:

```
File /sbin/btrfsck.btrfs could not be opened for reading line 34
```

I have installed btrfs-progs and re-emerged busybox. I also ran "revdep-rebuild" as a precaution. Here are the two files I created from the link:

```
#!/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

        btsfsck_opts="$btrfsck_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

    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

mount -t devtmpfs none /dev

# disable kernel messages from popping onto the screen

echo 0 > /proc/sys/kernel/printk

# clear the screen

clear

# mounting rootfs on /mnt/root

uuidlabel_root || rescue_shell "Error with uuidlabel_root"

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

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

That is my init file. Here is my initramfs_list file:

```
# 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/btrfsck.btrfs and /sbin/btrfsck

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/btrfsck.btrfs         /sbin/btrfsck.btrfs             755 0 0

# our init script

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

Regards,

             Nightcast2000

----------

## NeddySeagoon

nightcast2000,

Does

```
 /sbin/btrfsck.btrfs
```

exist on your system ?

Your initramfs_list file only contains 32 lines - its odd that you have an error at line 34.

The error is at line 29 of the initramfs_list that you posted. Maybe you have several initramfs_list files ?

----------

## nightcast2000

Hi NeddySeagoon,

                            I have corrected the initramfs_list file, I can produce a initrramfs file, but the problem is "grub2-mkconfig" doesn't pick up the custom initramfs file. I don't have a grub.conf as I use grub2. I do have a grub.cfg and have had a look in 10_linux in /etc/grub.d. I'll need some pointers on how to get this picked up by grub2-mkconfig. I am wondering if it would be better to use dracut instead, but I'll see for now on that one. Here is the output I have so far:

```
mernivia initramfs # find . -print0 | cpio --null -ov --format=newc | gzip -9 > /boot/initramfs-3.14.0-nouveau+.cpio.gz

.

./bin

./bin/busybox

./dev

./dev/sdb2

./dev/null

./dev/console

./dev/tty

./dev/sda2

./etc

./lib

./lib64

./mnt

./mnt/root

./proc

./root

./sbin

./sys

./init

./initramfs_list

3802 blocks

mernivia initramfs # ls -l /boot

total 33220

-rw-r--r-- 1 root root 3518504 Apr  3 02:40 System.map-3.14.0-gentoo

-rw-r--r-- 1 root root 3492077 Apr  6 19:57 System.map-3.14.0-nouveau+

-rw-r--r-- 1 root root 3490481 Apr  5 18:10 System.map-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root   97695 Apr  3 02:40 config-3.14.0-gentoo

-rw-r--r-- 1 root root   97807 Apr  6 19:57 config-3.14.0-nouveau+

drwxr-xr-x 1 root root      78 Apr  6 19:58 grub

-rw------- 1 root root   10247 Apr  6 18:37 grub.grub.cfg

-rw-r--r-- 1 root root  990920 Apr  6 21:16 initramfs-3.14.0-nouveau+.cpio.gz

-rw-r--r-- 1 root root 1557832 Apr  5 17:09 initramfs-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 7962800 Apr  5 18:10 kernel-genkernel-x86_64-3.14.0-gentoo

-rw-r--r-- 1 root root 5782736 Apr  3 02:40 vmlinuz-3.14.0-gentoo

-rw-r--r-- 1 root root 6993328 Apr  6 19:57 vmlinuz-3.14.0-nouveau+

mernivia initramfs # grub2-mkconfig -o /boot/grub/grub.cfg

Generating grub configuration file ...

Found linux image: /boot/kernel-genkernel-x86_64-3.14.0-gentoo

Found initrd image: /boot/initramfs-genkernel-x86_64-3.14.0-gentoo

Found linux image: /boot/vmlinuz-3.14.0-nouveau+                                                                                               

Found linux image: /boot/vmlinuz-3.14.0-gentoo                                                                                                 

Found initrd image: /boot/initramfs-genkernel-x86_64-3.14.0-gentoo                                                                             

Found Windows 7 (loader) on /dev/sda1                                                                                                          

done 
```

Regards,

             Nightcast2000

----------

## NeddySeagoon

nightcast2000,

I'm still on grub-legacy.  I don't see any reason to change.

Its a boot loader, it works.  Thats all I need.

I guess thats a long winded way of saying I can't help.

----------

## nightcast2000

Ok NeddySeagoon,

                          I'll wait until someone else help me with this problem. I have looked at both your link and this one:http://gentoo-en.vfose.ru/wiki/Initramfs but they don't seem to be clear on where to put the initrd line. Thank you for the help that you've given me so far.

Regards,

            Nightcast2000

----------

## NeddySeagoon

nightcast2000,

 *http://gentoo-en.vfose.ru/wiki/Initramfs wrote:*   

> Note: If you are using the grub-mkconfig scripts of Grub2 and want your generic initramfs to be recognized by it, edit the /etc/grub.d/10_linux file and search for 'initrd='. There is a list of recognized initramfs files. You can simply add ' "initramfs.cpio.gz"' to it.

 

That suggests that 

```
nano -w /etc/grub.d/10_linux

Ctrl-W initrd=
```

And adding something like 

```
initramfs-3.14.0-nouveau+.cpio.gz 
```

Look for the entry that matches 

```
initramfs-genkernel-x86_64-3.14.0-gentoo 
```

I'm guessing its version independent somehow.

----------

## nightcast2000

Hi NeddySeagoon,

                          I've looked into my "/etc/grub.d/10_linux file" and there is an entry but it is very general purpose: here is the contents of it:

```
#! /bin/sh

set -e

# grub-mkconfig helper script.

# Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.

#

# GRUB is free software: you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by

# the Free Software Foundation, either version 3 of the License, or

# (at your option) any later version.

#

# GRUB is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.

prefix="/usr"

exec_prefix="/usr"

datarootdir="/usr/share"

. "/usr/share/grub/grub-mkconfig_lib"

export TEXTDOMAIN=grub

export TEXTDOMAINDIR="${datarootdir}/locale"

CLASS="--class gnu-linux --class gnu --class os"

if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then

  OS=GNU/Linux

else

  OS="${GRUB_DISTRIBUTOR} GNU/Linux"

  CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"

fi

# loop-AES arranges things so that /dev/loop/X can be our root device, but

# the initrds that Linux uses don't like that.

case ${GRUB_DEVICE} in

  /dev/loop/*|/dev/loop[0-9])

    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`

  ;;

esac

if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \

    || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \

    || uses_abstraction "${GRUB_DEVICE}" lvm; then

  LINUX_ROOT_DEVICE=${GRUB_DEVICE}

else

  LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}

fi

case x"$GRUB_FS" in

    xbtrfs)

   rootsubvol="`make_system_path_relative_to_its_root /`"

   rootsubvol="${rootsubvol#/}"

   if [ "x${rootsubvol}" != x ]; then

       GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"

   fi;;

    xzfs)

   rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`

   bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"

   LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"

   ;;

esac

title_correction_code=

linux_entry ()

{

  os="$1"

  version="$2"

  type="$3"

  args="$4"

  if [ -z "$boot_device_id" ]; then

      boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"

  fi

  if [ x$type != xsimple ] ; then

      case $type in

     recovery)

         title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;;

     *)

         title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;;

      esac

      if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then

     replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"

     quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"

     title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"

     grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"

      fi

      echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"

  else

      echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"

  fi

  if [ x$type != xrecovery ] ; then

      save_default_entry | grub_add_tab

  fi

  # Use ELILO's generic "efifb" when it's known to be available.

  # FIXME: We need an interface to select vesafb in case efifb can't be used.

  if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then

      echo "   load_video" | sed "s/^/$submenu_indentation/"

      if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \

     && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then

     echo "   set gfxpayload=keep" | sed "s/^/$submenu_indentation/"

      fi

  else

      if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then

     echo "   load_video" | sed "s/^/$submenu_indentation/"

      fi

      echo "   set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/"

  fi

  echo "   insmod gzio" | sed "s/^/$submenu_indentation/"

  if [ x$dirname = x/ ]; then

    if [ -z "${prepare_root_cache}" ]; then

      prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"

    fi

    printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/"

  else

    if [ -z "${prepare_boot_cache}" ]; then

      prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"

    fi

    printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"

  fi

  message="$(gettext_printf "Loading Linux %s ..." ${version})"

  sed "s/^/$submenu_indentation/" << EOF

   echo   '$(echo "$message" | grub_quote)'

   linux   ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}

EOF

  if test -n "${initrd}" ; then

    # TRANSLATORS: ramdisk isn't identifier. Should be translated.

    message="$(gettext_printf "Loading initial ramdisk ...")"

    sed "s/^/$submenu_indentation/" << EOF

   echo   '$(echo "$message" | grub_quote)'

   initrd   ${rel_dirname}/${initrd}

EOF

  fi

  sed "s/^/$submenu_indentation/" << EOF

}

EOF

}

machine=`uname -m`

case "x$machine" in

    xi?86 | xx86_64)

   list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do

                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi

              done` ;;

    *) 

   list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do

                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi

        done` ;;

esac

case "$machine" in

    i?86) GENKERNEL_ARCH="x86" ;;

    mips|mips64) GENKERNEL_ARCH="mips" ;;

    mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;

    arm*) GENKERNEL_ARCH="arm" ;;

    *) GENKERNEL_ARCH="$machine" ;;

esac

prepare_boot_cache=

prepare_root_cache=

boot_device_id=

title_correction_code=

# Extra indentation to add to menu entries in a submenu. We're not in a submenu

# yet, so it's empty. In a submenu it will be equal to '\t' (one tab).

submenu_indentation=""

is_top_level=true

while [ "x$list" != "x" ] ; do

  linux=`version_find_latest $list`

  gettext_printf "Found linux image: %s\n" "$linux" >&2

  basename=`basename $linux`

  dirname=`dirname $linux`

  rel_dirname=`make_system_path_relative_to_its_root $dirname`

  version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`

  alt_version=`echo $version | sed -e "s,\.old$,,g"`

  linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"

  initrd=

  for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \

      "initrd-${version}" "initramfs-${version}.img" \

      "initrd.img-${alt_version}" "initrd-${alt_version}.img" \

      "initrd-${alt_version}" "initramfs-${alt_version}.img" \

      "initramfs-genkernel-${version}" \

      "initramfs-genkernel-${alt_version}" \

      "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \

      "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do

    if test -e "${dirname}/${i}" ; then

      initrd="$i"

      break

    fi

  done

  config=

  for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do

    if test -e "${i}" ; then

      config="${i}"

      break

    fi

  done

  initramfs=

  if test -n "${config}" ; then

      initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`

  fi

  if test -n "${initrd}" ; then

    gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2

  elif test -z "${initramfs}" ; then

    # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's

    # no initrd or builtin initramfs, it can't work here.

    linux_root_device_thisversion=${GRUB_DEVICE}

  fi

  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then

    linux_entry "${OS}" "${version}" simple \

    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"

    submenu_indentation="$grub_tab"

    

    if [ -z "$boot_device_id" ]; then

   boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"

    fi

    # TRANSLATORS: %s is replaced with an OS name

    echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"

    is_top_level=false

  fi

  linux_entry "${OS}" "${version}" advanced \

              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"

  if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then

    linux_entry "${OS}" "${version}" recovery \

                "single ${GRUB_CMDLINE_LINUX}"

  fi

  list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`

done

# If at least one kernel was found, then we need to

# add a closing '}' for the submenu command.

if [ x"$is_top_level" != xtrue ]; then

  echo '}'

fi

echo "$title_correction_code"

```

I did try and add my own entry, but it still doesn't still pick it up.

Regards,

            Nightcast2000

----------

## NeddySeagoon

nightcast2000

You need to change this bit

```
  initrd=

  for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \

      "initrd-${version}" "initramfs-${version}.img" \

      "initrd.img-${alt_version}" "initrd-${alt_version}.img" \

      "initrd-${alt_version}" "initramfs-${alt_version}.img" \

      "initramfs-genkernel-${version}" \

      "initramfs-genkernel-${alt_version}" \

      "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \

      "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do 
```

insert a line 

```
"initramfs-3.14.0-nouveau+.cpio.gz" \
```

to match your initramfs ... but thats version specific

```
"initramfs-${version}-nouveau+.cpio.gz" \
```

might be more future proof.

You can also cheat - rename your initramfs to match 

```
initramfs-${version}.img
```

which is already there.

I wonder it a symlink would work?

----------

## nightcast2000

Hi NeddySeagoon,

                             Sorry for the late reply, I'm just compiling libreoffice. I've tried putting in "initramfs-${version}-nouveau+.cpio.gz" \ into my 10_linux file,renamed my initramfs to a .img and even tried to put a genkernel name in front

Sadly all of them modifications still fail, grub2-mkconfig will just pick up the original gentoo kernel. I know it picks up the others, but I know they won't boot.

I don't know what else to try...

Regards,

              Nightcast2000

----------

## nightcast2000

Hi NeddySeagoon,

                             I've got some good news,

                                                                      I've managed to get my custom kernel to boot! The way I did it was to re-emerge both genkernel and (Hesitantly) grub2.

I am having a issue currently with getting sound to work, but I'll open a fresh post if I get stuck.

Regards,

              Nightcast2000

----------

