View difference between Paste ID: GZ7HviHx and mTMNcBLA
SHOW: | | - or go back to the newest paste.
1
# Reference
2
# https://help.ubuntu.com/community/Grub2
3
# https://help.ubuntu.com/community/Grub2/Installing
4
# https://ubuntuforums.org/showthread.php?t=2147295
5
# https://blog.heckel.io/2017/05/28/creating-a-bios-gpt-and-uefi-gpt-grub-bootable-linux-system/
6
7
# Define variables
8
export chrtdev_device=/dev/<my dev>
9
export chrtdev_root=/dev/<root partition>
10
export chrtdev_boot=/dev/<boot partition>
11
export chrtdev_efi=/dev/<efi esp partition>
12
export chrtdir=/media/chrt
13
14
# Ensure efivars are present
15
modprobe efivars
16
17
# Create mounts for chroot
18
sudo mkdir -p $chrtdir
19
20
sudo mount ${chrtdev_root} $chrtdir
21
sudo mount ${chrtdev_boot} $chrtdir/boot
22
sudo mount ${chrtdev_efi} $chrtdir/boot/efi
23-
sudo mount --bind /sys $chrtdir/sys 
23+
24
sudo mount --bind /dev $chrtdir/dev
25
sudo mount --bind /dev/pts $chrtdir/dev/pts
26
sudo mount --bind /proc $chrtdir/proc
27
sudo mount --bind /sys $chrtdir/sys
28
sudo mount --bind /sys/firmware/efi/efivars $chrtdir/sys/firmware/efi/efivars 
29
30
# networking
31
sudo cp $chrtdir/etc/resolv.conf{,.orig}
32
sudo cp /etc/resolv.conf $chrtdir/etc/
33
34
# enter chroot
35
sudo chroot $chrtdir /bin/bash -c "chrtdev_device=${chrtdev_device}; echo \${chrtdev_device}; bash"
36
37
# update apt, install grub if required
38
apt update
39
apt install grub-efi-amd64
40
41
# install grub
42
grub-install -v ${chrtdev_device}
43
update-grub
44
45
# Restore original resolve.conf
46
cp $chrtdir/etc/resolv.conf{.orig,}
47
48
# exit chroot
49
exit