Colin Robinson

How to setup LUKS on LVM for Arch

In this blog post, I’ll guide you through the steps to set up LUKS on LVM with Arch Linux.

Step 1: Boot the Arch Linux installation media
To start, you need to boot from the Arch Linux installation media. You can download the latest ISO file from the Arch Linux website and create a bootable USB drive or DVD.

Step 2: Connect to the internet
Make sure you are connected to the internet so that you can download the necessary packages and updates during the installation process.

Step 3: Partition the disk
Use a partitioning tool such as fdisk or cfdisk to partition your hard drive. You’ll need to create at least two partitions – one for the boot partition and another for the LVM partition.

Step 4: Set up LVM
Next, set up LVM on the LVM partition. Use the following commands to create a physical volume, a volume group, and a logical volume:

# pvcreate /dev/sda2
# vgcreate vg0 /dev/sda2
# lvcreate -L 10G vg0 -n root
# lvcreate -L 2G vg0 -n swap
# lvcreate -l +100%FREE vg0 -n home

This will create three logical volumes – one for the root partition, one for swap, and one for the home partition.

Step 5: Set up encryption
Now it’s time to set up LUKS encryption on the logical volumes. Use the following commands to encrypt each volume:

# cryptsetup luksFormat /dev/vg0/root
# cryptsetup luksFormat /dev/vg0/swap
# cryptsetup luksFormat /dev/vg0/home

You’ll be prompted to enter a passphrase for each volume.

Step 6: Open the encrypted volumes
Next, open the encrypted volumes with the following commands:

# cryptsetup open /dev/vg0/root root
# cryptsetup open /dev/vg0/swap swap
# cryptsetup open /dev/vg0/home home

You’ll be prompted to enter the passphrase for each volume.

Step 7: Format the partitions
Now format the partitions using the appropriate file system. For example, to format the root partition with the ext4 file system, use the following command:

# mkfs.ext4 /dev/mapper/root

Do the same for the swap and home partitions.

Step 8: Mount the partitions
Finally, mount the partitions with the following commands:

# mount /dev/mapper/root /mnt
# mkdir /mnt/boot
# mount /dev/sda1 /mnt/boot
# swapon /dev/mapper/swap
# mkdir /mnt/home
# mount /dev/mapper/home /mnt/home

Step 9: Install Arch Linux
Now you’re ready to install Arch Linux. Follow the usual installation process, but when you get to the partitioning step, select the LUKS-encrypted partitions you just created.

Step 10: Configure the bootloader
Finally, configure the bootloader to recognize the encrypted partitions. For example, if you’re using GRUB, add the following lines to /etc/default/grub:

GRUB_CMDLINE_LINUX="cryptdevice=/dev/vg0/root:root cryptkey=rootfs:/root/cryptkey"

Then regenerate the GRUB configuration file with the following command:

# grub-mkconfig -o /boot/grub/grub.cfg

Simplest splat shader – Unity URP Shader Graph

Here is the shader graph for the simplest possible splat shader in Unity using URP and Shader Graph.

It takes 4 textures to tile across the object and a 5th splat map texture

Here is an alternative using Vertex Color instead of a splat map texture

My top 10 plugins for Blender that you might not know

Blender is a powerful 3D modeling software that is free and open-source. With its large community of developers, there are many plugins available that can help you enhance your workflow and create even better models. In this blog post, we’ll introduce you to the top 10 plugins for Blender, with screenshots to show you what they can do.

  1. Hard Ops

    Hard Ops is a plugin that allows you to create complex shapes with ease. With this plugin, you can quickly create intricate shapes and cut them into other objects. This plugin is especially useful for creating hard surface models, such as weapons, vehicles, and buildings.
    https://hardops-manual.readthedocs.io/en/latest/

  2. BoxCutter

    BoxCutter is another plugin that is designed for creating hard surface models. This plugin allows you to cut holes, bevel edges, and create complex shapes with ease. With BoxCutter, you can create intricate details on your models in just a few clicks
    https://blendermarket.com/products/boxcutter

  3. SpeedFlow

    SpeedFlow is a plugin that allows you to create complex animations and rigs quickly. With this plugin, you can create complex animations in just a few clicks, without having to manually keyframe everything. This plugin is especially useful for creating character animations.
    SpeedFlow plugin
    https://blendermarket.com/products/speedflow

  4. Continue reading “My top 10 plugins for Blender that you might not know” »

Use MariaDB with PhpStorm

Update August 2018:

PHPStorm now includes MariaDB as a schema type but does not include the driver files. It does offer to download the MariaDB driver for you, but if you want to use the native driver, install mariadb-jdbc from the AUR and edit the MariaDB entry in PHPStorm to use /usr/share/java/mariadb-jdbc/mariadb-java-client.jar as the driver file.

Manually create the driver entry (the old way):

PhpStorm comes with several preconfigured database drivers (although the drivers themselves must be download separately). This short tutorial will tell you how to setup MariaDB as one of your Drivers on PhpStorm running on Arch Linux.

1. Install mariadb-jdbc from the AUR

2. Open the “Data Sources and Drivers” window

This can be done by selecting the menu option View > Tool Windows > Database and then clicking the wrench icon.


Continue reading “Use MariaDB with PhpStorm” »

Automatically switch Xfce panel layout when plugging in a monitor

Xfce has great multi-monitor support. Different panels on each monitor, it all works great. I’ve used it with multiple monitors on my desktop for 5+ years. Love it.

But you run into some annoyances with laptops. Half the time I’m using my laptop on its own, and half the time I’m using it with an external monitor. You plug the monitor in for the first time, then you create a new panel for it and drag it over. But then when you unplug the monitor, that second panel doesn’t go away. Instead, it moves over to the main laptop screen and the only way to hide it is to delete it. Then when you plug the external monitor in again, you need to recreate it, readd all the items and so on.

Well, the Xubuntu team has made a tool called Xfce Panel Switch (Arch package: xfpanel-switch).

I’ll quickly walk though how to setup automatic switching.

Continue reading “Automatically switch Xfce panel layout when plugging in a monitor” »

Clicking notifications in Chrome causes the window to change workspaces

This is a simple and obvious fix, but it was annoying me for awhile before I looked into it.

The situation:
You have a Chrome window open in workspace that’s different to the one you’re currently in. You receive a desktop notification from WhatsApp, Hangouts, 8tracks, ect. When you click the notification, it brings that browser window into your current workspace. But I put that window in that workspace so it stayed out of the way. You’re messing up my flow Chromium!

Actually this default behavior is super easy to change in Xfce.

xfwm4-tweaks-settings

Switch to the Focus tab and change When a window raises itself from Bring window on current workspace to Switch to window’s workspace. Voila.

Use Bash to get the memory usage of applications like Chromium

It’s not always easy to tell how much memory Chromium/Chrome is using, because of the different threads it starts. Here are a couple snippets with explanations to get you started.

Percent of memory use

Code:

ps -eo pmem,comm | grep chromium | cut -d " " -f 2 | paste -sd+ | bc | awk '{ print $1 "%" }'

Output:

17.5%

Explanation:

  1. Get the percent of memory used (pmem) and the command name (comm) of every process.
  2. Select only chromium results.
  3. Break each result into chucks and then select the chunk containing the percent value.
  4. Join the results together with the addition symbol (+).
  5. Add them up.
  6. Print the value with a percent symbol so it looks nicer.

Real memory use

Code:

ps -eo rss,comm | \grep chromium | sed 's/chromium//' | paste -sd+ | bc | awk '{printf( "%0.2f GiB\n", $1/1024^2 )}'

Output:

1.45 GiB

Explanation:

  1. Get the amount of memory in use (RSS) and the command name of every process.
  2. Select only chromium results.
  3. Remove the word “chromium”, so only the rss value is left.
  4. Join the results together with the addition symbol (+).
  5. Add them up.
  6. Use awk to convert the result from KiB to GiB by dividing by 1024²
  7. Also use awk to print the result to a maximum of 2 decimal places and add the text “GiB” so it looks nicer.

Play games in borderless windows with Compiz

I like to play games and luckily there are a lot of games for Linux now; I have 51 games in Steam which run on Linux. But not all of these games do a good job when running at fullscreen (diustorted resolutions, hidden cursors, ect). So I like to run games in a borderless window and not all of these games offer that.

This is a simple fix. Open cssm, navigate to Effects > Window Decoration, and change the Decoration windows property to (any) & !(class=Awesomenauts.bin.x86). In this case, the game I want in a borderless window is Awesomenauts (really great game).

Compiz – Window border edge overlaps when using the grid plugin

Problem: Window borders overlap when using the grid plugin in Compiz

This one has been bothering me for awhile. Turns out it isn’t a Compiz bug at all (well maybe it is), it’s an Emerald bug! Are you also using Emerald as your window decorator?

Open emerald-theme-manager. Emerald Settings > uncheck Use Decoration Cropping

Problem solved! For me at least. Here’s a related bug report (https://bugs.launchpad.net/compiz/+bug/1197811) that unfortunately I didn’t find until after I fixed this by using the age old technique of randomly changing settings. But hopefully this post appears in someone’s Google results and I save them from the months of pixel overlapping agony that I had to endure.

Quickly reload a database

I’m mostly posting this to copy/paste when I forget, but it’s useful information nonetheless so lets have at it.

  1. Delete the database
  2. Create a new database
  3. Import SQL file into the new database

Assume the mysql user/pass combo is colin/mypassword and the database is called db123.

mysqladmin -u colin -pmypassword drop db123;
mysqladmin -u colin -pmypassword create db123;
mysql -u colin -pmypassword db123 < db123_backup.sql

If you’re working on something and you need to reload your database a lot, you can put all the commands on one line (still with semicolons of course) and add -f to the first command to skip the delete check.

Very very basic stuff here, but I’m sure the 3min it took me to write this saved someone else more time than that.

Previous Posts