How can I stop the btrfs check during startup?


#1

Hi
I am falling in love with Manjaro. I have just one little issue, slow startup. I am pretty sure its the btrfs check during startup. I found that out while trying to remove it, and totally messed up an install. Lucky for me I had backed up the partition so it was relatively easy to restore my OS.
In Mint btrfs-tools is a package that can easily be removed. Not so much on Manjaro as it wants to remove Caja and a host of other applications and thats just not happening. I dont have any btrfs partitions, all of them are ext4 and I wont create one.
Is there a way to remove the btrfs check during startup? I have googled it but cant seem to find the answer.


#2

(Non-impolite question) - Why are you so sure? Let us know what indicates that.
Could it not just be ‘plain’ fsck (or other things like journaling or db) doing its thing?

Provide at terminal

pacman -Q systemd-fsck-silent
cat /etc/mkinitcpio.conf | grep keymap

#3

You could edit /etc/fstab and change the last number to a zero, disabling fsck for that partition.


#4

But why disable fsck for a non-btrfs partition? (Unless he wants to).


#5

Ah thanks. I missed the part about “all of them are ext4”.
If there are no btrfs partitions, there should also be no btrfs-check.


#6

Sorry if I was unclear on exactly what I wanted. I will try to be more specific here and give more details.

In my experience the system checks for btrfs file systems on startup. This is a slow process and one of the main reasons I dont like using it. Another is in the past it has been near impossible for older OS installs to access the partition. This makes booting into an older OS install if there is a problem, mounting the btrfs one, and fixing problems impossible. I have multiple OS partitions and I have saved a few installs over the years doing just that. I have no problem with ext4 and made a decision to just keep using it.
Its not a file system check I am talking about, sorry if I was unclear. Its the system looking for btrfs partitions. In my first post I mentioned I learned it was a problem because while trying to remove btrfs from the system I messed up the install. I let btrfs-tools uninstall, and with it all the other things it wanted to uninstall. When I rebooted the system it was very fast, but when I logged in the system was unstable. So I know checking for btrfs file systems is slowing down the boot.
The question is how can I stop the system from looking for btrfs file systems on boot.

After writing this I remembered a hook in the file list for the btrfs-tools package. Its found in /lib/initcpio/hooks/btrfs. Inside the file is

#!/usr/bin/ash

run_hook() {
    btrfs device scan
}

# vim: set ft=sh ts=4 sw=4 et:

Thsis looks to be the scan I am talking about.


#7

I hacked a solution. While I have a lot of Linux experience in general its mainly on Debian based systems and a few failed attempts at Arch. I dont know a super lot about how everything under the hood runs, but I am not afraid of the terminal or hacking things to see if they will work.
I deleted “btrfs device scan” from /lib/initcpio/hooks/btrfs and installed a new kernel. I had been wanting to try 4.20 and it was a safe way to test this by leaving the working kernel in place.
The system boot is super fast, likely under a minute now. I would still like to know if there is a easier/better/normal way of accomplishing the same thing to learn from this experience.


#8

:man_facepalming:
@torvic, do you want to say anything on this?


#9

Under normal circumstances, you shouldn’t need to edit that file.

/etc/mkinitcpio.conf defines what HOOKS get used with your initrd. You can remove btrfs from there if you don’t want that hook. I could be wrong, but I don’t think it is enabled by default.

After editing that file regenerate your initrds using

sudo mkinitcpio -P

#10

I did read something about mkinitcpio.conf on the Arch wiki. But when I looked at the /etc/mkinitcpio file in the hooks section it didnt have btrfs listed. It reads HOOKS=“base udev autodetect modconf block keyboard keymap resume filesystems”.


#11

It could also be in the MODULES section.

I am not an expert but I think filesystems autodetects installed filesystems and adds the appropriate modules.

All that being said, are you sure there is a “btrfs detection” being run at boot?


#12

Its not in modules and I did a search of the mkinitcpio.conf file and did not find btrfs anywhere in it.
I am not sure how I can see if there is no btrfs scan now. I have to go out for a bit, but when I get back I am going to boot into the 4.19 kernel and run

sudo mkinitcpio -P

To see if that speeds startup as well.


#13

It should run for all your installed kernels so you should run mkinitcpio -P and then reboot using the other kernel.


#14

I ran the command and now the 4.19 kernel startup is just as fast as the 4.20.


#15

Now add back “btrfs device scan” ; do “mkinitcpio -P” and see if it any slower, any kernel.


#16

Instead of editing that system file, try running mkinitcpio -P -S btrfs which will (or should) skip the btrfs hook.
Then verify the resulting initram with lsinitcpio -a /boot/initramfs-xxx.img and see whether the btrfs module is still in there.


#17

When compiling initramfs (mkinitcpio) --> if the OS is btrfs, the ‘btrfs’ module will be in it.
When compiling initramfs (mkinitcpio) --> if the OS is not btrfs, the ‘btrfs’ module will not be in it.

There’s no further need to run mkinitcpio -P -S btrfs just because the OS is not btrfs.
Nor is it necessary to do anything to /lib/initcpio/hooks/~ or in /lib/initcpio/hooks/btrfs.

Boot times will be the same (unless we mess up mkinitcpio).


#18

But isn’t that exactly the problem? His OS is NOT btrfs, but the btrfs hook still seems to have been loaded? Or am I completely misunderstanding the issue?


#19

I did not read anywhere that his hooks has btrfs nor anywhere where modules have btrfs.
Just that he has “btrfs device scan” in /lib/initcpio/hooks/btrfs (don’t we all have this regardless whether it is ext4 or btrfs?) and that his boot times are very slow.

Since I have both btrfs and ext4 OS’s I can print out the modules and maybe do the delete “btrfs device scan” and post it here. But give me some time.
ps: the btrfs OS is in external; drive which I don’t use normally (for testing this new grub only). But I can do the comparative grub (delete btrfs scan) in a bios-legacy system.

Give me about 5 minutes.


#20

Hmm well I thought that by removing “btrfs device scan” OP claimed that bootup is faster, and that’s where my suggestion of skipping the btrfs hook came from.

Yep, and that file shouldn’t be modified, hence my proposition to skip that hook entirely when building the initram.

Okay waiting for your return :wink: