CentOS8 basic setup

6 minute read

This is a basic setting memo for myself regarding the installation of CentOS8 series. Contains a lot of hobby ingredients.
During the actual installation, it is necessary to carefully check the installation requirements and replace the setting values as appropriate.

Obtaining installation media

Obtain the installation media from the following. For building a local repository (described later), drop the largest CentOS-8.X.XXXX-x86_64-dvd1.iso file.


Insert the installation media into the machine and boot the media. In order to deal with the problem that the screen is cut off in the image, the resolution is specified.
** How to specify the resolution: ** ʻInstall CentOS Linux 8 is selected, press the Tab key, add resolution = 1280x768` after the character string displayed at the bottom of the screen, and then press the Enter key.


Set the installation language to Japanese.


There are some setting items, but make the basic settings in the order of “Network and host name”, “Time and date”, “Software selection”, and “Installation destination”.


Network and host name

Assign the host name and IP address. The network settings differ depending on the environment, so please use the images as a reference only.




Time and date

NTP is available if the network is set up without any problems. Here, set the time zone to Japan time and synchronize it with the time server ntp.nict.jp that exists in Japan.



Software selection

The default is “Server (using GUI)”, but I want to change it to “Minimal installation” because I want to add what I need later.


Place of installation

If you install it with automatic configuration, you will end up with a strange partition setting that allocates a tremendous amount to / home, so be sure to customize it.
The / boot area where the kernel is placed is about 512MB of ext4, and the rest is allocated with xfs as the root partition. Very rarely, there is software whose file system does not support xfs, so if you are afraid to start over, you should build it with ext4.



You may be asked “What is a swap partition?”, But in recent years it is mostly built in a virtual environment, and considering that the amount of physical memory fluctuates, we will make it possible to flexibly set it as a swap file. Therefore, at this point, we will not create a swap partition and will mount it as a swap file later.

Start installation

After completing the above settings, start the installation. Set the root password during installation.


Initial setup

After the installation is complete, you will be able to access SSH.

Media local repository construction

The installation media contains a lot of commonly installed software. By building these as a local repository, you can install them to some extent even in an offline environment.


# mkdir /mnt/cdrom
# mkdir -p /root/repo/CentOS-8.2.2004-x86_64

##In the case of an environment where media can be read normally
# mount /dev/cdrom /mnt/cdrom
##In an environment where media cannot be read but ISO can be placed(AWS etc.)
# mount -o loop -t iso9660 /root/CentOS-8.2.2004-x86_64.iso /mnt/cdrom

# cp -vrp /mnt/cdrom/* /root/repo/CentOS-8.2.2004-x86_64/
# umount /mnt/cdrom

# vi /etc/yum.repos.d/CentOS-8.2.2004-Media.repo


name=CentOS-8.2.2004-Media - BaseOS

name=CentOS-8.2.2004-Media - AppStream


# dnf repolist
repo id name of repo
AppStream                              CentOS-8 - AppStream
BaseOS                                 CentOS-8 - Base
CentOS-8.2.2004-Media-AppStream        CentOS-8.2.2004-Media - AppStream
CentOS-8.2.2004-Media-BaseOS           CentOS-8.2.2004-Media - BaseOS
extras                                 CentOS-8 - Extras

Media local repositories only

Although I built a local repository, the latest online repository will also be referenced as it is. Disable it with the following command.


# dnf config-manager --disable AppStream BaseOS extras
# dnf clean all
# dnf repolist
repo id name of repo
CentOS-8.2.2004-Media-AppStream        CentOS-8.2.2004-Media - AppStream
CentOS-8.2.2004-Media-BaseOS           CentOS-8.2.2004-Media - BaseOS

If you want to use the latest repository, you can install it consciously by doing the following.


# dnf --enablerepo=BaseOS install package-name

Disable SELinux

It’s not very good, but most systems require you to disable SELinux, so I’ll disable it from the beginning.


# cp -p /etc/selinux/config /etc/selinux/config.default
# sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# reboot

Firewall out

Like SELinux, it’s not very good, but most systems require you to disable the firewall, so I’ll disable it from the beginning as well.

# systemctl stop firewalld
# systemctl disable firewalld

[Option] Creating a swap area

As insurance when the amount of physical memory installed is exceeded, a swap file is created and recognized as a swap area.


# # 128MiB x 64 =It takes time to create 8GiB, so it is recommended to use screen.

# dd if=/dev/zero of=/swapfile bs=128M count=64
# chmod 600 /swapfile
# mkswap /swapfile
Set swap space version 1. size= X GiB (xxxxxxxxxxxxx bytes)
No label, UUID=xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx

# swapon /swapfile
# swapon -s
Filename Type Size Used Priority
/swapfile                               file            XXXXXXX 0       -2

# #Set the swap area to be mounted even after rebooting
# cp -p /etc/fstab /etc/fstab.default
# vi /etc/fstab


/swapfile swap swap defaults 0 0

Try rebooting and make sure the swap area is mounted.


# reboot
# swapon -s
Filename Type Size Used Priority
/swapfile                               file            XXXXXXX 0       -2

There may be pros and cons to the swap area of the file format, but I personally think that it is flexible.

[Option] Installation of various tools

If you have a minimum installation, you may not be able to use commands that are frequently used.
Here, I will install the ones that I often use. There are some hobbies, so please check the requirements carefully before deciding whether to introduce it.


# dnf install tar wget telnet tcpdump bind-utils net-tools traceroute lsof vim rsync nfs-utils samba-client cifs-utils unzip
  • tar: Used for decompressing tar files. I don’t think it will be used, but it doesn’t seem to be included in the minimum installation of CentOS8.
  • wget: Used to get the content on the web as a file. I think you should use curl, but it’s a very familiar command, so I’ve included it.
  • telnet: Allows telnet connection. This command is used quite often, such as for operation tests and maintenance work.
  • tcpdump: Packet capture tool. It is used for maintenance work. The capture data acquired by this command can be confirmed with WireShark, which is famous for the Windows version packet capture tool.
  • bind-utils: Used for maintenance work related to DNS. The nslookup and dig commands will be available.
  • net-tools: From RHEL7 series, net-tools has been abolished and replaced with iproute (iproute2). However, although it is deprecated, the knowledge base accumulated so far has overwhelmingly many commands of net-tools itself (ifconfig, netstat, etc.), so if you want to make use of it, you need to include this. I think that it will be completely abolished soon, so I feel that it should be migrated as soon as possible.
  • traceroute: A command to trace the NW route. It is often used when there is a problem with the NW.
  • lsof: You can inspect open files. Occasionally used for maintenance work.
  • vim: CUI text editor. Vi is enough until then, but since it is convenient with various functions added, I will put it in for the time being.
  • rsync: It’s like robocopy on Windows. I use it instead of scp as well as maintenance, and I decided that rsync should be installed because it is necessary to install it on the other side as well.
  • nfs-utils: Allows NFS mounting.
  • samba-client, cifs-utils: Allows you to mount SMB / CIFS shares.
  • unzip: Required when unzipping the zip archive.