Where is my software RAID?!

There are a few different ways to view RAID information on Fedora. Here are two commands that can help.

1. Print Mdadm config

You can copy and past the following command to print the mdadm configuration.

cat /etc/mdadm.conf

It should return something similar to the following.

$ cat /etc/mdadm.conf
# mdadm.conf written out by anacondaMAILADDR root
AUTO +imsm +1.x -all
ARRAY /dev/md/Boot level=raid0 num-devices=6 UUID=21ce258a:015d0dd4:90d5b80e:ab04b7f7
ARRAY /dev/md/Root level=raid0 num-devices=6 UUID=4be32ad0:f3aa77bd:139d749d:4a6aab60 

We see from the above output that we have two raid arrays. Both RAID 0 over 6 drives.

2. Print mdstats

You can show the mdstats by running

cat /proc/mdstat

Should get output similar to the following.

$ cat /proc/mdstat
 Personalities : [raid0]
 md126 : active raid0 sdc2[0] sdf2[5] sde2[4] sdd2[1] sda2[2] sdb2[3]
       5856552960 blocks super 1.2 512k chunks
 md127 : active raid0 sdc1[0] sdf1[5] sde1[4] sdd1[1] sdb1[3] sda1[2]
       3133440 blocks super 1.2 512k chunks
 unused devices: 

This shows us the RAID size. About 5TB on one and 3GB on the other. The 3GB is used for the boot partition.

Other Notes

Apparently there is a difference between “mdadm” and “dm-raid”
Mdadm is for managing and creating software raids, while dm-raid interacts if a device like a laptop has a “fake RAID”

https://superuser.com/questions/721795/how-fake-raid-communicates-with-operating-systemlinux/721796#721796
https://stackoverflow.com/questions/23164384/what-is-the-difference-between-dm-and-md-in-linux-kernel

For more information on managing RAID with Mdadm, you can refer here.

Install RX 580 Mining Drivers on Debian Based Distributions

Use wget to download AMD drivers.

wget https://drivers.amd.com/drivers/linux/amdgpu-pro-20.45-1164792-ubuntu-20.04.tar.xz --referer https://support.amd.com

Extract archive.

tar xf amdgpu-pro-20.45-1164792-ubuntu-20.04.tar.xz

Change directory

cd amdgpu-pro-20.45-1164792-ubuntu-20.04

Install AMD Drivers

./amdgpu-pro-install -y --opencl=legacy,rocm --headless

If you run into issues with it saying “Unsupported DEB based OS” Refer to the following article.

Unsupported DEB-based OS: /etc/os-release ID ‘kali’

Unsupported DEB-based OS: /etc/os-release ID ‘kali’

Unsupported DEB-based OS: /etc/os-release ID ‘kali’. You can get the above error if you try to install AMD drivers on Kali Linux. Looks like by default they are looking for a system that is Ubuntu, LinuxMint or Debian.

You can resolve the issue by opening up the “amdgpu-pro-install” file and adding more OS’s that it can check for.

vi ./amdgpu-pro-install

Scroll down to line 147 where is says

ubuntu|linuxmint|debian) 

and change it to

ubuntu|linuxmint|debian|kali)

The code function should look like the following.

142 function os_release() {
143         if [[ -r  /etc/os-release ]]; then
144                 . /etc/os-release
145
146                 case "$ID" in
147                 ubuntu|linuxmint|debian|kali)
148                         :
149                         ;;
150                 *)
151                         echo "Unsupported DEB-based OS: `
152                                 `/etc/os-release ID '$ID'" | stderr
153                         exit 1
154                         ;;
155                 esac
156         else
157                 echo "Unsupported OS" | stderr
158                 exit 1
159         fi
160 }

Save a close the file and install the AMD drivers

./amdgpu-pro-install -y --opencl=legacy,rocm --headless

Looking at trying to install AMD drivers for mining? Check out the following link
Install RX 580 Mining Drivers on Debian Based Distributions

More info on Stack Exchange
https://elementaryos.stackexchange.com/questions/24282/cant-install-amd-drivers-on-elementaryos-hera-unsupported-deb-based-os

An upgrade from ‘disco’ (19.04) to ‘focal’ (20.04) is not supported with this tool.

Unfortunately once a version of Ubuntu becomes unsupported you can run into problems upgrading to the latest version. As is the case when you try to upgrade disco to focal. Ubunut 19.04 to 20.04.

A work around is to update the apt sources and then run an update

Update Apt Sources with.

sudo sed -i 's/disco/focal/g' /etc/apt/sources.list

Now Upgrade with the following two commands.

sudo apt update
sudo apt -y dist-upgrade

More info at the following link.

https://www.knowledgepublisher.com/article/1452/solution-an-upgrade-from-disco-to-focal-is-not-supported-with-this-tool.html

UFW Allow ICMP (ping) Traffic

https://askubuntu.com/questions/6995/how-to-enable-ufw-firewall-to-allow-icmp-response

Open up the UFW before.rules config file

vi /etc/ufw/before.rules 

And make sure you have these rules in it

# ok icmp codes for INPUT
-A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT
-A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT
-A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT
-A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT
# ok icmp code for FORWARD
-A ufw-before-forward -p icmp --icmp-type destination-unreachable -j ACCEPT
-A ufw-before-forward -p icmp --icmp-type time-exceeded -j ACCEPT
-A ufw-before-forward -p icmp --icmp-type parameter-problem -j ACCEPT
-A ufw-before-forward -p icmp --icmp-type echo-request -j ACCEPT

Cannot load Zend OPcache – it was already loaded

Started getting the following error while running ./validate.php for LibreNMS

Cannot load Zend OPcache - it was already loaded

Looks like the problem arises out of PHP trying to load two ini files for OPcache. Was trying to enable OPcache for LibreNMS so I created an opcache.ini file and put the settings in it. I missed the default 10-opcache.ini file.

Moving all the settings into the 10-opcache.ini file and deleting the created opcache.ini file resolved the issue for me.

https://unix.stackexchange.com/questions/253448/php-7-install-throws-cannot-load-zend-opcache-it-was-already-loaded-error/253484

Configure UFW Firewall on Ubuntu

UFW Firewall Status

Below are some simple commands around working with UFW. UFW is included in Ubuntu. However it may need to be enable.

Show status

sudo ufw status

Disable UFW Service

sudo systemctl stop ufw && sudo systemctl disable ufw

Stop UFW Service

sudo systemctl stop ufw

Start UFW service

sudo systemctl stop ufw

Enable UFW

sudo ufw enable

Allow SSH

sudo ufw allow 22/tcp

Show status

sudo ufw status numbered

Example output

sudo ufw status numbered
Status: active
To            Action   From 
--            ------   ----
[1] 3478/udp  ALLOW IN  Anywhere
[2] 5514/udp  ALLOW IN  Anywhere
[3] 8080/tcp  ALLOW IN  Anywhere
[4] 8443/tcp  ALLOW IN  Anywhere
[5] 8880/tcp  ALLOW IN  Anywhere
[6] 8843/tcp  ALLOW IN  Anywhere
[7] 6789/tcp  ALLOW IN  Anywhere
[8] 27117/tcp ALLOW IN  Anywhere
[9] 22/tcp    ALLOW IN  Anywhere

Delete rule

You need to know the number of the rule you want to delete. Replace number with the number of the rule from the status command

sudo ufw delete number

Reset rules

sudo ufw reset

Allow access to port from specific IP address

Example command allows access to SSH (port 22) from the 172.16.0.0/12 ip range.

sudo ufw allow proto tcp from 172.16.0.0/12 to any port 22

One note: It appears that you need to run the rule with every IP range you want to allow.

Allow access to port from all private IP ranges (RFC 1918)

If we wanted to allow SSH (port 22) from all local IP addresses, we would need to run the following three commands.

sudo ufw allow proto tcp from 10.0.0.0/8 to any port 22
sudo ufw allow proto tcp from 172.16.0.0/12 to any port 22
sudo ufw allow proto tcp from 192.168.0.0/16 to any port 22

The following link has more information regarding UFW firewall and subnets.
https://www.cyberciti.biz/faq/ufw-allow-incoming-ssh-connections-from-a-specific-ip-address-subnet-on-ubuntu-debian/

Mount disk by UUID in Linux

Find UUID

blkid

Example output

/dev/xvdb1: UUID="42fbe9a1-eea1-34bc-439d-19a0b48e7df1" TYPE="xfs"

Mount drive using the UUID

[root@host ~]# mount -U 42fbe9a1-eea1-34bc-439d-19a0b48e7df1 /mnt

Add to fstab to automatically mount on system boot up

vi /etc/fstab

Add the following, swap out the UUID for your devices UUID

UUID="42fbe9a1-eea1-34bc-439d-19a0b48e7df1" /backup xfs defaults 0 0

Save and exit. Now when the system reboots it should automatically mount the drive. You should also be able to call “mount -a” to automatically mount everything in fstab.