Home > Common Problem > What should I do if there is grub problem when installing ubuntu from USB disk?

What should I do if there is grub problem when installing ubuntu from USB disk?

coldplay.xixi
Release: 2020-07-06 09:27:48
Original
16655 people have browsed it

The solution to the grub problem when installing ubuntu from a USB flash drive: First plug in the USB flash drive to start the computer, open the terminal and find the installation partition; then check the file to find the grub2 partition, and perform the transformation from rescue to normal; Finally, restart the system and enter [sudo update-grub2].

What should I do if there is grub problem when installing ubuntu from USB disk?

Solution to grub problem when installing ubuntu from USB disk:

1. Plug in the USB disk Start your computer and open a terminal.

sudo -i

First find out which partition your ubuntu10.04 is installed in, use:

fdisk -l

The partition where my ubuntu10.04 root directory is located is /dev/sda2.

The following mounts the root directory of the original system:

mount /dev/sda2 /mnt
Copy after login

mounts /dev/sda2 to /mnt, of course you can also Choose somewhere else. Note here that if you have a separate partition for /boot, you need to mount /boot separately. For example, if your original /boot is mounted to /dev/sda12 is up, you need to enter mount /dev/sda12 /mnt/boot here. I didn't separate it here, so it's not needed.

The following is the last step:

grub-install --root-directory=/mnt /dev/sda
Copy after login

(Note: there is a space bar after /mnt, do not write /dev/sda2)

If you see

Installation finished.No Error Reported.
Copy after login

means it has been successful!

Enter the following command in the terminal:

sudo update-grub2
Copy after login
Copy after login

Enter the password according to the prompts. If everything goes well, a sentence similar to the following will appear, which means success.

grub.cfg ...
Found Debian background: moreblue-orbit-grub.png
Found linux image: /boot/vmlinuz-2.6.31-15-generic
Found initrd image: /boot/initrd.img-2.6.31-15-generic
Found memtest86+ image: /boot/memtest86+.bin
done
Copy after login

If no similar statement above appears, then search for grub in Synaptic. You can install the one with the Ubuntu logo grub-pc. After installation, enter

sudo update-grub2
Copy after login
Copy after login

Just update grub2.

At this time, I restarted directly without using the USB disk. I found that I still could not directly enter the system, but entered the grub rescue mode.

2.grub rescue

Since in rescue mode, only a small number of basic commands are available, certain operations must be performed to load normal modules , and then enter normal mode.

The commands available in rescue mode are: set, ls, insmod, root, prefix(Set startup path)

First assume that the core file of grub2 is in the (hd0,8) partition, and then let’s see how to enter the normal mode (normal) from rescue mode to boot from (hd0,8) .

The search command cannot be used in rescue mode. If you are not sure which partition the grub2 file is in, you can use the ls command to check, such as

  • ls (hd0 ,8)/ Check the root directory of the (hd0,8) partition to see if there is a boot folder

  • ls (hd0,8)/boot/ View the files in the /boot directory of the (hd0,8) partition

  • ls (hd0,8)/boot/grub/ View the (hd0,8) partition The file

in the /boot/grub directory can be determined by viewing the file in which partition the grub2 core file is located, and then the transition from rescue to normal can be performed :

First ls Look at the partition, guess the / partition number based on the partition list and then ls (hd0,x)/ look at the file in the partition directory to make sure it is found / Partition, if it’s not right, keep looking. Find the (hd0,x) of the / partition and continue

grub rescue>set root=(hd0,x)
grub rescue>set prefix=/boot/grub
grub rescue>insmod normal
rescue>normal
Copy after login

to enter the system. But after restarting, it still enters grub rescue mode, which does not completely solve the problem.

3. Enter the system, open the terminal and enter:

sudo update-grub2
sudo grub-install /dev/sda
Copy after login

After rebooting again, I found that everything was done.

The above is the detailed content of What should I do if there is grub problem when installing ubuntu from USB disk?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template