Resizing an Ubuntu LVM Host!

I spent hours trying to find instructions on how to resize my Ubuntu virtual hosts after one of my cluster workers seemingly ran out of space (randomly). After working out the basics, I was able to resize my drives correctly after assigning them the correct disk size in ProxMox.

root@server:~# fdisk -l

GPT PMBR size mismatch (104857599 != 209715199) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 396A0315-7944-49AC-BBFF-7AD2F7747AC9

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 104857566 102756319 49G Linux filesystem

Disk /dev/mapper/ubuntu–vg-ubuntu–lv: 48.102 GiB, 52609155072 bytes, 102752256 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@server:~# parted
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) resizepart
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an
extra 104857600 blocks) or continue with the current setting?
Fix/Ignore? Fix
Partition number? 3
End? [53.7GB]? 100%
(parted) quit
Information: You may need to update /etc/fstab.

root@server:~# pvresize /dev/sda3
Physical volume “/dev/sda3” changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized

root@server:~# lvextend -l +100%FREE /dev/mapper/ubuntu–vg-ubuntu–lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <49.00 GiB (12543 extents) to <99.00 GiB (25343 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.

root@server:~# resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu–vg-ubuntu–lv is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 13
The filesystem on /dev/mapper/ubuntu–vg-ubuntu–lv is now 25951232 (4k) blocks long.

root@server:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.9G 0 2.9G 0% /dev
tmpfs 595M 1.2M 594M 1% /run
/dev/mapper/ubuntu–vg-ubuntu–lv 98G 32G 62G 34% /
tmpfs 3.0G 0 3.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.0G 0 3.0G 0% /sys/fs/cgroup
/dev/sda2 976M 198M 712M 22% /boot
/dev/loop1 56M 56M 0 100% /snap/core18/1932
/dev/loop2 72M 72M 0 100% /snap/lxd/16099
/dev/loop0 56M 56M 0 100% /snap/core18/1944
/dev/loop3 68M 68M 0 100% /snap/lxd/18150
/dev/loop4 32M 32M 0 100% /snap/snapd/10492
/dev/loop5 32M 32M 0 100% /snap/snapd/10707
tmpfs 595M 0 595M 0% /run/user/1000

Restart 21

Weekly Raw Stats
– Overall weight is down 6.1 lbs
– My Body Fat is down 3%
– My Muscle Mass is up 2.8%
– Bone Mass is up 0.2%
– BMI is down 0.8
– My VO2 max is up
– Sleeping has never been better
– Feeling less stressed

Review
Getting started is definitely the toughest part. Over the last few rides I can definitely feel a change in my breathing which is reflected in my VO2 max score. Also while doing the free-rides I’ve notices a definite change in the effort needed to bike. Theres definitely some new muscle.

NVME Drive Keep Alive Script

Placed in /Scripts/keepalive

 pi@raspberry01:~/Scripts/keepalive$ cat keepalive.sh 
 #bin/bash
 
## BAINWERX
## NVME Keepalive Read|Write Script
## version 1.2
## created Feb 2021

## Time in 12 hr format
 logging_time=$(date +'%r')
 
## backup dir format
 logging_dir=$(date +'%m_%d_%Y')
 
find /home/pi/Scripts/keepalive/*.log -mtime 1 -delete;
 echo "NVME Keepalive Read|Write at" "${logging_time}" >> /home/pi/Scripts/keepalive/"${logging_dir}".log 

Runing this script will create a .log file with a simple write to the nvme drive. Next step wil be to setup a cron task with

sudo crontab -e

add the following lines to enable the script

# nvme drive keepalive by posting to drive every minute
 */1 * * * * sudo sh /home/pi/Scripts/keepalive/keepalive.sh

Now Save and reboot the system.

NOTE

If you are adding this with pihole…you might want to add the following step which will run when the pi is rebooted. It tells the pi that when it reboots…wait 15 seconds and then restart the pihole dns resolution

# On reboot + 15 seconds restart the pihole dns resolver (loop prevention)
 
@reboot sleep 15 && sudo pihole restartdns

Cluster Management with Ansible

Now that I have my “base cluster” up and running with ProxMox, it’s time to turn my attention to how I’m going to manage it.

After creating a new management user I setup ssh certs to permit ssh traffic from the master to slave systems.

Instalation of Ansible was a breeze

$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt-add-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible

After creating an inventory file, and then a quick and dirty playboook...I tested it out and...

voila!

First run went smashing..although it showed that there WAS actually an update or two on 2/3 of the servers.

After running my playbook again it looks like everything was in fact in order.

Ubuntu 20.10 Server Virtualization Challenges

===============================================================

Issue #1 – IP Address not configured correctly

The fix

sudo rm /etc/machine-id
sudo systemd-machine-id-setup
sudo reboot

as per https://jaylacroix.com/fixing-ubuntu-18-04-virtual-machines-that-fight-over-the-same-ip-address/

===============================================================

Issue #2 – Time Sync (aka NTP Server / Client Config)

The fix

setup ntp server on ubuntu01

setup ntp client on ubuntu02 through ubuntu04

as per https://vitux.com/how-to-install-ntp-server-and-client-on-ubuntu/

===============================================================

Issue #3 – Time / Date Appearance

The fix – simple reconfiguration as per https://linuxize.com/post/how-to-set-or-change-timezone-on-ubuntu-18-04/

Why Experts Get Paid More

A cruise line spent hundreds of millions of dollars to build a new highly efficient cruise ship. Everything tested fine and the ship was launched successfully, on budget, and on schedule.


On its maiden voyage, its engine failed. The brand new crew ran through their basic tests, searched manuals, but were unable to fix it themselves.
The ship’s owners tried one ‘professional’ after another but none of them could figure out how to fix the broken engine.

They brought in a local shipwright. He was an older man, had grown up on the docks, and had been fixing ships for as long as people could remember. He carried a small bag of tools with him, and when he arrived on board he immediately went to work.

He quietly inspected the engine very carefully, top to bottom.
Two of the ship’s owners quietly watched the man, hoping he would know what to do. But as time dragged on, they didn’t think it was looking good as they noticed the man quietly speaking to himself as item after item checked as “being ok”.

After looking things over, the old man reached into his bag and pulled out a small hammer. He gently tapped something on the side of the control panel, and instantly the engine lurched into life.

He carefully put his hammer away, the engine running properly.A week later, the owners received an invoice from the old man for $50,000.
Stunned with the amount of money, the owners asked the shipwright to provide an itemized invoice.

The man responded with an invoice that read:
Tapping with a hammer – $2.00,Knowing where to tap – $49,998.00

Experience, and knowing where to direct that effort makes all the difference in the world.

PiHole System v2.0

So I’ve noticed the PiHole being a little bogged down as of late. I’m only running it on a Raspberry Pi 3b+ at the moment so I know I am a little limited as to the performance…but as I have a couple of background projects I want to tackle this year, I thought I would take the oppotunity to replace the SD card with an NVME SSD drive (only about 5000 times faster).

Overall it was a pretty painless process…the big part was realizing that it takes 5-10 seconds for the USB to recognize the booth drive…but then it’s *BOOM* and we are back up and running almost instantly (pretty impressive actually).

The drive went together without a hitch, and was recognized and everything…but then…ROADBLOCK.

I boot off of an SD card…how do I image that to the NVME drive?

Thankfully someone else ran into this same issue and wrote a script/small app to resolve this very issue…and DAMN is it easy and impressive. With a small installation and a simple command of…

$ rpi-clone sda

I was up and running with no issues!

================================================================

Mad props to https://github.com/billw2/rpi-clone

On a Raspberry Pi:

	$ git clone https://github.com/billw2/rpi-clone.git 
	$ cd rpi-clone
	$ sudo cp rpi-clone rpi-clone-setup /usr/local/sbin

Make sure /usr/local/sbin is in your $PATH and then run rpi-clone or rpi-clone-setup with no args to print usage.

rpi-clone-setup is for setting the hostname in /etc/hostname and /etc/hosts files. It is run automatically by rpi-clone if -s args are given, but before your first clone using a -s option, test run rpi-clone-setup with:

      $ sudo rpi-clone-setup -t testhostname

And check the files under /tmp/clone-test to be sure the files have been edited correctly. If you need additional customizations to a clone, add them to the rpi-clone-setup script.

Boba Fett is BACK!

I have no words.

40 years ago we were introduced to Boba Fett. He had all of 4 lines in the entire movie…

  • “As you wish.” – Boba Fett to: Vader
  • “What if he doesn’t survive? He’s worth a lot to me.” – Boba Fett re: Han Solo
  • “He’s no good to me dead.” – Boba Fett
  • “Put Captain Solo in the cargo hold.” – Boba Fett

But…he was the fiercest, most badass bounty hunter in the galaxy when it came to the books and comics…and EVERY kid wanted to be Boba Fett when we ran around and played Star Wars.

Flash forward 40 years, and we have a grizzled and scarred up Boba Fett that somehow escaped the sarlacc pit. Has he spent all this time on Tattooine? We have questions!

Regardless, he’s seemingly faster, stronger and tougher than we have ever seen in a movie. He fights off TWO squads of stormtroopers almost single-handedly…and that’s without his armor. It’s when he spots his armor in the Razorcrest that things get interesting…it’s like a switch goes off and Badass Ultimate Warrior Boba Fett is activated and we finally see his glory unleashed on our high-definition 4k television sets.

Like many of us, 40 years has taken its toll. He’s battered, beat up, but still has some serious fight in him.

I’d argue that he’s probably scarier now than he ever was.

Raspbian Commands – RFKILL

RFKILL is a handy tool to hard disable wireless and bluetooth from Raspbian devices like a pi. Unlike other command line tools, this is persistant meaning that it will survive reboots until it is unblocked.

sudo rfkill block wifi
sudo rfkill block bluetooth

to undo…

sudo rfkill unblock wifi
sudo rfkill unblock bluetooth