Assuming you are using grub2, the most important configuration file is grub.cfg
(usually located in /boot/grub
directory for bios based systems and /boot/efi/EFI/<os name>/
for efi systems). When computer starts grub follows instructions from that file. This is just a text file, so you can edit it by hand, or use some automatic tool (a shell script) grub-mkconfig
(a.k.a. grub2-mkconfig
) which creates configuration according to rules defined in a /etc/default/grub
file and /etc/grub.d/
directory.
Anyway, if you've changed root partition there are a few things to take care of. First of all linux kernel parameters: grub directly is not affected by root partition, but it needs to pass correct path to the kernel, so look for a line like this
linux /vmlinuz-4.19.5 root=/dev/sda1
and change it to /dev/sda2
.
It can also be passed in UUID way:
linux /vmlinuz-4.19.5 root=UUID=abcdefgh-ijkl-mnop-qrst-uvwxyz
You can test your root UUID with grub's command:
grub-probe --target=fs_uuid /
Second thing to check/change is a kernel file itself. It can reside on separate partition (usually /boot
), or on root (/
) one. In later case you need to search for a line
set root='hd0,gpt1'
and change gpt1
to gpt2
. (I assumed here that you have only one disk hd0
and you are using GUID partition table, a standard nowadays).
Depending on you configuration you may also need to change filesystem UUID and a hint string to find proper path to the kernel. It could look like
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt1' --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 abcd-efgh
search --no-floppy --fs-uuid --set=root abcd-efgh
New UUID you already know, use grub-probe --target=hints_string /
to find proper value of hints-string.