0

Is it possible to copy standard vmlinuz-3.10..... kernel file to another directory, rename it and load it during booting the system?

I'm on CentOS7 and I have a class task. "Copy vmlinuz-... and initramfs-.... files from /boot to root directory, rename them, add menuentry "Spare kernel" and load it from this new copied kernel file".

I edited /etc/grub.d/40_custom file and added this menuentry.Screenshot1 Copied and renamed files (/kernel and /ramdisk) Screenshot2 I have also made unexecutable /etc/grub.d/10_linux file (chmod 644). As a result "Main kernel" - no problem, "Spare kernel" gives error Screenshot3

I guess I have to set bootable root in correct way so I tried options 'set root=(hd0,msdos1)' and 'set root=(hd0,msdos2)' (/boot mounted on sda1, but system root ( / ) on sda2, I thought that (hd0,msdos2) will work but it doesn't). Screenshot4

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Olek K
  • 65

1 Answers1

1

Your root partition is on an LVM volume. When boot menu shows up, press "c" to enter the command prompt, then type "ls" command to list the partitions available on your system. You will see a partition like "(...centos-root)". Replace your "(hd0,msdos2)" in "set root=(hd0,msdos2)" with "(...centos-root)" you see, then try again.
(Remember to run grub2-mkconfig after modifying /etc/grub.d/40_custom.)

liuqx
  • 52
  • Thank you so much for your response. But my grub2's command prompt doesn't give me this partition option "(...centos-root)". Here is the link to my screenshots. Do you have any idea what I'm missing? Shall I create another partition or may be it is possible to solve as it is? – Olek K Jan 04 '19 at 13:25
  • @AlexKuchin Run "insmod lvm" command before the "ls" command, and try again. If that works, add "insmod lvm" before "set root=..." in your menuentry. – liuqx Jan 06 '19 at 02:50
  • Thanks a lot for your help. It works for me. Also had to delete piece of code between lines "set root='lvm/centos-root'" and "linux16 /kernel ..." (see screenshot above with my /etc/grub.d/40_custom file). Don't know exactly what are they need for, but they had some hints to "hd0,msdos*" partition and your advice didn't work while these lines existed. – Olek K Jan 09 '19 at 16:02
  • I tried to investigate the meaning of those lines of code with --hint options. GNU GRUB Manual 2.02 gives some info about that. Do you know what the hexadecimal string after --hint options needed for? In my case it is "17c3748a-0f25-4e92-ad6c-d3f2f85abee8". I guess it's connected to --set=root option, but where can I find out more info about that? Thank you. – Olek K Jan 10 '19 at 10:00
  • @AlexKuchin The hexadecimal string is the UUID of your partition. You can use blkid to get that. – liuqx Jan 11 '19 at 13:38