Sunday, July 16, 2023

Disabling Transparent Huge Pages on RHEL 8

 

What are Transparent Huge Pages? :

Transparent Huge Pages (THP) is a Linux memory management system that reduces the overhead of Translation Lookaside Buffer (TLB) lookups on machines with large amounts of memory by using larger memory pages.

Transparent Huge Pages are by default enabled in CentOS / RHEL 8.

Database workloads often perform poorly with THP enabled, because they tend to have sparse rather than contiguous memory access patterns.

Therefore, sometimes it is required that, you should disable Transparent Huge Pages on your Linux operating system.

 

Disable Transparent Huge Pages:

Check the current status of Transparent Huge Pages.

# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

THP are currently enabled in your Linux operating system.

To disable Transparent Huge Pages, you have to edit GRUB boot menu. For this purpose, edit the GRUB configuration file in vim text editor.

# vi /etc/default/grub

Locate GRUB_CMDLINE_LINUX and append "transparent_hugepage=never" at the end of that line.

GRUB_CMDLINE_LINUX="resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet transparent_hugepage=never"

Generate new GRUB boot menu based on customized configuration file.

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done

Restart Linux operating system to apply new settings.

# reboot

After restart, check the status of THP again.

# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

You have disabled Transparent Huge Pages on your Linux operating system. But you are also required to configure tuned service as well.

Wednesday, May 3, 2023

 
How to Take ‘Snapshot of Logical Volume and Restore’ in LVM 


LVM Snapshots are space-efficient point-in-time copies of lvm volumes. It works only with lvm and consumes the space only when changes are made to the source logical volume to snapshot volume. If the source volume has huge changes made to the sum of 1GB the same changes will be made to the snapshot volume. It is best to always have a small size of changes for space efficiency. In case the snapshot runs out of storage, we can use lvextend to grow. And if we need to shrink the snapshot we can use lvreduce.

Take Snapshot in LVM
Take a Snapshot in LVM

If we have accidentally deleted any file after creating a Snapshot we don’t have to worry because the snapshot has the original file which we have deleted. It is possible that the file was there when the snapshot was created. Don’t alter the snapshot volume, keep it as it is while the snapshot is used to do a fast recovery.

Snapshots can’t be used as a backup option. Backups are Primary Copies of some data, so we cant use snapshots as a backup option.

Requirements

  1. Create Disk Storage with LVM in Linux – PART 1
  2. How to Extend/Reduce LVM’s in Linux – Part II
My Server Setup
  1. Operating System – CentOS 6.5 with LVM Installation
  2. Server IP – 192.168.0.200

Step 1: Creating LVM Snapshot

First, check for free space in the volume group to create a new snapshot using the following ‘vgs‘ command.

# vgs
# lvs
Check LVM Disk Space
Check LVM Disk Space

You see, there is 8GB of free space left in the above vgs output. So, let’s create a snapshot for one of my volume named tecmint_datas. For demonstration purposes, I am going to create only 1GB snapshot volume using the following commands.

# lvcreate -L 1GB -s -n tecmint_datas_snap /dev/vg_tecmint_extra/tecmint_datas        

OR

# lvcreate --size 1G --snapshot --name tecmint_datas_snap /dev/vg_tecmint_extra/tecmint_datas
  1. -s – Creates Snapshot
  2. -n – Name for snapshot
Create LVM Snapshot
Create LVM Snapshot

Here, is the explanation of each point highlighted above.

  1. Size of snapshot I am creating here.
  2. Creates snapshot.
  3. Creates name for the snapshot.
  4. New snapshots name.
  5. A volume of which we are going to create a snapshot.

If you want to remove a snapshot, you can use ‘lvremove‘ command.

# lvremove /dev/vg_tecmint_extra/tecmint_datas_snap

Remove LVM Snapshot
Remove LVM Snapshot

Now, list the newly created snapshot using the following command.

# lvs
Verify LVM Snapshot
Verify LVM Snapshot

You see above, a snapshot was created successfully. I have marked with an arrow where snapshots originate from where its created, It’s tecmint_datas. Yes, because we have created a snapshot for tecmint_datas l-volume.

Check LVM Snapshot Space
Check LVM Snapshot Space

Let’s add some new files into tecmint_datas. Now volume has some data around 650MB and our snapshot size is 1GB. So there is enough space to back up our changes in snap volume. Here we can see, what is the status of our snapshot using the below command.

# lvs
Check Snapshot Status
Check Snapshot Status

You see, 51% of snapshot volume was used now, no issue for more modification in your files. For more detailed information use the command.

# lvdisplay vg_tecmint_extra/tecmint_data_snap
View Snapshot Information
View Snapshot Information

Again, here is a clear explanation of each point highlighted in the above picture.

  1. Name of Snapshot Logical Volume.
  2. Volume group name currently under use.
  3. Snapshot volume in read and write mode, we can even mount the volume and use it.
  4. A time when the snapshot was created. This is very important because a snapshot will look for every change after this time.
  5. This snapshot belongs to the tecmint_datas logical volume.
  6. A logical volume is online and available to use.
  7. Size of Source volume which we took a snapshot of.
  8. Cow-table size = copy on Write, which means whatever changes were made to the tecmint_data volume will be written to this snapshot.
  9. Currently, the snapshot size used, our tecmint_datas was 10G but our snapshot size was 1GB which means our file is around 650 MB. So what is now in 51% if the file grows to 2GB size in tecmint_datas size will increase more than the snapshot allocated size, sure we will be in trouble with a snapshot. That means we need to extend the size of the logical volume (snapshot volume).
  10. Gives the size of the chunk for a snapshot.

Now, let’s copy more than 1GB of files in tecmint_datas, let’s see what will happen. If you do, you will get an error message saying ‘Input/output error‘, which means out of space in the snapshot.

Add Files to Snapshot
Add Files to Snapshot

If the logical volume becomes full it will get dropped automatically and we can’t use it anymore, even if we extend the size of the snapshot volume. It is the best idea to have the same size as Source while creating a snapshot, tecmint_datas size was 10G, if I create a snapshot size of 10GB it will never overflow like above because it has enough space to take snaps of your volume.

Step 2: Extend Snapshot in LVM

If we need to extend the snapshot size before overflow we can do it using.

# lvextend -L +1G /dev/vg_tecmint_extra/tecmint_data_snap

Now there was a total of 2GB size for a snapshot.

Extend LVM Snapshot
Extend LVM Snapshot

Next, verify the new size and COW table using the following command.

# lvdisplay /dev/vg_tecmint_extra/tecmint_data_snap

To know the size of the snap volume and usage %.

# lvs
Check Size of Snapshot
Check the Size of the Snapshot

But if you have a snapshot volume of the same size as the Source volume we don’t need to worry about these issues.

Step 3: Restoring Snapshot or Merging

To restore the snapshot, we need to un-mount the file system first.

# unmount /mnt/tecmint_datas/
Un-mount File System
Un-mount File System

Just check for the mount point to whether it’s unmounted or not.

# df -h
Check File System Mount Points
Check File System Mount Points

Here are mount has been unmounted, so we can continue to restore the snapshot. To restore the snap using the command lvconvert.

# lvconvert --merge /dev/vg_tecmint_extra/tecmint_data_snap
Restore LVM Snapshot
Restore LVM Snapshot

After the merge is completed, the snapshot volume will be removed automatically. Now we can see the space of our partition using the df command.

# df -Th
Check Size of Snapshot
Check the Size of the Snapshot

After the snapshot volume is removed automatically. You can see the size of the logical volume.

# lvs
Check Size of Logical Volume
Check the Size of the Logical Volume

Important: To Extend the Snapshots automatically, we can do it using some modifications in the conf file. For manual, we can extend using lvextend.

Open the lvm configuration file using your choice of editor.

# vim /etc/lvm/lvm.conf

Search for the word autoextend. By default, the value will be similar to below.

LVM Configuration
LVM Configuration

Change the 100 to 75 here, if so auto extend threshold is 75 and the auto-extend percent is 20, it will expand the size by 20 Percent

If the snapshot volume reaches 75% it will automatically expand the size of the snap volume by 20% more. Thus, we can expand automatically. Save and exit the file using wq!.

Thursday, March 16, 2023

Install the Google Chrome Browser via the Ubuntu 22.04 LTS Terminal

 

How to install Google Chrome web browser on Ubuntu 22.04 Jammy Jellyfish


Google Chrome is an open-source and free web browser used by a large community of computer users. It is a cross-platform and secure browsing application launched and maintained by Google.  It has a fast browsing speed.

Google Chrome is a famous and widely used search engine worldwide. It is available in 47 languages and provides the facility of translation in almost 52 languages.

This descriptive write-up will teach you to install Google Chrome on Ubuntu 22.04.

  • Install Google Chrome from Deb Package
  • Install Google Chrome using the Google repository
  • How to Remove Google Chrome From Ubuntu 22.04?

Method 1: Install Google Chrome from deb package

Ubuntu doesn’t have the Google Chrome packages in its default repository. However, Chrome can be installed on Ubuntu using the deb package. For this purpose, follow the below-mentioned step-by-step process.

Step 1: Download deb package

Top 10 Linux Distros

To download the deb package of Google Chrome, type and run the following command in terminal:

$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

The deb package of the stable version of Google Chrome is downloaded successfully.

Step 2: Install Google Chrome

You can use the apt/dpkg command to install Chrome from the Debian package file. In our case, the following command will install Chrome on Ubuntu 22.04:

$ sudo apt install ./google-chrome-stable_current_amd64.deb

The stable version of Google Chrome is installed successfully.

How to start Google Chrome on Ubuntu 22.04

When the Chrome is installed successfully on Ubuntu 22.04, you can launch it using the following command:

$ google-chrome

It will open the following interface. To continue, Click on the Get Started.

After launching Google Chrome, you can set it as a default browser.

Google Chrome is now open to use.

Method 2: Install Google Chrome using Google repository

A user can install Google Chrome on Ubuntu 22.04 through Google repository. To do this, perform the below-mentioned steps.

Step 1: Add GPG key

First, you should add the gpg key to add the google repository. To do this action, type the following command and run-in terminal:

$ wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmour -o /usr/share/keyrings/google_linux_signing_key.gpg

The gpg key is added successfully.

Step 2: Add Google repository

To add the Google repository, run the following command:

$ sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google_linux_signing_key.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list'

The repository is added successfully.

Step 3: Update system’s packages

After adding the repository, you must update the core library of the system to get the updated package. For this purpose, run the following command:

$ sudo apt update

The packages are updated successfully.

Step 4: Install Google Chrome

Now, to install the stable version of Google Chrome, execute the following command:

$ sudo apt install google-chrome-stable

The stable version of Google Chrome is installed successfully.

How to remove Google Chrome from Ubuntu 22.04

A user can remove the Google Chrome application from Ubuntu 22.04 by running the below-mentioned command in terminal:

$ sudo apt autoremove google-chrome-stable

Chrome was removed successfully.

Congratulations! You have learned the installation method of Google Chrome on Ubuntu 22.04.