F2FS - Force Grub to update-grub using UUID?

Hi ,
I made the mistake during installation and I am using f2fs as root and on every kernel update I have to:

  1. change the line root=/dev/nvme1n1p1 to root=UUID=xxx-xxx-xxxx-xxx-xxx otherwise I will end with a non bootable system.
  2. I have to delete manually the previous modified grub Kernel entries because the modified entries are not updated.

I am using 3x Kernel versions and Imagine having to do this in three kernels every week is troublesome so atm I just modify only 1 kernel grub line.
One time I forgot and spend like 15 mins on terminal trying to figure how to fix this.

I have searched and found some posts about this and that is possible to do it but I just dont know how so any help will be much appreciated.

Creating a /boot/grub/custom.cfg file could be a solution, but you will need to search for details how it works.

In your /etc/fstab is / mounted by /dev/nvme1n1p1 or by UUID? If it’s by the device, maybe change that to UUID?

also in /etc/default/grub there is a GRUB_DISABLE_LINUX_UUID=true make sure that is false or commented out.

I did that and still root=/dev/nvme1n1p1
All my FSTAB mountings are using UUID

Okay how about this. First run:

sudo grub-probe --target=device /

I think on your system that will return /dev/nvme1n1p1, can you just confirm? Next run:

sudo grub-probe --device /dev/nvme1n1p1 --target=fs_uuid

Does it print a UUID? The correct UUID? The device should be the same device returned from the first command. If it’s not printing the correct UUID can you run it again with a -v maybe we can figure out why with the verbose output…

I may be going too low level trying to figure this out (looking at the scripts), but this appears to be how grub is finding the UUID for the device.

Update: Wait looking at output on my machine, I don’t have a /boot/grub/device.map file, do you have that file? Maybe if you back it up and remove it, things might work?

[w-pc wolfyrion]# sudo grub-probe --target=device /
[w-pc wolfyrion]# sudo grub-probe --device /dev/nvme1n1p1 --target=fs_uuid
grub-probe: error: unknown filesystem.
[w-pc wolfyrion]#

Okay looks like I went too deep…according to https://wiki.archlinux.org/index.php/F2FS#GRUB_with_root_on_F2FS GRUB doesn’t really support F2FS.


As I see from the above link that many people asked the developer for f2fs support but I think devs dont care that much :frowning:

I’m not sure if this is at all helpful, but


Do you update grub manually or just let the pacman hooks do their job? I would probably just write a pacman hook that runs after grub configuration is updated. It would trigger a simple bash script that uses sed to change the root parameter. Do you want to have help with that? It is not very difficult.

1 Like

I have tried that as well but is not building correctly.
I just let the pacman hooks do their job and then go manually with grub-customizer and modify the grub (replacing /dev with UUID’s)

This is easy to script. Wanna go there?

It will be nice to have something to automate things than do it manually but how can it be done :o?

First, the command to modify a file is

sed -i /path/to/file

To replace the string:

sed -i 's~root=/dev/nvme1n1p1~root=UUID=xxx-xxx-xxxx-xxx-xxx~g' /boot/grub/grub.cfg

Just put the right uuid there. Test first with a copy of the real file to ensure it works correctly.

So at it’s simplest, the script would be

sed -i 's~root=/dev/nvme1n1p1~root=UUID=xxx-xxx-xxxx-xxx-xxx~g' /boot/grub/grub.cfg

You might want to also automatically delete the old entries, which is a bit more complicated.

You would then call the script with a pacman hook:

Type = File
Operation = Install
Operation = Upgrade
Operation = Remove
Target = boot/grub/grub.cfg

Description = Updating Grub-Bootmenu for f2fs
When = PostTransaction
Exec = /usr/bin/update-f2fs-grub

Not sure if that is enough, I have not previously written pacman hooks.

Maybe better option would be add an os-prober script that runs the command:


#! /usr/bin/env bash
sed -i 's~root=/dev/nvme1n1p1~root=UUID=xxx-xxx-xxxx-xxx-xxx~g' /boot/grub/grub.cfg &>/dev/null

This way it should get executed after the entries have been generated. Does this look reasonable?



OP is using grub-customizer.
Not sure , no, don’t think your script will work on it. (that is - the final menu that is presented)

Two. Not sure either if OP has separate /boot partition.
Best for f2fs to have separate boot partition.

Cheers. Take care.

Good points. Using a separate /boot should avoid the whole issue. But it’s an opportunity to learn sed, no? :grinning:

Good point about grub customerizer, I have no idea what file it is going to edit.

1 Like

What is this giving
cat /etc/default/grub | grep UUID

  1. @Chrysostomus
    Thank you very much for all your effort writing down this script. I really appreciate it.
    I dont know though if t will work , I will try it out.
    I am afraid that it will not automatically remove previous entries so I may have to do this manually.

  2. @gohlip I have a separate boot Partition
    (I couldnt install grub on an f2fs partition, is impossible …)

3.@AgentS [wolfyrion@w-pc ~]$ cat /etc/default/grub | grep UUID
( I edited this entry manually)

Although That doesnt matter because grub doesnt support f2fs (it doesnt recognize the partition so it cant produce the uuid)
[w-pc wolfyrion]# sudo grub-probe --device /dev/nvme1n1p1 --target=fs_uuid
grub-probe: error: unknown filesystem.

1 Like

That too can be scripted, but it is slightly more difficult. Alternatively you could just blank the file before a new one is generated? Use a smaller number for the grub script:


   mv /boot/grub/grub.cfg /boot/grub/grub.cfg.bak


#! /usr/bin/env bash
sed -i ‘s~root=/dev/nvme1n1p1~root=UUID=xxx-xxx-xxxx-xxx-xxx~g’ /boot/grub/grub.cfg &>/dev/null

I have done this one but it doesnt do anything…
I have uninstall a kernel and reinstall again as well but nothing

Did you try the command in a terminal first, to see any errors?

Any errors during the update-grub hook?

Forum kindly sponsored by