2

I have a usb drive with overclockix (debian-based) that I have booted my system from. I am trying to figure out a way to install it to the attached SATA SSD drive. I attempted the following:

I created the following partitions on the SSD with fdisk:

/dev/sda1 /boot ext2 (bootable) 
/dev/sda2 / ext4
/dev/sda3 /var ext4
/dev/sda4 /home ext4
/dev/sda5 none swap
partprobe /dev/sda

I ran mkfs. on each partition and mkswap on sda5.

Then I mounted the partitions:

mount /dev/sda2 /mnt
mkdir /mnt/boot /mnt/var /mnt/home
mount /dev/sda1 /mnt/boot
mount /dev/sda3 /mnt/var
mount /dev/sda4 /mnt/home

Then I copied the files from the USB:

rsync -avp --exclude /proc --exclude /boot --exclude /home --exclude /var --exclude /sys --exclude /dev --exclude /run / /mnt
rsync -avp /var /mnt/var
rsync -avp /boot /mnt/boot 
rsync -avp /home /mnt/home

Then I bind mounted proc, sys, run and dev:

mkdir /mnt/proc /mnt/run /mnt/sys /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /dev /mnt/dev
mount --bind /run /mnt/run

Then I chrooted to /mnt:

chroot /mnt /bin/bash

I created a new fstab:

blkid >> /etc/fstab
vi /etc/fstab
UUID=<UUID> <mpoint> <type> defaults(or sw)  0 2

Then I ran grub-install /boot /dev/sda which returned no errors.

I exited the chroot, unmounted the partitions, removed the USB and rebooted.

I thought that this would create a nearly identical file system as what is on the USB device which would boot with grub. However, I wasn't able to boot from the drive. I am thinking it has something to do with UEFI, but I can't quite figure out what else needs to be done.

Any help is appreciated, thanks.

3
  • UEFI boots from a file on the EFI system partition. You did not create that (nor copy the relevant files to it).
    – Hennes
    Aug 29, 2016 at 21:46
  • Is ext2 a suitable partition type for efi? Aug 30, 2016 at 0:04
  • No. Started to answer that in a comment but it did not fit. Posted as an answer instead.
    – Hennes
    Aug 30, 2016 at 6:37

2 Answers 2

3

Format the boot partition sda2 to Fat32 , it will be used as ESP partition

Mount partitions and replace mount /dev/sda1 /mnt/boot by:

mount /dev/sda1 /mnt/boot/efi

Run:

for i in /sys /proc /dev; do mount --bind $i /mnt$i; done

Get the internet working then change root:

cp /etc/resolv.conf /mnt/etc/
chroot /mnt /bin/bash

Install grub:

apt-get install --reinstall grub-efi
update-grub
exit
for i in /sys /proc /dev; do umount /mnt$i; done

Unmount partions and reboot

1

with UEFI boot

Let me expand on this a bit so that the rest of the answer makes sense:

On old style IBM compatible PCs the firmware is loaded on start. This is usually BIOS firmware and looks for a MBR record on haarddisk, reads that, excutes bootsector, first stage bootloader etc etc. This is the same when booting windows or Linux. You just get different bootloaders. Or even multiple bootloaders, e.g. when you chain windows from grub.

BIOS is a basic system from about 1985 and is somewhat lacking on modern PCs. We just used it for backward compatability.

It since got replaced by EFI. EFI is well defined and much more capable. It does not use a bootsector. Instead it look at a GPT partitioned disk, locate the EFI system partition and reads files from that. Usually that includes something like boot.efi.*1

An EFI System partition must be present to boot from. It must be in a format which your EFI implementation understands. There is one filesystem which is required for EFI to understand, and that one just happens to be 100% compatible with FAT32.*2

Your setup shows you creating several partitions, none of which are the EFI system partition. I think you are following an old guide for BIOS, coreboot or CSM booting.

So much for background and why it did not work, that leaves the main question unanswered though.

How do I install debian linux to ssd from live system with UEFI boot

From wiki.debian.org/UEFI:
"Debian installs grub-efi for its EFI bootloader".

This is an .efi file and it should be installed on your EFI system partition. Which you do not have. Start again, partition the disk with an extra partition with the right type (identifier C12A7328-F81F-11D2-BA4B-00A0C93EC93B). format it FAT32. Read up on grub-efi and make sure that your kernal if UEFI enabled. Then at the right time issue an apt-get install --reinstall grub-efi-amd64 or play around with efibootmgr.



*1: Note: Grub2 is EFI compatible.

*2: One known exception: Apple EFI also groks HFS. As requires it also understands the normal format.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .