# weird gentoo kernel boot

## slashlinux

Hello,

I have a little problem on my work.

I have a server , and someone installed gentoo :

```

backup ~ # uname -r

2.6.30-gentoo-r4

backup ~ # uname -a

Linux backup 2.6.30-gentoo-r4 #1 SMP Wed Aug 26 11:14:51 EEST 2009 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz GenuineIntel GNU/Linux

```

Now my boss want to install and configure OpenVPN and for that i need to install "module tun" , first i need to make menuconfig in kernel, save and then copy bzImage  to boot, but i have a surprize.

On my /boot i have nothing:

```
backup ~ # cd /boot

backup boot # ls

backup boot #

```

I don`t know from were is booting the bzImage?

The gentoo don`t let me to mount /boot.

```
backup ~ # mount /boot

mount: unknown filesystem type 'ext2'
```

What can I do in this case?

Where is the boot image ?

----------

## mvaterlaus

your kernel will be on the boot partition. if you can not mount it, you have to load the kernel module or compile ext2fs support directly in to the kernel. since grub does have ext2 support on its own, it does find the kernel in the boot partition and is able to load it.

----------

## slashlinux

How can I do that, I am new in gentoo.

Thank you so much

----------

## mvaterlaus

first try to load the module:

```
modprobe ext2
```

if that works, you can mount your /boot partition. if it does not work, you have a bit of a problem. I don't know, what you have enabled in your kernel, but you can also try to mount it as ext3/4

```
mount -t ext3 /dev/sdXX /boot
```

if this does not work, you must recompile your kernel [1], but since you cannot mount your boot partition, you have to copy your kernel image with a live cd or pen.

[1]http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=7#doc_chap3

----------

## slashlinux

This is the output.

```
backup boot # modprobe ext2

FATAL: Module ext2 not found.

backup boot # mount -t ext3 /dev/sda /boot

mount: /dev/sda already mounted or /boot busy

```

----------

## mir3x

Check what partition u need to mount first by fdisk or cfdisk /dev/sda

or look for /boot in /etc/fstab or /etc/mtab

sda is whole disk,

u have to mount sdaX ( or sdbX or sdXY )

----------

## slashlinux

```
backup boot # mount -t ext3 /dev/sda1 /boot

mount: wrong fs type, bad option, bad superblock on /dev/sda1,

       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try

       dmesg | tail  or so

backup boot # mount -t ext2 /dev/sda1 /boot

mount: unknown filesystem type 'ext2'

```

----------

## gabrielg

Did you try simply

```
mount /dev/sda1 /boot
```

 ?

That should detect whichever file system you formatted /dev/sda1 automatically (could be ReiserFS).

If that doesn't work, you'll probably need ext2 in your kernel, so you need to recompile as mvaterlaus mentioned (followed his link).

Good luck.

----------

## mvaterlaus

you can check, which filesystems your kernel supports by issuing the command

```
cat /proc/filesystems
```

----------

## slashlinux

```
backup boot # mount /dev/sda1 /boot

mount: unknown filesystem type 'ext2'

backup boot #

```

I just installed the ext2 from Filesystem in kernel, i compilated and i copied the bzImage on /boot but is nothing happening.

Thanks

----------

## slashlinux

```
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.

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

/dev/sda3               /               ext3            noatime         0 1

/dev/sda2               none            swap            sw              0 0

/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0

#/dev/fd0               /mnt/floppy     auto            noauto          0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for

# POSIX shared memory (shm_open, shm_unlink).

# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will

#  use almost no memory if not populated with files)

shm                     /dev/shm        tmpfs           nodev,nosuid,noexec     0 0
```

----------

## mvaterlaus

what do you mean, by nothing is happening. first, it does not make any change, if you copied the bzImage to /boot without mounting the partition. so at boottime, grub will read the kernel from the partition and not the directory, where you copied the new one. if you have compiled the kernel, boot the system from a rescue media (any linux live cd will do) and then mount the partitions (sda3 and sda1). after that, you can copy the new kernel to sda1 and modify the grub entries in {sda1}/grub/grub.conf (assuming, you use grub 0.9xx).

after these steps, the system should boot with your new kernel

----------

## VoidMage

First of all, '2.6.30-gentoo-r4' is a bit old these days.

Second on any recent kernel, CONFIG_EXT4_USE_FOR_EXT23 has been working fine for me for quite awhile.

----------

## wcg

A little clarity:

```

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

/dev/sda3               /               ext3            noatime         0 1

/dev/sda2               none            swap            sw              0 0

/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0

#/dev/fd0               /mnt/floppy     auto            noauto          0 0

```

You have 3 partitions on /dev/sda. /dev/sda3 is the root partition,

mounted on / at system boot. It contains the /boot directory. /dev/sda1

is the boot partition, which is where grub finds kernels specifed

in grub.conf. The "noauto" in the boot options for /dev/sda1 in

/etc/fstab tells the system to not automatically mount it on /boot

at system startup.

If you copy a new kernel into /boot without mounting /dev/sda1

on the /boot directory, it ends up on the root partion, on /dev/sda3,

instead of on the boot partition, /dev/sda1, which is what happened

after you enabled ext2 with make menuconfig and compiled a new

kernel.

So, you have what is colloquially called a "Catch-22". You do not have

filesystem support for ext2 in the kernels that grub can boot (at

least the kernel that you have been trying), but you need a running

kernel with ext2 support to mount the boot partition so that you can

copy a new kernel into it, configure grub.conf to find it, etc.

(The /boot/grub/ directory is on that boot partition.)

The way out is to install grub. It will install itself into /boot/grub/

on /dev/sda3. Then you can copy your new kernel into /boot,

still on /dev/sda3, edit /boot/grub/grub.conf to list it in the

boot menu, and use grub-install (or any of the numerous

ways to install grub's stages to an mbr) to tell grub to look

on the /dev/sda3 partition for a kernel to boot.

Once that kernel is up and running, you can copy all of your

new stuff in /boot to a temporary directory, mount the

/dev/sda1 partition on /boot, and fix things up as you like.

You will have to learn about grub to do this (that is likely

grub1 with a kernel that old, the package that gentoo

calls "grub-static".

Step 1:

emerge grub-static

Step 2:

Copy your new kernel with ext2 support into boot.

Step 3:

Read grub manual.

Step 4:

Edit /boot/grub/grub.conf

Step 5:

Run grub-install.

Step 6:

reboot and choose new kernel from grub menu.

If you already knew how grub worked this would probably

take no more than an hour. If you do not, figure some extra

time to read the grub manual, experiment, fail, try again,

etc, until it works. Give it a weekend. If you succeed in less

time than that, you have some leisure time.

----------

## wcg

PS:

There is a recent thread in another subforum here,

https://forums.gentoo.org/viewtopic-t-943610.html

where a user has a similar problem. Other

posters pointed out that one could compile ext2

support as a module for an otherwise already

compiled kernel (if the source tree that the kernel

was compiled from is still installed), and load it

with modprobe to enable ext2 support. This would

enable mounting and accessing the original contents

of /dev/sda1, the boot partitition, with the original kernel.

Addendum to my previous "emerge grub-static"

explanation: when you emerge grub-static, copy

a newly compiled kernel into /boot, etc, without

the boot partition mounted, those files exist in

the /boot directory on /dev/sda3 (mounted on

/ at system boot).

Once you mount /dev/sda1, the boot partition, on /boot,

those files still exist on /dev/sda3, but any contents

of the /boot directory on /dev/sda3 are shadowed

by the contents of the boot partition, /dev/sda1.

When you mount /dev/sda1 on /boot, you see

the contents of /dev/sda1 when you run "ls /boot".

If you unmount /dev/sda1 and run "ls /boot", then

you see the contents of /boot on /dev/sda3 again.

As far as copying the contents of /boot on /dev/sda3

(newly installed grub-static, newly compiled kernel,

etc) to a temporary directory before mounting the

boot partition that contained the old kernel(s) on /boot,

I suggest a location other than a subdirectory of /tmp

for that. On a reboot, the default Gentoo init scripts

clean out any contents of the /tmp directory remaining

from a previous boot (old temporary files not cleaned

up by their applications, maybe detritus remaining

in /tmp after a power fail reboot, etc), and you might

need your new grub files, new kernel, etc around after

you have rebooted and fixed things up in grub.conf on

the boot partition to accomodate your new kernel.

You can always use a subdirectory of /root, root's

home directory, for that, (all of this stuff is going

to be root-owned files anyway). Once everything

is booting and running smoothly again, you can delete

that temporary copy (of your recovery files in /boot on

/dev/sda3.)

----------

