Installing from the Live USB to a GPT Drive - sakaki-/funtoo-2-gentoo GitHub Wiki

Install a GNOME 3.14 / Gentoo / OpenRC system to your PC's (GPT) hard drive in under 15 minutes, from a running live-USB session! These notes assume a UEFI BIOS.

Note that this process is strictly optional, you can simply run GNOME from the live-USB (if experimenting), or follow these notes if you'd rather build from source.

Introduction

To make use of these instructions, you'll need to be currently booted into (and logged onto) a GNOME session using the live-USB (see these notes if you haven't yet done so).

Warning - be aware that the below process will wipe any existing software and data on your PC's hard drive, so be sure to back up first, before proceeding.

We're going to assume here that you want to use GPT partitioning on your PC's hard drive, and that you are going to direct-boot the kernel under UEFI (sans bootloader). If you'd rather use the more conventional MBR / GRUB approach, you should refer to these notes instead.

Prepare your PC's Hard Drive

In the following, we'll assume that your PC hard drive is on /dev/sda (you can check with the lsblk command). If it is not, you will have to recompile the kernel, since it has a compiled-in command line that is used when stub-EFI booting.

We will go for a simple layout here, with 3 partitions (modify as desired; however, be aware that the root partition must reside on /dev/sda3 to use the supplied precompiled kernel, again due to the hardcoded command line)):

Partition Size Filesystem Description
/dev/sda1 256MiB fat32 EFI system partition
/dev/sda2 5GiB swap Swap (if 4GiB RAM, hibernation wanted)
/dev/sda3 Rest of drive ext4 Root partition

From your GNOME session on the live-USB, open a terminal, get root, and issue:

Warning - this will delete any data and programs on /dev/sda - only proceed if you are sure!

# fdisk /dev/sda
<type g and Enter (to create a new GPT partition table)>
<type n and Enter (to create a new partition)>
<press Enter (to define partition 1)>
<press Enter (to accept the default start location)>
<type +256M and press Enter (to make a 256MiB sector, for boot)>
<type t and press Enter (to change the sector type)>
<type 1 and Enter (to set as an EFI system partition)>
<type n and Enter (to create a new partition)>
<press Enter (to define partition 2)>
<press Enter (to accept the default start location)>
<type +5G and press Enter (to make a 5GiB sector, for swap; modify as appropriate)>
<type t and press Enter (to change the sector type)>
<press Enter (to accept changing partition 2's type)>
<type 14 and press Enter (to set the type as swap)>
<type n and press Enter (to create a new partition)>
<press Enter (to define partition 3)>
<press Enter (to accept the default start location)>
<press Enter (to use all remaining space on the drive)>
<type p and press Enter (to review the partition table)>
<type w and press Enter (to write the table and exit)>

Next, format the partitions (you will need sys-fs/dosfstools to format the EFI system partition):

# emerge --ask --verbose sys-fs/dosfstools
# mkfs.vfat -F 32 -n "EFI" /dev/sda1
# mkswap -L "swap" /dev/sda2
# mkfs.ext4 -L "root" /dev/sda3

Copy Files from the Live-USB Image

Next, we need to mount the hard drive filesystems, and copy the necessary files across from our running image. Issue:

# mkdir /mnt/{sdaboot,sdaroot}
# mount /dev/sda1 /mnt/sdaboot
# mount /dev/sda3 /mnt/sdaroot

Now we can copy the root partition contents. The process below isn't quite what your mother would recommend ^-^, but it gets the job done (the first line may take some time to complete):

# cp -ax /bin /dev /etc /home /lib /lib32 /lib64 /root /sbin /tmp /usr /var /mnt/sdaroot/
# mkdir /mnt/sdaroot/{boot,media,mnt,opt,proc,run,sys}

As we've just blindly copied over the /etc/fstab file from our running USB system, it will be wrong. A valid fstab (for this partition ordering, assuming /dev/sda) has been provided in root's home directory on the USB image, so copy that over now:

# cp /root/fstab-gpt /mnt/sdaroot/etc/fstab

Lastly for this section, if you have been running sshd from the USB image, you'll probably want to delete your copied host keys (to force a fresh set to be generated for the hard-drive install). Issue:

# rm -f /mnt/sdaroot/etc/ssh/*key*

to do that.

Install Bootable (Stub-EFI) Kernel

Our last task is to install a copy of the kernel to the correct location. We won't need a bootloader here, as the kernel on the image has been built so as to be directly bootable under UEFI. We just need to put it in the correct location. To do this, issue:

# mkdir -pv /mnt/sdaboot/EFI/Boot/
# cp /boot/vmlinuz-3.17.3-gentoo /mnt/sdaboot/EFI/Boot/bootx64.efi
# cp /boot/{config,System.map}-3.17.3-gentoo /mnt/sdaboot/EFI/Boot/

This works because most UEFI systems will boot an appropriately formatted executable at the 'magic' path /EFI/Boot/bootx64.efi on the main drive's EFI system partition.

Lastly, sync filesystems, and dismount:

# sync
# umount -l /mnt/{sdaboot,sdaroot}

Reboot!

Your system is installed! To try it out, just issue:

# shutdown -P now

wait for the PC to power down, and remove the live-USB key. Then, power up again. During reboot, enter the BIOS, and turn UEFI boot on. You should not enable secure boot, however, as the kernel is not signed. Exit the BIOS, saving changes.

If all is well, your PC should reboot directly into your kernel, and then the GNOME login page should come up. If it does, congratulations, you're all done! Login with your existing password (the passwords will have been copied over, along with everything else, from the live-USB).

As a reminder, the password is changeme123 for both root and demouser on the live-USB, unless you have already changed this.

You can now work from your PC without needing the USB key. Feel free to create proper user accounts, modify the configuration to your requirements, emerge any additional packages that you want etc.

Next Steps

Your installed system has eix configured, and I recommend that you use that when syncing, as it will update the overlays too. See these notes for more information.