Booting the host OS

You can use any distribution that can use the rpm package manager. Even if the host distribution doesn't use rpm natively.

If you're using a CentOS installion CD, either CD or DVD 1, or a live CD, boot the CD with:

linux rescue 

or alternatively:

linux text 

to start in a "text mode" ("TUI") console. If you have already booted into the "graphical" ("GUI") install environment, once it progresses a bit, when the installation interview reaches the partitioning questions, you may type: ctrl-alt-F2 This will get a text console in which to work on partition details. Once you are satisfied with, and have saved the partitioning information in the TUI console, reboot the installation, and work forward from that partitioning by simply typing:


in that TUI panel.

Additionally you may optionally choose to provide a vga= parameter in the initial boot time options, in order to have a larger framebuffer display window.

The following setup was done on a debian stable (stretch) livecd, but the steps should be very similar on any moderately modern system.

Install the needed tools on the host operating system

# apt-get update
# apt-get install rpm yum curl mdadm lvm2 xfsprogs

Disk setup

First, setup your disks to your liking. You can use whatever partitioning scheme you prefer here, RAID, LVM, etc... Remember your disk configuration because you'll need it to configure grub, menu.lst and fstab.

It is recommended to use gpt partition tables since only these will support modern large hard drives and UEFI booting. Before starting the partitioning process you will need to decide whether you want to use UEFI or MBR boot method, since this will influence the number and types of partitions you will need as well as the RAID versions used if the installation needs RAID.

In fdisk, g creates a new GPT partition table.

# fdisk /dev/sda
Command (m for help): g

You will need to setup a number of different partitions depending on your needs. To boot using UEFI, you will need a small "UEFI system" type partition formatted as fat (you will need to set the type of the partitions in fdisk). You can use software raid1 on this partition if you want to, but will need to use --metadata=0.90 flag when creating the raid array. To boot using MBR, you will need a small "BIOS boot partition" type partition at the beginning of your device.

example: set a partition's type to BIOS boot partition in fdisk

# fdisk /dev/sda
Command (m for help): t
Partition number (1-3, default 3): 1
Partition type (type L to list all types): L
  1 EFI System                     C12A7328-F81F-11D2-BA4B-00A0C93EC93B
  2 MBR partition scheme           024DEE41-33E7-11D3-9D69-0008C781F39F
  3 BIOS boot partition            21686148-6449-6E6F-744E-656564454649
Partition type (type L to list all types): 3

If using RAID, I would recommend creating a separate boot partition using RAID1 (and setting up the UEFI system partition on RAID1 aswell), while the rest of the system (/, /home, ...) can be on any combination of raid levels and lvm you choose. The default filesystem on centos is xfs, so once the partitions, raid and lvm are set up, use mkfs.xfs to create the /boot and / filesystems, and mkfs.vfat to create the UEFI system partition if needed. If using an older mkfs version, I recommend using the mkfs.xfs -m crc=1 option to enable crc on metadata of the filesystem. This is the default on modern versions of the xfsprogs tools.

Next, a location is set up in the existing filesystem, to build the new installation in, and the partitions hung at the relative slash and ./boot positions:

# mkdir /target
# mount /dev/sda3 /target
# mkdir /target/boot
# mount /dev/sda2 /target/boot

If using booting with UEFI, mount the UEFI system partition

# mkdir /target/boot/efi
# mount /dev/sda1 /target/boot/efi

Install the system

Here use the latest version of the centos-release package from the centos mirrors (you can find it on the listing)

# rpm --root /target -i
# mkdir -p /etc/pki/rpm-gpg && cp /target/etc/pki/rpm-gpg/* /etc/pki/rpm-gpg
# yum --installroot=/target --releasever=7 install yum

Prepare the chroot

# cp /etc/resolv.conf /target/etc
# mount --bind /dev/ /target/dev/
# mount -t proc procfs /target/proc/
# mount -t sysfs sysfs /target/sys/

If booting with UEFI:

mount -t efivarfs efivarfs /target/sys/firmware/efi/efivars/

Enter the chroot

# chroot /target

Reinstall package managers and base packages

# yum --releasever=7 install yum centos-release
# yum install @core @base redhat-lsb-core dracut-tools dracut-config-generic dracut-config-rescue

Configure software RAID arrays if you use RAID

# mdadm --detail --scan > /etc/mdadm.conf

Install the bootloader

You can choose not to install the UEFI bootloader if you are not booting UEFI.

# yum install grub2 grub2-efi efibootmgr
# cat > /etc/default/grub << EOF
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet consoleblank=0"

If booting using MBR, install grub to the MBR and create configuration:

# grub2-install /dev/sda
# grub2-mkconfig -o /boot/grub2/grub.cfg

If you use multiple disks (i.e. boot on raid1, you can install it to each of the boot disks).

If booting using UEFI, create the UEFI boot entry and generate grub configuration. It is assumed here that partition #1 on sda is the UEFI system partition:

# efibootmgr -c -p 1 -d /dev/sda -L "centos sda" -l '\EFI\centos\grubx64.efi'
# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

If you use multiple disks (i.e. boot on raid1, you can create an entry for each of the boot disks). check with efibootmgr -v if your bootentry is listed first in the boot order, otherwise to delete entries, use

# efibootmgr -b entrynum -B

or to change the boot order use

# efibootmgr -o bootnum,nextbootnum,nextnextbootnum

Set up the system

Networking setup

Add your hostname to /etc/hosts:

# cat /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 myhostname.domain.tld myhostname

Predictable network interface names

The name of the network device will be one of these (probably), for me it was ID_NET_NAME_ONBOARD for a phisical machine, I have found no way of reliably predicting this for a virtual machine. If you use a sufficiently modern system to bootstrap from, it might (or might not) be the same name as the name on your system, depending on systemd and udev versions and configuration. you may also want to disable this feature, for this you can search for disabling predictable network interface names.

# udevadm test-builtin net_id /sys/class/net/eth0 2> /dev/null

network scripts

# echo "NETWORKING=yes" > /etc/sysconfig/network

DHCP configuration for an interface:

# cat > /etc/sysconfig/network-scripts/ifcfg-eno1 << EOF

Enable journald

# mkdir /var/log/journal
# chgrp systemd-journal /var/log/journal
# chmod 2755 /var/log/journal
# systemctl enable systemd-journald

relabel filesystem with correct selinux labels

# touch /.autorelabel

create /etc/fstab

Populate /etc/fstab with entries for at least / and /boot, /boot/efi if needed. I recommend using UUIDs, use blkid to find out the UUID of each partition.

# cat /etc/fstab
UUID=5ee0f2e5-0e9c-4fe4-a8b8-c5a0f3e1f9f3       /       xfs     defaults        0 0
UUID=e63ef796-a478-4388-9713-804588c86cd9       /boot   xfs     defaults        0 0
UUID=dfdd57a6-39cf-4613-9764-0c2169dbec11       swap    swap    defaults        0 0

finishing up

Set the root password

# passwd
Changing password for user root.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

Set the timezone

for example, to set the timezone to Europe/Paris:

# cd /etc
# rm localtime
rm: remove symbolic link ‘localtime’? y
# ln -s ../usr/share/zoneinfo/Europe/Paris localtime

Exit the chroot, then unmount everything in it

# mount |grep target |awk '{ print $3 }' |xargs umount -lf

reboot. At first login, run the following as root to finish setting up the machine:

# hostnamectl set-hostname myhostname
# localectl set-locale LANG=en_US.utf8

Post installation tips

Right now you should have a bootable system! Here are some tips to help you through your first boot

System configuration

Many of the system configurations happens in /etc/sysconfig See


for full documentation.

Configure your keyboard in /etc/sysconfig/keyboard using the KEYTABLE variable


Take a look at /etc/sysconfig/network-scripts/ See ifcfg-lo for an example.

HowTos/ManualInstall (last edited 2017-10-27 13:32:54 by JohnSoros)