Month: December 2020

How to install NVIDIA driver (proprietary) and uninstall Nouveau driver (open source) in Linux server

  • Start your Linux server in text mode. GUI mode will give an error while uninstalling the Nouveau driver or installing the NVIDIA driver.
  • Remove Nouveau driver: Open /etc/default/grub in text editor [vi] and add the following option to GRUB_CMDLINE_LINUX

modprobe.blacklist=nouveau

  • On root shell, execute the following command to build the /boot/grub2/grub.cfg as follows:

grub2-mkconfig -o /boot/grub2/grub.cfg [BIOS servers]
grub2-mkconfig -o /boot/efi/EFI/seimaxim/grub.cfg [UEFI servers]

  • Reboot Linux server.
  • Install NVIDIA driver: Download NVIDIA driver from the NVIDIA website. Use YUM to install the following dependencies.

yum install gcc make kernel-headers kernel-devel acpid libglvnd-devel pkgconfig libglvnd-glx libglvnd-opengl

  • Build initramfs: Backup current initramfs.

mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img

  • Install new initramfs.

dracut /boot/initramfs-$(uname -r).img $(uname -r)

At this point, a server reboot is required. After the server comes up, check if the NVIDIA driver module is loaded.

Change hostname and IP address of Linux server without rebooting server

You can change option in third line in /etc/hosts file on Linux server without rebooting;

/etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.1 server.seimaxim.com seimaxim

You can change all of the following options in /etc/sysconfig/network without reboot.

/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=server.seimaxim.com
GATEWAY=192.168.0.1

Similarly options in /etc/sysconfig/network-scripts/ifcfg-eth0 can also be changed.

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0

Hostname of server can be changed with;

hostname server.seimaxim.com

Restart network with;

systemctl restart network

Error while configuring IP in ifcfg-eth0 on Linux Server “RTNETLINK answers: network is unreachable”

  • This error may arise if the IP address and Gateway subnets are different. Make sure both IP address and Gateway have the same subnets. For reference, the ifcfg-eth0 configuration file is given below.

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eth0"
UUID="3d9bd3c7-310c-4e46-a57c-5b3a99819f78"
DEVICE="eth0"
ONBOOT="yes"
IPADDR="37.48.96.245"
PREFIX="27"
GATEWAY="37.48.96.254"
DNS1="8.8.8.8"
IPV6_PRIVACY="no"

  • Remove route entry from etc/sysconfig/network-scripts/route file.

Rebuild initial ramdisk image in Linux server – How-To

You may need to rebuild initial ramdisk image after adding new hardware or software to server.

  • Create backup as shown below;

cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).bak.$(date +%m-%d-%H%M%S).img

  • Use following command to rebuild initramfs

dracut -f -v

  • Make sure /boot/grub2/grub.cfg and /etc/grub2.cfg includes the menu to the new custom initramfs
  • Rebuild grub.cfg;

grub2-mkconfig -o /boot/efi/EFI/seimaxim/grub.cfg

Adding disk space from non-root-LVM to root-LVM

  • All users should be logged out of server except root.
  • Fsck the filesystem.
  • Reduce the non-root LVM by entering following command on root shell;

lvresize --resizefs --size

lvresize --resizefs --size -200G /dev/VolGroup00/LogVoL-USER

  • After non-root LVM filesystem is reduced, increase the root-LVM filesystem using;

lvresize --resizefs --size +500M /dev/VolGroup00/LogVol-ROOT

  • Mount the filesystem.

Disable Transparent Huge Pages [THP] in CentOS 8

On CentOS 8, In file editor open /etc/default/grub file, and add “transparent_hugepage=never” kernel parameter on the GRUB_CMDLINE_LINUX in options as shown below;

GRUB_CMDLINE_LINUX="options transparent_hugepage=never"

On command line execute grub2-mkconfig to build /boot/grub2/grub.cfg

grub2-mkconfig -o /boot/grub2/grub.cfg [System with BIOS]
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg [System with UEFI]

Reboot Server to apply changes. If THP is still not disabled, stop tuned with

tuned-adm off

Add “transparent_hugepage=never” kernel parameter in /etc/default/grub file and reboot server.

How to measure maximum available network speed of your Linux server?

You can use iperf that use client and server scenario to test network speed between two Linux based servers. The tool iperf is available in EPEL free repository else you can download from https://iperf.fr/iperf-download.php

The following iperf command will send a buffer size enough to test network speed for 120 seconds

iperf3 -i 5 -t 120 -c <hostname or ip address of server>

On the server side, start iperf with iperf3 -i 5 -s

iperf server listens on TCP port 5201. Allow port 5201 in server firewall to allow server-client connection. If you want to change server listening port use -p option on command line.

Other alternative tools to iperf is ttcp, nc, and netcat.

Why do Linux Kernel log “martian source” in log file /var/log/messages?

Mention of martian source in file /var/log/messages indicates a packet received on the active network interface eth0 whose source or destination IP address is not correct. An example of this scenario is source network IP address is already configured on current system throwing martian source in log files. All this indicate a configuration error in your system that you need to investigate.

The kernel parameter net.ipv4.conf.all.log_martians controls log entry in /var/log/messages. This is executed when the kernel receives a network packet with an incorrect source and/or destination IPv4 address.

To change behavior, set parameter value in /etc/sysctl.conf with net.ipv4.conf.all.log_martians = 1