Automatic Fan Control for PowerEdge R710

There are various guides online for controlling the fan speed of you R710 through IPMI. And I used them and others to make my own script.

For me, I was not able to get IPMI working through an Ubuntu VM so I made a CentOS 7 container thats sole purpose is to update the fan speed of the R710.

First I created a new direcory mkdir /scripts and added a new file nano r710-fan-control.sh

inside of that new file I wrote of the script:

#!/bin/bash

IPMIHOST=192.168.1.114
IPMIUSER=root
IPMIPW=calvin
IPMIEK=0000000000000000000000000000000000000000

TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK sdr type temperature |gr$

ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00

if [[ $TEMP = 25 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 2 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x02
elif [[ $TEMP = 27 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 2 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x02
elif [[ $TEMP = 28 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 3 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x3
elif [[ $TEMP = 29 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 3 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x3
elif [[ $TEMP = 30 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 3 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x3
elif [[ $TEMP = 31 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 4 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x4
elif [[ $TEMP = 32 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 4 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x4
elif [[ $TEMP = 33 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 4 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x4
elif [[ $TEMP = 34 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 5 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x5
elif [[ $TEMP = 35 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 5 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x5
elif [[ $TEMP = 36 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 10 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0xA
elif [[ $TEMP = 37 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 10 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0xA
elif [[ $TEMP = 38 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 15 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0xF
elif [[ $TEMP = 39 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 15 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0xF
elif [[ $TEMP > 40 ]]; then
	printf "Temp is ($TEMP C) Setting Fans to 75 percent"
	ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x4B
fi

It's a bit overkill but I like having a bit more of a fine control over my fans.

After that I made it executable with chmos +x r710-fan-contro.sh

Then I need to install it in a cron job. I wasn't sure how to do that with the deault editor for centos so I changed the default editor to nano with the commands:

yum -y install nano
cat <<EOF >>/etc/profile.d/nano.sh
export VISUAL="nano"
export EDITOR="nano"
EOF

then i entered crontab -e to make a new command

I entered */5 * * * * /scripts/r710-fan-control.sh >> /scripts/temp.log 2>>&1 so that i could have the command run every 5 minutes and have the results of the script put into a log file in the same folder the script is in.

That about sums it up. Now i have a fully working fan speed adjuster for my R710. And if it turns out that it's not regulating effectivlythen i can just go in an edit the script when i need to.

Edit:

I also made a seperate script that timestamps the entries and then writes them to the log

the script was created at nano timestamps.sh and the scripts is:

#!/bin/bash

 while read x; do
		echo -n `date +%d/%m/%Y\ %H:%M:%S`;
		echo -n " ";
		echo $x;
 done

Just make that executable and edit the cronjob to be */5 * * * * /scripts/r710-fan-control.sh | /scripts/timestamp.sh >> /scripts/temp.log 2>&1


Transferring VM's from one server to another in Proxmox

Introduction

I recently got a new server (PowerEdge R710) and so I need to transfer the VM's that I have on my existing server over to the new one. There are a couple ways to do this but I chose to go with the backup to an external hard drive and then restore onto the new system.

Steps

Though some trial and error I determined how to get it done:

  1. First I erased every partition on the new hard drive using fdisk first I found the new drive's ID using fdisk -l
  2. Then I used fdisk /dev/sdc/ to go into the drive and delete every partition on the drive.
  3. I created a new partition and then changed the type to a linux LVM using the hex code 31
  4. After that I wrote those changes to disk
  5. I then created the file system for the disk with mkfs.ext4 /dev/sdbc1
  6. Then all that's left to do is create a new directory to mount it in with mkdir /external/usb-drive and then mount it with mount /dev/sdc1 /external/usb-drive
  7. Now you sould be able to go into Proxmox and add the new drive as a direcotry with the path to the drive as /deb/sdc1 in the web GUI

Now that we have a bunch of backups we now need to get them over to the new server. So I unmounted my usb drive with umout /external/usb-drive, plug it into the new server and mount it.

To restore the VM's to the new server, simply go to the disk, select the backup you just made, and then press the restore button in the web GUI. Let that run all the way through and you should be good to go!


Install Docker CE on Ubuntu 18.04.2 LTS

Introduction

I've decided to spin up a new VM to see what all the fuss abut Docker is about. I'll be following the guide on the official docker docs website which I will link to at the bottom of the post.

I'm going to set it up using repositories so that it will be easier to update in the future.

Installation

First i updated the package index and installed the ability to use repositories over https:

sudo apt-get update

sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

	

Then I added Dockers GP key with curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

I set up the repository for smd 64bit with

sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"

Run a package update again and then use sudo apt-get install docker-ce docker-ce-cli containerd.io to install docker

Then to test that it was working I ran sudo docker run hello-world

It seems everyting was installed correctly so I'm going to move on to some post install

Post Installation

To enable Docker to start on boot I'll simply run sudo systemctl enable docker

I'll also add docker as a user and group so that it can be accesses more easily from a non root-user account

First sudo groupadd docker Then sudo usermod -aG docker $USER

You should be able to run commands without sudo now.

Quick Links

Docker Install Guide Docker Post Installation Getting Started Guide


Plex Update on Ubuntu 18.04.2 LTS

Introduction

So recently I've been having an issue with my Plex Media Server (PMS) where the Hama scanner plugin gets stuck in a constant loop maxing out one core of my cpu to endlessly scan my files. Not sure why this is, most likely cause is a corrupt media file somewhere. So While I'll probably eventually have to find that file at some point I thought I'd take the time to update plex and the Hama plugin at the same time.

Updating Plex

Because I have the Plex distribution package enabled I can simply use sudo apt update && sudo apt upgrade to update all packages including Plex. Then the service needs to be restarted with sudo service plexmediaserver stop

However, this did not fix the issue with the scanner, so I now have to update that separately because it's not a stock service but a plugin i added.

Updating Hama

Luckily there is a handy sequence of code that someone wrote up to install and update Hama and ASS easily and quickly. So I ended up plugging those into my system and they worked like a charm. I did have to sudo rm a file when it was getting stuck, but once that was finished everything else worked like it should.

sudo service plexmediaserver stop cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-ins/Hama.bundle sudo git reset --hard && sudo git pull cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Scanners/Series/ wget -N https://raw.githubusercontent.com/ZeroQI/Absolute-Series-Scanner/master/Scanners/Series/Absolute%20Series%20Scanner.py && cd sudo chown -R plex:plex /var/lib/plexmediaserver sudo chmod 775 -R /var/lib/plexmediaserver sudo touch /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Data/com.plexapp.agents.hama/StoredValues sudo chmod 777 /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Data/com.plexapp.agents.hama/StoredValues sudo chown plex:plex /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Data/com.plexapp.agents.hama/StoredValues sudo service plexmediaserver restart

Final Notes

It seems that everything is now working as it should. Looks like it wasn't a corrupt media file after all but rather a a corrupt file in the Hama scanner files. I should not that I also made sure to optimize the database and clean the bundles after most steps throughout this process.

Hopefully everything stays working from now on!

Quick Links

Plex Install Guide Hama and ASS Install Guide


Creating a Minecraft Server on Ubuntu 18.04

Introduction

I decided to try and get a small minecraft server running on a Linux server because, why not?

So I spun up a new VM of Ubuntu 18.04 and went to work.

Installation

First update everything apt update && apt install git build-essential

Then get Java installed, but the headless version of Java, cause, well, server apt install openjdk-8-jre-headless

Create a new user to run the minecraft instance instead of the root sudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft

switch to the minecaft user su - minecraft

Although in my case, during the installation of the VM I created a user "minecraft" so I didn't need to manually create one.

Navigate to the /server directory and download a new server jar. I used BuildTool to create a new jar file. using wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar to download the new tools and then I ran java -jar BuildTools.jar --rev 1.13.2 to get a new server build and move that into the /server directory if it isn't already.

From there run java -Xmx4G -Xms2G -d64 -jar server.jar nogui in the /server directory and then it will generate the initial files for the server.

Edit the server.properties file and change the following values rcon.port=25575 rcon.password=strong-password enable-rcon=true

Final Notes

Now from there everything should be good to go. I ended up adding plugins to the generated plug in folder using a new sftp connection from another computer on my network. I'm still in the process of configuring those plugins and such but overall the server is up and running.

Things to still do are port forward the re correct port on my router to access the server outside of the local network.

Quick Links

Reference Install Guide Server Jar Builder