Posts Tagged how to

LVM Part 4: RAID

📅 April 6, 2024
RAID (Redundant Array of Independent Disks) is available in Linux using mdadm, but did you know that RAID is also possible with LVM?

By default, LVM creates a linear logical volume, but we can create a RAID logical volume as well with RAID modes 0, 1, 4, 5, 6, and 10 (also known as 1+0).

How is RAID accomplished with LVM?

Read the rest of this entry »

, , ,

Leave a comment

LVM Part 3: Logical Volumes

📅 April 3, 2024
We have created physical volume building blocks. We assigned them to volume group storage pools. Now, it is time for the final piece of the LVM system: logical volumes.

The logical volume is the “thing” that we format, mount, and allow users to interact with. We can treat a logical volume just like any other NVMe, SSD, or HDD.

Read the rest of this entry »

, ,

Leave a comment

LVM Part 1: Physical Volumes

📅 March 31, 2024
Linux has a number of handy technologies built in that have existed for a long time but seem to receive little attention because they are taken for granted or simply not talked about.

One of these is logical volume management (LVM) that allows us to treat hard drive storage space in a way similar to RAM. Comparable to adding another memory stick to expand RAM, we can add more hard drives to expand hard drive storage space. Need more secondary storage? Just add another hard drive.

This simple concept is incredibly versatile and saves time by eliminating the need to backup and restore data following a new drive addition to a system. It requires some extra steps to set up and has a few specific terms to learn, but the benefits are worthwhile.

LVM consists of three layers to create a working storage system. In this part, we will focus on the physical drives themselves, called physical volumes. These can be mechanical hard drives, SSDs, SAS, or even super fast NVMe storage devices.

Read the rest of this entry »

, ,

Leave a comment

Redundant Synchronized Pi-Hole with keepalived and gravity-sync

📅 March 4, 2024
“Help! When Pi-Hole goes down, nobody can access the Internet!”

Pi-Hole is a superb network-wide ad blocker because it blocks connections to forbidden domain names listed in its blocklists when resolving DNS requests, but if Pi-Hole hangs up or is inadvertently turned off for whatever reason, then domain names cannot be resolved and it seems like the Internet is down.

To help protect against this and provide some form of resiliency, we can mirror two Pi-Hole instances so if one goes down, the backup will take over, and users can still access the Internet.

This is simpler than it sounds thanks to a service called keepalived. Let’s see how to set up two Pi-Hole instances using a virtual IP address (VIP) to provide high availability (HA).

Read the rest of this entry »

, ,

Leave a comment

Bash: Read JSON File to Add Many Users

📅 February 22, 2024
“Can Bash parse a JSON file?”

Yes, but not natively like Python can using the json module.

Parsing a JSON file from a Bash script usually involves writing custom code that parses strings and such, but there is a handy program call jq that handles the details of JSON parsing for use.

Suppose we want to add a batch of user accounts, each user with a unique password and assignment to a Linux specific group. This involves more user information that a simple username with a temporary common password. We can store this user information in a JSON file, and then let a Bash script process the user data from the file to create the users.

Here is one way to achieve this.

Read the rest of this entry »

, , ,

Leave a comment

Add New Users from a Text File

📅 February 21, 2024
“I have a LOT of users to add, but I do not want to add them one by one. Can I use a script?”

Yes! This is what Linux specializes in. We can write a script that reads a list of usernames from a text file to create these users on a given system and assign them all a default password.

Here is one way to achieve this magic.

Read the rest of this entry »

, ,

Leave a comment

Open and Monitor Multiple SSH Terminals at Once

📅 January 21, 2024
“So many remote hosts, so many logins. Can we automate this?”

Suppose we have multiple remote systems that we need to monitor as a group. Usually, we open a terminal for each remote system, SSH with a password, and then interact with the remote systems to perform updates or htop monitoring.

Wouldn’t it be easier if we could run a script that automatically logs into each remote system via SSH for us and display whatever we want to see in each terminal?

This takes a little time to set up, but we can write a script that does this for us to make the terminal windows appear quickly and in specified positions on the Linux desktop!

Read the rest of this entry »

, ,

Leave a comment

How to Position a Bash Terminal

📅 January 20, 2024
“I want to be fancy and open a terminal at a specific (x, y) coordinate.”

When we open a Bash terminal, such as gnome-terminal, it will open smack dab in the center of the screen. This is fine for a single terminal, but when opening several, they stack on top of each other (at least they do in Linux Mint).

Is there a way to manually specify where a terminal opens in addition to its size?

Indeed there is!

Read the rest of this entry »

, ,

Leave a comment

How to Connect Apache2 + PHP on Linux to SQL Server 2022 Express on Windows

📅 July 17, 2023
“Help! I have a web server, but all of my data is on a SQL Server instance in Windows. How can I access the data from PHP in Linux without migrating it to MySQL?”

Not a problem! If you have a web server running Apache2 with PHP, you can indeed access SQL Server data located on a different system.

In fact, this is the usual arrangement where the web server runs in its own environment while the database server runs in another. A modular configuration makes it easier to mix and match systems, and fault tolerance is increased. In this case, the database server is running on a Windows system, not MySQL or MariaDB running under Linux.

It is possible to connect to and access SQL Server data from PHP in Linux, but there is some extra setup required compared to MySQL that runs practically out of the box.

This will show how to setup and access Transact-SQL (T-SQL) data located on a Windows virtual machine from a Linux virtual machine running Apache2 with PHP. Do you think you are up for this? Because it is not as straightforward as we might think.

Read the rest of this entry »

, , , ,

Leave a comment

PCIe Bifurcation and NVMe RAID in Linux Part 1: The Hardware

📅 April 8, 2023
“PCIe Bifur…..WHAT?!”

Ooooh! Sounds fancy, right? On some motherboards, the BIOS will allow a single physical PCIe x16 slot to be divided into two or more logical PCIe slots in order to install multiple NVMe SSDs (two, three, or four) using an adapter card. This is PCIe bifurcation, and Linux is compatible with motherboards that support it.

What would benchmark numbers look like if we put two NVMe devices in RAID-0? How about RAID-1? How well would it compare to a single NVMe? What would be the best data storage arrangement if using NVMe? Are there different techniques to follow compared to RAID with mechanical drives?

Here are my experiments in an attempt to help protect data stored on a Linux system with the hopes of providing faster redundancy while exploring PCIe bifurcation on a system running Ubuntu Cinnamon 22.04.

Read the rest of this entry »

, , ,

Leave a comment