Install Ubuntu in UEFI mode with debootstrap

在 UEFI 模式下使用 LiveCD 安裝 Ubuntu,安裝完成後卻總是卡在 grub。


Ubuntu boot failed



Boot your PC/server from Ubuntu live CD

Boot your PC/server from Ubuntu live CD, configure network to connect to Internet.

Prepare the partition

Create partitions on the system disk, the first one is for EFI system; the other is for system.

sudo parted /dev/sda
(parted) mklabel gpt
(parted) mkpart ESP fat32 1MiB 128MiB
(parted) mkpart primary xfs 128MiB 100%
(parted) set 1 boot on
(parted) quit

sudo partprobe /dev/sda
sudo mkfs.vfat -F 32 /dev/sda1
sudo mkfs.xfs -f /dev/sda2

Mount root file system:

sudo mount /dev/sda2 /mnt

Install Ubuntu core with debootstrap

First, you need to install debootstrap:

sudo apt install debootstrap

Then, you can install ubuntu to the /mnt with debootstrap command:

sudo debootstrap --arch amd64 xenial /mnt

Copy the apt repository configuration to new file system:

sudo cp /etc/apt/sources.list /mnt/etc/apt/sources.list

Mount other file system

sudo mkdir -p /mnt/boot/efi
sudo mount /dev/sda1 /mnt/boot/efi
sudo mount --bind /dev /mnt/dev
sudo mount -t devpts /dev/pts /mnt/dev/pts
sudo mount -t proc proc /mnt/proc
sudo mount -t sysfs sysfs /mnt/sys
sudo mount -t tmpfs tmpfs /mnt/tmp

Then, chroot to /mnt:

sudo chroot /mnt /bin/bash
export HOME=/root

Install Linux kernel, grub and other packages

apt update
apt install linux-image-generic linux-headers-generic grub-efi

Configure grub

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --debug

The reboot system.


  1. GNU Parted - ArchWiki
  2. GRUB - ArchWiki