You are not logged in.

#1 2023-11-15 09:21:47

mpr
Member
Registered: 2022-01-13
Posts: 15

Disk Access Patterns during Boot

I'm curious about how the different stages of the boot process access the hard drive (or SSD). My understanding is as follows:

- The boot loader loads the kernel image from the hard drive into memory. This disk access is a sequential read (and the kernel image is compressed) so it should be fast.
- For early user space initramfs is loaded from hard drive into memory. Again this is a (compressed) image so access will be sequential so it should be fast.
- Once control is handed over to the init process (eg systemd) and we enter userland, we cannot load standard images but have to load whatever the specific system requires. At this stage disk access will be random reads from different locations on the hard drive (wherever the data we need is stored). Here nothing has been pre-loaded into memory. This stage will be a bit slower (in terms of disk access speed -- maybe not in overall time).

Is my understanding correct?

I'm asking for two reasons:
1. general understanding
2. I want to understand how important sequential vs random read performance of a hard drive is for the boot process

Thanks for your help!

Offline

#2 2023-11-19 15:07:09

ectospasm
Member
Registered: 2015-08-28
Posts: 273

Re: Disk Access Patterns during Boot

Your understanding is sound, as far as I can tell.  You may gain insight using the systemd-analyze, see systemd-analyze(1).  It's not going to give you much insight in sequential versus random access disk reads, but systemd loads a lot of stuff in userspace in parallel, so there will likely be a lot more disk activity as everything is initialized and loaded. 

So depending on the capabilities of the disk and its controller, etc., the userland initialization has the potential to be faster (though a spike in I/O is to be expected).

Offline

#3 2023-11-21 20:03:58

mpr
Member
Registered: 2022-01-13
Posts: 15

Re: Disk Access Patterns during Boot

Thanks for your answer! I've found systemd-analyze is really useful to get a better idea of what's happening during boot.

Offline

#4 2023-11-22 04:32:28

ectospasm
Member
Registered: 2015-08-28
Posts: 273

Re: Disk Access Patterns during Boot

One thing to note, the initramfs is pretty flexible, you could load quite a bit into it to minimize disk reada as init/systemd's main process spins up.  Not that I know how to do it off the top of my head, but you could preload all sorts of stuff (including the root filesystem) into RAM, making systemd boot the OS even faster while minimizing disk reads.

Of course, there are trade-offs, the more stuff you pack into the initramfs, the larger the initrd image needs to be (and the more space on /boot or /efi, etc., you'll need).  But that's the beauty of Arch Linux, if you really want to do it that way nothing is really stopping you.  However, you'll by and large need to support yourself, for the most part, or at least be able to describe the setup intelligently so other Archers can help.

Offline

Board footer

Powered by FluxBB