Categories
Development Linux Ubuntu

Edit/Add a line in Grub2 Ubuntu

I want to make my grub2 tell me when it loads a kernel and initrd file.
so i edited my /boot/grub/grub.cfg file to get something like this :

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0b1e0d0c-7515-41a4-ae05-2e62c31cba02' {
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod ntfs
    set root='hd0,msdos4'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos4 --hint-efi=hd0,msdos4 --hint-baremetal=ahci0,msdos4  FA84518A845149F1
    else
      search --no-floppy --fs-uuid --set=root FA84518A845149F1
    fi
    loopback loop0 /ubuntu/disks/root.disk
    set root=(loop0)
    echo "Loading kernel..."
    linux   /boot/vmlinuz-4.15.0-76-generic root=UUID=FA84518A845149F1 loop=/ubuntu/disks/root.disk ro rootflags=sync  quiet splash $vt_handoff
    echo "Loading initrd..."
    initrd  /boot/initrd.img-4.15.0-76-generic
} 

instead of :

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0b1e0d0c-7515-41a4-ae05-2e62c31cba02' {
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod ntfs
    set root='hd0,msdos4'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos4 --hint-efi=hd0,msdos4 --hint-baremetal=ahci0,msdos4  FA84518A845149F1
    else
      search --no-floppy --fs-uuid --set=root FA84518A845149F1
    fi
    loopback loop0 /ubuntu/disks/root.disk
    set root=(loop0)
    linux   /boot/vmlinuz-4.15.0-76-generic root=UUID=FA84518A845149F1 loop=/ubuntu/disks/root.disk ro rootflags=sync  quiet splash $vt_handoff
    initrd  /boot/initrd.img-4.15.0-76-generic
}

I added echo "loading kernel but when a script runs update-grub my mod are overwriten..
how can I make my mod permanent without being overwriten by update-grub?

Leave an answer

Your email address will not be published. Required fields are marked *