You are not logged in.

#1 2012-11-23 18:33:38

graph
Member
Registered: 2010-12-21
Posts: 105

Booting without initrd?

So, I recently switched to systemd.
According to the Wiki I could safely remove the /-entry in /etc/fstab, because grub2 can handle mounting the root-partition. This is correct. Further down on the same wiki-page it it mentioned that "(initramfs) takes care of recognizing your root filesystem and mounting it".

This got me thinking - Is it possible to boot without using an initramfs?

According to this link it is, but I can't figure out how to do it. I tried booting with the following configuration, but got errors about a missing root-partition (my root is sda5):

menuentry 'Arch Linux - Custom initramfs' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-edfcc182-d233-431
5-aefd-0c11f80ff4a9' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  61fc73d6-c126-44c4-bf45-98ecbe06c96d
    else
      search --no-floppy --fs-uuid --set=root 61fc73d6-c126-44c4-bf45-98ecbe06c96d
    fi
    echo    'Loading Linux core repo kernel ...'
    linux   /vmlinuz-linux root=sda5 rootfstype=ext4 rw quiet libahci.ignore_sss=1 raid=noautodetect init=/usr/lib/systemd/systemd

    #echo    'Loading initial ramdisk ...'
    #initrd  /initramfs-linux-tiny.img

Is it possible to do what I'm trying to do, without compiling my own kernel?

Offline

#2 2012-11-23 18:49:47

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,548
Website

Re: Booting without initrd?

graph wrote:

Is it possible to do what I'm trying to do

Yes.

graph wrote:

...without compiling my own kernel?

No, at least not using the standard kernel(s) in arch repos.

For pretty "traditional" setups, you'd need a kernel built with at least sd_mod and ext4 built in.  You can, however, trim down your initramfs quite a bit from the defaults.  Falconindy has a great blog posting with all the details of this ... where he also notes that this generally doesn't have any noticable difference in boot speed.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2012-11-23 18:50:16

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Booting without initrd?

grub does not mount your root device. It has no concept of mount namespaces like the Linux kernel does. The wiki states that it's thanks to mkinitcpio's fsck hook, and totally unrelated to any work your bootloader does. The only mention of a bootloader in this text is where it mentions that you can change "ro" to "rw".

The initramfs mounts your root device. If you have no initramfs, then your kernel must have, compiled in, support for your storage bus (SATA, PATA, SCSI, etc), support for your block device driver (very likely using the sd_mod driver), and support for your filesystem. With all these things available, you can remove the initrd line from your bootloader, and the kernel will mount your root partition, assuming it can understand the declaration. That is, it will understand /dev/sda2, but not something like /dev/disk/by-label/myroot or LABEL=myroot. Interestingly, it will understand PARTUUID=123456... thanks to some patchwork from the ChromeOS team.

All this said, the stock ARCH kernel is incapable of running without an initramfs. You'll need to compile your own.

Offline

#4 2012-11-23 18:56:02

teateawhy
Member
From: GER
Registered: 2012-03-05
Posts: 1,138
Website

Re: Booting without initrd?

Is it possible to do what I'm trying to do, without compiling my own kernel?

No.
You can see a lot of drivers with the 'lsmod' command , of which some are necessary for booting , but are not compiled in the kernel.
I recommend you not to boot without initramfs or compiling your own kernel unless you do it for the learning experience.
But it is definitly possible and you can read about it on the archwiki.
https://wiki.archlinux.org/index.php/Ke … ompilation
https://wiki.archlinux.org/index.php/Initramfs

For starters try to create a minimal initramfs, that contains only parts necessary for your hardware setup.

Last edited by teateawhy (2012-11-23 18:57:08)

Offline

#5 2012-11-23 18:57:53

graph
Member
Registered: 2010-12-21
Posts: 105

Re: Booting without initrd?

Alright. My initramfs is already as tiny as it gets, thanks to Falconindys blog, but I appreciate the link anyway.
I am not interested in making my own kernel at the moment, so I guess it doesn't get much better than it is now.

Thank you for your help, all of you.

Last edited by graph (2012-11-23 18:58:11)

Offline

#6 2012-11-23 18:58:21

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,548
Website

Re: Booting without initrd?

It is a great learning experience.  The first three times I did it, I was learning what I was doing wrong.  The fourth time I learned it still wasn't worth it.  Now I stick with stock kernels (or precompiled ck).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB