# What are the necessary packages to boot kernel?

## colag

Debian is the existing linux.

I'm trying to boot kernel from an empty partition (/dev/sda1).

These are the empty directories in that partition.

```

bin  boot  dev   include  lib  media  mnt  proc   sbin  sys  tmp   usr  var

```

Kernel source is in /usr/src. 

What I tried:

```

mount /dev/sda1 /media/sda1

cd /media/sda1/usr/src/linux-4.8

make menuconfig

make INSTALL_MOD_PATH=/media/sda1 modules_install

cp -v arch/x86/boot/bzImage /media/sda1/boot/vmlinuz-4.8.0

cp -v System.map /media/sda1/boot/System.map-4.8.0

cp -v .config /media/sda1/boot/config-4.8.0

reboot

```

Got error something like this:

```

Kernel panic unable to mount rootfs

```

Why is this error?

What other packages do I have to install to boot kernel?Last edited by colag on Mon Oct 17, 2016 5:41 am; edited 1 time in total

----------

## xaviermiller

Hi!,

Did you add the support for the disk controller and filesystem ?

/dev need also to contain /dev/console and /dev/null before /dev is mounted into devtmpfs (don't forget to enable it)

Then you need at least one init system.

More info at http://www.tldp.org/HOWTO/From-PowerUp-To-Bash-Prompt-HOWTO.html

----------

## colag

 *xaviermiller wrote:*   

> Did you add the support for the disk controller and filesystem ?

 

What does that mean? Can you please explain this more?

----------

## NeddySeagoon

colag,

If you mean have the kernel load and attempt to mount the root filesystem, a boot loader and kernel are required.

No more. Root will mount and you will get an error about /sbin/init missing.

The next step is to include a statically built /bin/busybox in the root filesystem and add init=/bin/busybox to your kernel command line.

Adding in  /bin/bash in place of /bin/busybox is a little harder as bash is dynamically linked.

You need all the libraries too. lddtree /bin/bash will tell you what they are.

These options don't give you much more that a shell.  Does that cover your definition of booted?

----------

## colag

 *NeddySeagoon wrote:*   

> The next step is to include a statically built /bin/busybox in the root filesystem and add init=/bin/busybox to your kernel command line.

 

This works:

```

linux   /boot/vmlinuz-4.8.0 root=/dev/sda1 ro init=/bin/busybox hush

```

But this doesn't work:

```

linux   /boot/vmlinuz-4.8.0 root=UUID=69b65444-5f22-4b9b-9afc-3a815c0d44b8 ro init=/bin/busybox hush

```

This gets error like this:

```

Kernel panic VFS: Unable to mount root fs

```

lddtree /bin/bash doesn't work in debian, 

```
bash: lddtree: command not found
```

```

ldd /bin/bash

   linux-gate.so.1 (0xb771f000)

   libncurses.so.5 => /lib/i386-linux-gnu/libncurses.so.5 (0xb76d8000)

   libtinfo.so.5 => /lib/i386-linux-gnu/libtinfo.so.5 (0xb76b5000)

   libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xb76af000)

   libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb7502000)

   /lib/ld-linux.so.2 (0xb7722000)

```

If I want to run bash, do I need these:

```

ncurses

glibc

```

What are linux-gate.so.1,libtinfo.so.5,libdl.so.2 ?

----------

## NeddySeagoon

colag,

```
linux   /boot/vmlinuz-4.8.0 root=UUID=69b65444-5f22-4b9b-9afc-3a815c0d44b8 ro init=/bin/busybox hush 
```

fails as mounting root by filesystem UUID requires that the userspace mount command be available, so requires an initrd.

The kernel understands PARTUUID without any outside help. root=PARTUUID=<your_root_partition_PARTUUID> will work.

Note that the filesystem UUID and PARTUUID are different values because they refer to different objects.

```
/dev/sda2: UUID="b6633d8e-41ef-4485-9bbe-c4c2d69f4e8c" TYPE="swap" PARTUUID="0553caf4-02"
```

Thats swap on on MSDOS partition by way of an example.

The PARTUUID format varies with the partition table type in use.

The following is /boot on GPT

```
/dev/sde1: UUID="c400b18c-0210-4338-a0fd-f437ecbaaf99" TYPE="ext4" PARTLABEL="ext4" PARTUUID="150e6ef1-7ba8-409c-9c3f-dbdecdc9f18b
```

----------

