
Author: cweb
-
enter the virtual
I’m in the process of cleaning up my gaming PC, so it is easier to virtualize. The C: drive has grow over the years to 153 GB of crap. Naturally, I found the opensource Bulk-Crap_uninstaller. I was monkey’n around in Visual Studio 2022 already, so I was able to clone it from github and compile it with a handful of clicks. It is pretty nice. I wish I had found it before I spent like an hour manually uninstalling things.
-
thecweb to DB DP
I finally decided on CentOS and Cockpit for the VM Host. Which is quite surprising. I have naturally used RedHat Enterprise and clones at work for quite some time, but I haven’t given them another look since they first started with Cockpit, and man is it slick now. Some clarification I needed to arrive at this decision is what CentOS actually IS. It is basically a stable release of RHEL. The next upcoming release, so they give that out for free for people to test before they release it to paying customers. I did not know that it is made by RH engineers, and I never really saw myself ever using a RH derived distro since I abandoned them in the late 90s.
Anyhoo, back to what this post is actually about, the DB migration. I was trying to come up with a clever name that rhymed with DB and DP came to mind, so we get this completely tasteless image and server name DBDP. If you are not familiar with the reference – then good – you’ve lived a good life.
I configured the new VM Guest with 8 cores and 32 GB of RAM. This is probably overkill, but it will allow me to do stupid things and “probably” not take out my website db in the process.
Ubuntu Server 24 LTS is the OS, and I’m switching from mysql to mariadb. Honestly, I don’t know why I even chose mysql. I wouldn’t have if I remembered that it was now owned by Oracle, part of the Sun acquisition. It is my opinion that Oracle was and continues to be everything that MS was made out to be during the anti-trust cases of the 90s. Actually, I just googled and it wasn’t settled until 2001, but it started in 1990.
I just used the regular server netinstall iso I used for the old db server, only the 24 version, and so far I’ve just the mariadb-server package. Side note, /var/log/apt/history.log next time you can’t remember what you’ve installed with apt. I setup a winscp connection for root and copied over the keys for password-less login. Added a rule for mysql in the fancy-shmancy pit of cocks.
Fire up DBeaver and connect to mariadb as root over SSH, so I can create a dev account on the DB.
Which of course did not allow me to connect. Mariadb by default doesn’t even allow local connections over tcp/ip, I find after much confusion. So I add this to /etc/mysql/my.cnf.
[mysqld] skip-networking=0 skip-bind-address
Same as mysql, accounts are tied to hosts, and root is tied to local host, so I still won’t be able to connect with root even over ssh, apparently. So I’ll create a development user that is close to root, and I managed to do it without much googling thanks to an earlier post.
CREATE USER 'cwebdev'@'%' IDENTIFIED BY '*****'; GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'cwebdev'@'%' WITH GRANT OPTION;
Yay! DBeaver is connecting.
And now it’s a few minutes until one am, and I’m hungry. Off to WhataBurger and then I’ll dick-around with loading info from that kasa power strip.
-
VM Host search continues
The cats weren’t around when I fed them yesterday. I noticed that the back porch light was on so I glanced out to take a look, around two in the morning I think.
Anyhoo, I bought the vm host hardware and it is setup. Arch was way to much manual work, though it is ideal if I really want to do things MY way… But, MY way would be a gruesome sojourn into masochism, for nothing but LFS would really be my way, and if I don’t have time or patience for Arch, MY way isn’t feasible.
So far, I’ve built the Arch system, Debian system with KVM/QEMU/Libvirt, Proxmox(disappointment for the hype), and I just started a Ubuntu server LTS build. Fucking Broadcom, killed another with their VMWare purchase. It would be some much easier to use ESXi.
-
Programmable Search Engine
I just found out about this programmablesearchengine.google.com site. It is for adding a custom site search bar to you website, but it also allows you to just do a regular google search on the web, and then include and exclude up to 500 sites, so it seems like the perfect way to configure some searches for specific tasks.
-
SQL – notes
create user
CREATE USER '<username>'@'<connect from hostname>' IDENTIFIED BY '<password>';
grant access
# basic syntax CREATE USER '<username>'@'<connect from hostname>' IDENTIFIED BY '<password>'; # as close to root without being root # probably shouldn't be giving any user this much access GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO '<username>'@'<connect from hostname>' WITH GRANT OPTION;
database
create database <databasename>; show databases;
Inserting data
# INSERT INTO Syntax # It is possible to write the INSERT INTO statement in two ways: # 1. Specify both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...); # 2. If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. Here, the # INSERT INTO syntax would be as follows: INSERT INTO table_name VALUES (value1, value2, value3, ...);
-
$40 Kasa HS300 Smart Power Strip
I impulse-bought 2 of these because it seemed like exactly what I needed for a couple projects. 6 individually controlled power outlets, and three always on USB ports. Each port monitors voltage and amps. And I even found a Python library that controls it and all the other Kasa smart devices I own. 😍
And look here. An official MySQL Python Connector.
So, this is a start.
# commented out code is example code... for now import asyncio from kasa import Discover async def main(): # dev = await Discover.discover_single("127.0.0.1",username="un@example.com",password="pw") # me no think me need login dev = await Discover.discover_single("192.168.1.230") # await dev.turn_on() # await dev.update() # me just want Info for now devInfo = dev.hw_info print(type(devInfo)) print(devInfo) if __name__ == "__main__": asyncio.run(main())
which gives me this
<class 'dict'> {'sw_ver': '1.0.12 Build 220121 Rel.175814', 'hw_ver': '2.0', 'mac': 'B0:19:21:DF:80:D0', 'mic_type': 'IOT.SMARTPLUGSWITCH', 'hwId': '955F433CBA24823A248A59AA64571A73', 'oemId': '32BD0B21AA9BF8E84737D1DB1C66E883'}
I could probably use this command to populate the device table with ease.
-
Arch notes – post install config
This system is too butt-ass-naked to be useful, even just as a hypervisor, so more fuck’n around.
more packages to install:
sudocreate user
useradd -m frank passwd frank
here I realize I don’t have a network connection
en01 is now detected as eth0, for one, so edited /etc/systemd/network/20-wired.network to fix that.
# enable NetworkManager systemctl enable NetworkManager systemctl start NetworkManager nmcli
Sweet. where was I?
I’ve got network, so I need ssh, because Hyper-V sucks for running linux. no copo pasto.
pacman -S openssh systemctl enable sshd pacman -S sudo
uncomment to allow users in wheel to sudo in /etc/sudoers
usermod -G wheel frank
finally, I can ssh in and copy and paste.
list of more packages to install:
posix wget zip unzip gzip libvirt qemu-base
-
Arch notes – basic setup
https://wiki.archlinux.org/title/Installation_guide
Testing out minimal distros to run my hypervisor. Debian is fine and light enough, but the server doesn’t come for at least another day, so I’ve got time. I’ve been hearing about Arch for ever and I haven’t really looked into it, but it sounds exactly like what I’m looking for.
Arch boots into live cli environment, and then you have to manually partition the disk to start.
So, how do I want to do this?
Update the first partition must be the efi partition, and it cannot be in LVM, so do that first
fdisk /dev/sda # g to create GPT table, n to make new, t to change type, and w to write g n +1G t uefi # make LVM partition n w
We should end up with something like this
Reddit has some ideas as usual. https://www.reddit.com/r/sysadmin/comments/1e4xnmq/linux_partition_scheme_recommendation_for_2024/
Looks like this list from open-scap is a good start. The rest is just standard linux crap.
- /boot – 2 GB
- swap – 4 GB
- / – 8 GB
- /home – 2 GB
- /var – 4 GB
- /var/log – 4 GB
- /var/audit – 4 GB
- /var/tmp – 2 GB
- /tmp – 8 GB
reminder: pv = physical disk, vg = volume group, lv = logical volume
# list all physical volumes lvmdiskscan # create pv pvcreate /dev/sda2 # display pv pvdisplay # summary pvscan
vg
# create volume group vgcreate rootVG /dev/sda # add another pv to vg vgextend rootVG /dev/sdc
lv
# create lv lvcreate -L 2G rootVG -n bootLV lvcreate -L 4G rootVG -n swapLV lvcreate -L 8G rootVG -n rootLV lvcreate -L 2G rootVG -n homeLV lvcreate -L 4G rootVG -n varLV lvcreate -L 4G rootVG -n varlogLV lvcreate -L 4G rootVG -n varauditLV lvcreate -L 2G rootVG -n vartmpLV lvcreate -L 8G rootVG -n tmpLV # create lv on specific pv lvcreate -L 10G VolGroup00 -n lvolhome /dev/sda
mkfs
# boot partition is FAT32 - efi mandates as a standard mkfs.fat -F 32 /dev/sda1 mkfs.fat -F 32 /dev/rootVG/bootLV # swap mkswap /dev/rootVG/swapLV # the rest mkfs.ext4 /dev/rootVG/rootLV
mount shit under /mnt. This better get less do-it-yourself real soon or I’m going back to debian. But, if I can slap these in a script I’ll be fine.
# mount root filesystem mount /dev/rootVG/rootLV /mnt # make all those mf mount points you just had to have mount --mkdir /dev/rootVG/bootLV /mnt/boot mount --mkdir /dev/rootVG/varLV /mnt/var and so on... # enable swap swapon /dev/rootVG/swapLV
Package list:
base linux linux-firmware vim efibootmgr grub intel-ucode
networkmanager dosfstools exfatprogs e2fsprogs ntfs-3g lvm2
sshd sudopacstrap -K /mnt base linux linux-firmware
fstab
# Generate an fstab file (use -U or -L for UUID or labels) genfstab -L /mnt >> /mnt/etc/fstab
chroot to new install
# fancy smancy arch version of chroot arch-chroot /mnt
set a bunch of shit you normally never have to…
# time zone ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime # hw clock hwclock --systohc # Edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8 # fuck, install vim with 'pacman -S vim' if you forget it locale-gen # Create the locale.conf(5) file, and set the LANG variable accordingly echo LANG=en_US.UTF-8 >> /etc/locale.conf echo archkvm >> /etc/hostname
net config
# install Network Manager - nmcli pacman -S networkmanager # add this stuff to /etc/systemd/network/20-wired.network [Match] Name=en01 [Link] RequiredForOnline=routable [Network] DHCP=yes
initramfs
# because we are using LVM we need to create a new initramfs. Also needed for encryption and RAID. # edit /etc/mkinitcpio.conf # remove udev and replace with systemd # insert vlm2 between block and filesystems HOOKS=(base systemd ... block lvm2 filesystems) # rebuild image mkinitcpio -P # install lvm2 and rebuild again because it gave you an error about exactly that pacman -S lvm2 mkinitcpio -P
root password
passwd
install bootloader – I’m doing grub for now, but I may either put the /boot partition outside of LVM and load directly from UEFI.
# install grub and efibootmgr (if you haven't already) pacman -S grub efibootmgr # mount efi partition mount --mkdir /dev/sda1 /boot/efi # install grub grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB # make grub config grub-mkconfig -o /boot/grub/grub.cfg
NOTE: it is here where you realize the efi partition can NOT be on an LVM partition, even though GRUB is fine with /boot being there. Starting over and updating notes. fml
cross fingers and reboot
# exit chroot exit umount -R /mnt reboot
Aaaaannnd voila!!!
The most basic-bitch linux distro I’ve ever seen. Well, except for LFS, and I guess Gentoo was possibly worse because you had to wait five hours of compiling to realize you fucked up. But this is what I wanted. A Hypervisor should be very minimal.