You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

加密分区中更新GRUB的方法及Ubuntu 16.04更新后GRUB故障求助

Fixing GRUB Boot Issue After Ubuntu 16.04 Update & Updating GRUB on Encrypted Partitions

Hey there, let's tackle this GRUB problem you ran into after updating Ubuntu 16.04, plus cover how to update GRUB on encrypted partitions.

First: Get Back Into Your System From the GRUB Rescue Prompt

Since you're stuck at the black GRUB screen with just a prompt, here's how to manually boot into Ubuntu temporarily:

  1. First, identify your Ubuntu root partition by running:

    ls
    

    You'll see entries like (hd0,gpt1), (hd0,gpt2)—test which one is your root partition by running:

    ls (hd0,gpt2)/boot
    

    If you see kernel files (like vmlinuz-xxx-generic), that's your root partition.

  2. Set the root partition in GRUB:

    set root=(hd0,gpt2)  # Replace with your actual partition
    
  3. Load the kernel and initrd image (use TAB to auto-complete the kernel version):

    linux /boot/vmlinuz-<your-kernel-version>-generic root=/dev/sda2 ro  # sda2 matches the partition from step 1
    initrd /boot/initrd.img-<your-kernel-version>-generic
    
  4. Boot into Ubuntu:

    boot
    

Once you're in the system, we can fix GRUB permanently.

Permanently Repair GRUB (Non-Encrypted Partitions)

Run these commands to refresh and reinstall GRUB:

sudo update-grub
sudo grub-install /dev/sda  # Note: This is the disk (e.g., /dev/sda), not a partition like /dev/sda2

Reboot your system—you should now see the normal GRUB menu.

Updating GRUB on Encrypted Partitions

If your Ubuntu root partition is encrypted, follow these steps to safely update GRUB:

  1. Unlock the encrypted partition (replace /dev/sda2 with your encrypted partition, ubuntu-crypt is a temporary mapping name):

    sudo cryptsetup luksOpen /dev/sda2 ubuntu-crypt
    
  2. Mount the root partition to /mnt:

    sudo mount /dev/mapper/ubuntu-crypt /mnt
    
  3. Mount the /boot partition if you have a separate one (replace /dev/sda1 with your boot partition):

    sudo mount /dev/sda1 /mnt/boot
    
  4. Bind critical system directories to access them from the chroot environment:

    sudo mount --bind /dev /mnt/dev
    sudo mount --bind /proc /mnt/proc
    sudo mount --bind /sys /mnt/sys
    
  5. Enter the chroot environment to work within your installed system:

    sudo chroot /mnt
    
  6. Update and reinstall GRUB:

    update-grub
    grub-install /dev/sda  # Again, target the disk, not a partition
    
  7. Clean up and unmount:
    Exit the chroot, then unmount all the directories and close the encrypted partition:

    exit
    sudo umount /mnt/sys
    sudo umount /mnt/proc
    sudo umount /mnt/dev
    sudo umount /mnt/boot  # Skip this if you didn't mount a separate boot partition
    sudo umount /mnt
    sudo cryptsetup luksClose ubuntu-crypt
    

Reboot your system, and GRUB should be properly updated for your encrypted setup.


内容的提问来源于stack exchange,提问作者Jarodd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:23:48