User:Gavlee/LVM install alternative

This is a log of installing Gentoo on LVM from an existing Ubuntu installation. The method of booting is BIOS and MSDOS style partition table. It's possible to adapt this for different method but due to hardware this was not tried. The installation is possible to be completed over one evening.

Objective

 * Install Gentoo to split LVM partitions, fixing Ubuntu and its GRUB detection problems.

Requirements

 * Existing Linux installation.
 * LVM tools installed.
 * Free space for LVM partitions.

Installation
The installation is meant to achieve the same result as the handbook while being in a full Linux system. Some parts deviate from the handbook in the case of ordering and by being on an alternative operating system media than Gentoo.

It's possible to resume installation or emerge more software inside the chroot at any time by mounting the file systems again at the correct points and following on from where the installation was left off.

Su
Get root to do administrative tasks.

LVM Partitioning
Use cfdisk or another disk partitioner if needed create some partitions for LVM if they do not exist already. Here these were already prepared which were empty, ready for any operating system.

Now allocate the partitions to volumes for LVM

Create volume group gvg0 on /dev/sdb7 and extend the group with the partition volumes on /dev/sdb8, /dev/sdb9 and /dev/sdb10

Create the logical volumes on the volume group gvg0

Creating the filesystems
Create the filesystems and swap

Preparing mount points
Create the root directory for gentoo and mount the root filesystem there.

Mount the LVM logical volumes inside the root filesystem.

Fix up the tmp dir permissions.

Change current working directory to the mounted gentoo root directory.

Stage3
Fetch the Gentoo stage3

Check the download isn't corrupted. checking the authenticity is a good idea too, from the handbook.

Unpack the stage3

Edit compiler flags and add split-usr to USE (FIXME: is this needed?)

repos.conf
Set up repos.conf for portage and any overlays.

DNS / resolv.conf
Set up the DNS resolver.

On Ubuntu, the /etc/resolv.conf is a non-usable file with dns pointing to 127.0.0.53, copy the real one so the gentoo chrooted system can use it properly after reboot.

Pseudo-filesystems
Mount the pseudo-filesystems, this is important for the chroot to function correctly.

Some /dev/shm trickery follows, from the alternative OS install method. This may be necessary.

Chroot
Time to chroot.

Configuration
Get the portage tree so emerge can install software.

Selecting a portage profile
List and select profile according to use case and requirements.

Select Gentoo mirrors
Use mirrorselect to get fast mirrors, this will pull in quite a few dependencies. The mirrors can be set manually instead if they are known, to save installing them.

Setting architecture specific compiler flags
Set architecture specific cflags early in the process.

Update the system
Do a quick update and rebuild any use flags that changed.

Configuring time zone
Configure the time zone to appropriate locality.

Configuring Locales
Configure the locales.

Generate the locales and set them with eselect

Updating the environment
Update the environment to propagate changes

Selecting a kernel
Emerge the kernel sources and genkernel to build them, acceptance of the license for firmware is required.

Installing LVM
Install lvm2 so the tools are available and activated on boot.

Checking loaded kernel drivers
To configure the kernel, it's sometimes useful to see what kernel modules are loaded on a running Linux system. List modules currently loaded on the system with and the -k option.

Creating a kernel configuration
Change to the kernel source directory and create a kernel configuration.

Compiling the kernel
Backup the kernel configuration and start compiling the kernel.

Setting up fstab
While compiling, edit fstab and set up the mounts for the system.

Building the initramfs
Build the initramfs with lvm using genkernel (easy peasy method)

Networking
Set up hostname, DNS domain, DHCP networking for wired network.

Install netifrc for DHCP

Startup configuration
Set parallel startup will make the boot process faster.

Setting keyboard mappings
UK keymap

Setting up the clock
Whether local/utc clock, if dual booting.

Setting a root password
It's probably a good idea to set a root password here.

Installing system software
Install system logger, a cron daemon, locate, dhcpcd and filesystem tools then add them to default runlevel to start on boot

SSH server
If ssh is required, add it to the run level to start on next boot.

Serial consoles
Optional but sometimes serial console is needed..

Setting up GRUB
Time to get grubby for booting. Add dm and mount support to grub for lvm. Add BIOS and EFI support to make.conf, then install grub and os-prober. Finally, install grub to boot drive and run setup to create the grub configuration.

BIOS (This was what was used here)

UEFI

Add dolvm as a kernel boot parameter, this is important to boot with lvm also, when using genkernel to build the initramfs, the root=/dev/ram0 and real_root= pointing to the root is sometimes necessary.

Creating a login user
Make a regular user to login with.

Clean up
Remove the install stage3 tarball when not needed.

Next steps
It's reasonable to reboot here but since being in the chroot, it could be useful to emerge while in a working environment. Install the required software while still working and reboot into new environment after the needed software is installed.

Unmounting filesystems
Finish up and unmount the file-systems to sync all the data

Reboot
Reboot when necessary.

Acknowledgments
There used to be a document describing LVM install method. This must have disappeared somewhere so the aim was to try a Gentoo install remembering those steps. The method is a little different by using an existing Ubuntu installation rather than installing from Gentoo media. The Gentoo Handbook and installation alternatives document was used as a reference for the install, and credit to flameeyes for writing the how-to document for the LVM installation method which this document was inspired from.