Topics: LVM, Red Hat, Storage

Logical volume snapshot on Linux

Creating a snapshot of a logical volume, is an easy way to create a point-in-time backup of a file system, while still allowing changes to occur to the file system. Basically, by creating a snapshot, you will get a frozen (snapshot) file system that can be backed up without having to worry about any changes to the file system.

Many applications these days allow for options to "freeze" and "thaw" the application (as in, telling the application to not make any changes to the file system while frozen, and also telling it to continue normal operations when thawed). This functionality of an application can be really useful for creating snapshot backups. One can freeze the application, create a snapshot file system (literally in just seconds), and thaw the application again, allowing the application to continue. Then, the snapshot can be backed up, and once the backup has been completed, the snapshot can be removed.

Let's give this a try.

In the following process, we'll create a file system /original, using a logical volume called originallv, in volume group "extern". We'll keep it relatively small (just 1 Gigabyte - or 1G), as it is just a test:

# lvcreate -L 1G -n originallv extern
  Logical volume "originallv" created.
Next, we'll create a file system of type XFS on it, and we'll mount it.
# mkfs.xfs /dev/mapper/extern-originallv
# mkdir /original
# mount /dev/mapper/extern-originallv /original
# df -h | grep original
/dev/mapper/extern-originallv 1014M   33M  982M   4% /original
At this point, we have a file system /original available, and we can start creating a snapshot of it. For the purpose of testing, first, create a couple of files in the /original file system:
# touch /original/file1 /original/file2 /original/file3
# ls /original
file1  file2  file3
Creating a snapshot of a logical volume is done using the "-s" option of lvcreate:
# lvcreate -s -L 1G -n originalsnapshotlv /dev/mapper/extern-originallv
In the command example above, a size of 1 GB is specified (-L 1G). The snapshot logical volume doesn't have to be the same size as the original logical volume. The snapshot logical volume only needs to hold any changes to the original logical volume while the snapshot logical volume exists. So, if there are very little changes to the original logical volume, the snapshot logical volume can be quite small. It's not uncommon for the snapshot logical volume to be just 10% of the size of the original logical volume. If there are a lot of changes to the original logical volume, while the snapshot logical volume exists, you may need to specify a larger logical volume size. Please note that large databases, in which lots of changes are being made, are generally not good candidates for snapshot-style backups. You'll probably have to test in your environment if it will work for your application, and to determine what a good size will be of the snapshot logical volume.

The name of the snapshot logical volume in the command example above is set to originalsnapshotlv, using the -n option. And "/dev/mapper/extern-originallv" is specified to indicate what the device name is of the original logical volume.

We can now mount the snapshot:
# mkdir /snapshot
# mount -o nouuid /dev/mapper/extern-originalsnapshotlv /snapshot
# df -h | grep snapshot
/dev/mapper/extern-originalsnapshotlv 1014M   33M  982M   4% /snapshot
And at this point, we can see the same files in the /snapshot folder, as in the /original folder:
# ls /snapshot
file1  file2  file3
To prove that the /snapshot file system remains untouched, even when the /original file system is being changed, let's create a file in the /original file system:
# touch /original/file4
# ls /original
file1  file2  file3  file4
# ls /snapshot
file1  file2  file3
As you can see, the /original file system now holds 4 files, while the /snapshot file system only holds the original 3 files. The snapshot file system remains untouched.

To remove the snapshot, a simple umount and lvremove will do:
# umount /snapshot
# lvremove -y /dev/mapper/extern-originalsnapshotlv
So, if you want to run backups of your file systems, while ensuring no changes are being made, here's the logical order of steps that can be scripted:
  • Freeze the application
  • Create the snapshot (lvcreate -s ...)
  • Thaw the application
  • Mount the snapshot (mkdir ... ; mount ...)
  • Run the backup of the snapshot file system
  • Remove the snapshot (umount ... ; lvremove ... ; rmdir ...)

Topics: Red Hat, Virtualization

Renaming a virtual machine domain with virsh

There is no API to accomplish renaming a domain (or system) using virsh. The well known graphical tool "virt-manager" (or "Virtual Machine Manager") on Red Hat Enterprise Linux therefore also does not offer the possibility to rename a domain.

In order to do that, you have to stop the virtual machine and edit the XML file as follows:

# virsh dumpxml > machine.xml
# vi machine.xml
Edit the name between the name tags at the beginning of the XML file.

When completed, remove the domain and define it again:
# virsh undefine
# virsh define machine.xml

Topics: Red Hat

Red Hat Enterprise Linux links

Official Red Hat sites:

Other Red Hat related sites:

Topics: Red Hat

Red Hat Customer Portal

Access Red Hat Customer Portal at

  • Access everything provided with subscription in one location:
    • Search knowledge-base for solutions, FAQs, and articles.
    • Access official product documentation.
    • Submit and manage support tickets.
    • Attach and detach product subscriptions.
    • Download software, updates, and evaluations.
  • Parts of site accessible to everyone.
    • Other parts are exclusive to customers with active subscriptions.
  • Get help with Customer Portal at
Note: The Red Hat Customer Portal can be accessed via command line tool:
# redhat-support-tool
Welcome to the Red Hat Support Tool.
Command (? for help):
You can access it from any terminal or SSH connection, and you can use it as interactive shell (which is default) or execute individual commands with options and arguments. The syntax is identical for both methods. To see all available commands, use "help".

Topics: Red Hat, Security

Generating random passwords

A way to create a random password yourself is using a password generator. The pwmake is a command-line tool for generating random passwords that consist of all four groups of characters: uppercase, lowercase, digits and special characters.

The utility allows you to specify the number of entropy bits that are used to generate the password. The entropy is pulled from /dev/urandom. The minimum number of bits you can specify is 56, which is enough for passwords on systems and services where brute force attacks are rare. 64 bits is adequate for applications where the attacker does not have direct access to the password hash file (/etc/shadow). For situations when the attacker might obtain the direct access to the password hash or the password is used as an encryption key, 80 to 128 bits should be used. If you specify an invalid number of entropy bits, pwmake will use the default of bits.

To create a password of 128 bits, enter the following command:

# pwmake 128

Topics: Red Hat, System Admin

Red Hat: Creating a backup to ISO images

The following procedure describes how to create a full system backup, using MondoRescue, to ISO images, that can later be burnt to DVD, and used to recover the entire system.

First, set up the REPO for MondoResuce:

# cd /etc/yum.repos.d/
# wget
Install MondoRescue:
# yum install mondo
Answer "y" to everything.

You will need a destination to put the ISO files in. For example a remote NFS mount on a separate server is a good choice, so the backup is not locally on the same system.

Edit /etc/mindi/mindi.conf, to allow for a larger RAM disk. Mindi is used by Mondo. Wihout it, Mindi will exit saying it ran out of space. Add to mindi.conf:
Now run the MondoRescue backup:
# mondoarchive -O -V -i -s 4480m -d /target -I / -T /tmp
You can also add the -E option to tell MondoRescue to exclude certain folders.

The -s option tells MondoResuce to make ISO images of DVD size 4480m.

The command says it will log to /var/log/mondoarchive.log. A /var/log/mindi.log is also written. It will also indicate the number of media images to be created. Let it run, and your backup is successful.

Topics: Red Hat

Using Wodim to write an ISO image to DVD

Wodim is an easy tool to write an ISO image to DVD, and it's included with Red Hat.

In order to write an ISO image to DVD, first start off by making sure what the device is of the DVD burner. Most often, it is /dev/sr0. To validate this, run:

# ls -als /dev/sr0
If that's the correct device, all you need is an ISO image. Let's say, your ISO image is located in /path/to/image.iso. In that case, use the following command to write the ISO image to DVD:
# wodim dev=/dev/sr0 -v -data /path/to/image.iso

Topics: Red Hat

Red Hat Cluster Suite commands

Red Hat cluster controls the startup and shutdown of all application components on all nodes within a cluster. To check the status of the cluster, to start, stop or failover resource groups Red Hat cluster's standard commands can be used.

Following is a list of some of cluster commands.

  • To check cluster status: clustat
  • To start cluster manager: service cman start (do on both nodes right away with in 60 seconds)
  • To start cluster LVM daemon: service clvmd start (do on both nodes)
  • To start Resource group manager: service rgmanager start (do on both nodes)
  • To enables and starts the user service: clusvcadm -e service_name (check with clustat for available service names in your cluster)
  • To disable and stops the user service: clusvcadm -d service_name (check with clustat for available service names in your cluster)
  • To stop Resource group manager: service rgmanager stop
  • To stop cluster LVM daemon: service clvmd stop
  • To stop cluster manager: service cman stop (Do not stop CMAN at the same time on all nodes)
  • To relocate user service: clusvcadm -r service_name (check with clustat for available service names in your cluster)
  • To relocate user service: clusvcadm -r service_name (check with clustat for available service names in your cluster)

Topics: Red Hat

How to Mount and Unmount an ISO Image in RHEL

An ISO image or .iso (International Organization for Standardization) file is an archive file that contains a disk image called ISO 9660 file system format. Every ISO file have .ISO extension has defined format name taken from the ISO 9660 file system and specially used with CD/DVD Roms. In simple words an iso file is a disk image.

Typically an ISO image contains installation of software such as, operating system installation, games installation or any other applications. Sometimes it happens that we need to access files and view content from these ISO images, but without wasting disk space and time in burning them on to CD/DVD.

This article describes how to mount and unmount an ISO image on RHEL to access and list the content of ISO images.

To mount an ISO image, you must be logged in as root user and run the following commands from a terminal to create a mount point.

# mkdir /mnt/iso
Once you created mount point, use the mount command to mount an iso file. We'll use a file called rhel-server-6.6-x86_64-dvd.iso for our example.
# mount -t iso9660 -o loop /tmp/Fedora-18-i386-DVD.iso /mnt/iso/
After the ISO image mounted successfully, go the mounted directory at /mnt/iso and list the content of an ISO image. It will only mount in read-only mode, so none of the files can be modified.
# cd /mnt/iso
# ls -l
You will see the list of files of an ISO image, that we have mounted in the above command.

To unmount an ISO image, run the following command from the terminal as root:
# umount /mnt/iso

Topics: Red Hat, System Admin

Increase the size of a tmpfs file system

On Linux systems, a tmpfs filesystem keeps the entire filesystem (with all its files) in virtual memory. All data is stored in memory, which means the data is temporary and will be lost after a reboot. If you unmount the filesystem, all data in the file system is gone. You can also a lot of installations using a tmpfs for /tmp and hence anything written to /tmp is wiped after a reboot.

To increase the size, do the following:

Modify /etc/fstab line to look something like this:

none /raw tmpfs defaults,size=2G 0 0
Then, re-mount the file system:
# mount -o remount /raw # df -h
Note: Be careful not to increase it too much as the system will use up real memory.

Number of results found for topic Red Hat: 53.
Displaying results: 1 - 10.