Installing from the Live USB to an MBR Drive - sakaki-/funtoo-2-gentoo GitHub Wiki
Install a GNOME 3.14 / Gentoo / OpenRC system to your PC's (MBR) hard drive in under 15 minutes, from a running live-USB session!
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 wish to use a conventional MBR-style approach. If you'd rather use a UEFI BIOS / GPT-formatted disk (and stub-EFI kernel), 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
- if it is not, modify the paths given accordingly (you can check with the lsblk
command).
Per the Gentoo Handbook, we will go for a simple layout here, with 4 primary partitions (modify as desired):
Partition | Size | Filesystem | Description |
---|---|---|---|
/dev/sda1 | 2MiB | N/A | BIOS boot partition |
/dev/sda2 | 256MiB | ext2 | Boot partition |
/dev/sda3 | 5GiB | swap | Swap (if 4GiB RAM, hibernation wanted) |
/dev/sda4 | 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 o and Enter (to create a new partition table)>
<type n and Enter (to create a new partition)>
<press Enter (to make a primary partition)>
<press Enter (to define partition 1)>
<press Enter (to accept the default start location)>
<type +2M and press Enter (to make a 2MiB sector, for BIOS boot)>
<type t and press Enter (to change the sector type)>
<type ef and press Enter (to set the sector type as EFI (even though MBR booting))>
<type n and Enter (to create a new partition)>
<press Enter (to make a primary partition)>
<press Enter (to define partition 2)>
<press Enter (to accept the default start location)>
<type +256M and press Enter (to make a 256MiB sector, for boot)>
<type a and press Enter (to turn the boot flag on)>
<type 2 and Enter (to change the boot flag on sector 2)>
<type n and Enter (to create a new partition)>
<press Enter (to make a primary partition)>
<press Enter (to define partition 3)>
<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 3's type)>
<type 82 and press Enter (to set the type as swap)>
<type n and press Enter (to create a new partition)>
<type p and press Enter (to make a primary partition)>
<press Enter (to define partition 4)>
<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:
# mkfs.ext2 -L "boot" /dev/sda2
# mkswap -L "swap" /dev/sda3
# mkfs.ext4 -L "root" /dev/sda4
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/sda2 /mnt/sdaboot
# mount /dev/sda4 /mnt/sdaroot
Then copy the kernel and its configuration (there is no initramfs used on the live USB):
# cp -ax /boot/* /mnt/sdaboot/
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-mbr /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 Bootloader
Our last task is to install the GRUB bootloader into our new system (which is otherwise complete). We'll quickly chroot
in to do this. Issue:
# cd /mnt/sdaroot
# mount -t proc none proc
# mount --rbind /sys sys
# mount --rbind /dev dev
# mount --rbind /mnt/sdaboot boot
# chroot . /bin/bash
# source /etc/profile
Now we are chroot
ed in, we can set up the bootloader (the package is already emerged); issue:
# grub2-install --no-floppy --target=i386-pc /dev/sda
# grub2-mkconfig -o /boot/grub/grub.cfg
If those commands completed without error, you should be good to go! Exit the chroot and dismount:
# sync
# exit
# umount -l boot proc sys dev
# cd
# 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. If all is well, you should get a GRUB screen, after which your kernel should boot, 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 bothroot
anddemouser
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.