Last active
April 1, 2023 09:15
-
-
Save JorgenEvens/04cab9e9f6dd2e2e385df9ada90fb552 to your computer and use it in GitHub Desktop.
Script to convert legacy boot debian to UEFI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
apt update | |
apt install lvm2 gparted | |
# Convert MBR to GPT | |
sgdisk -g /dev/xvda | |
partprobe | |
# resize partitions | |
gparted | |
cd /tmp | |
# mount root | |
mkdir install | |
mount /dev/*-vg/root install | |
# mount boot | |
cd install | |
mount /dev/xvda1 boot | |
mkdir -p boot/efi | |
mount /dev/xvda2 boot/efi | |
# mount environment | |
mount --bind /dev dev | |
mount --bind /sys sys | |
mount --bind /proc proc | |
mount --bind /run run | |
# install grub-efi | |
chroot . << EOF | |
apt install -y grub-efi | |
grub-install /dev/xvda | |
echo "UUID=$(blkid -o value /dev/xvda2 | head -n1) /boot/efi vfat defaults 0 2" >> /etc/fstab | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thank you for the script! I would like to convert my MBR to GPT in Debian 12.
Just a couple of quick questions: