You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Extending an LVM volume on a VMWare host

Back story
This is going to be a short blog post. Mostly with commands. Basically I run a media server for online courses/lectures called Echo360 ESS. At some point the LVM volume which holds the lecture captures nearly filled up. I was getting Icinga alerts on it and by looking at the rate of data generation in munin showed me I had better hop to it. So that's what this post is about.

The fun stuff

Add disk to VM

I added a disk to the virtual machine and then rescanned disks so that it would be apparent in the VM.

Code:

#Add the disk to VMWare disk in VM settings
#then rescan the disks so it shows up
echo "- - -" > /sys/class/scsi_host/host0/scan
#check out what the new device is called
dmesg
#in my case the new device is /dev/sdf

Extending an LVM volume

Code:

#look at the devices in the volume
lvdisplay
#look at each device
pvdisplay /dev/sdb
pvdisplay /dev/sdd
#deactivate the logical volumes in the volume group
vgchange -an vg_echo360
#initialize the disk for use by LVM
pvcreate /dev/sdf
#get the VG Name and extend it
vgdisplay
vgextend vg_echo360 /dev/sdd
#get the LV name
lvdisplay
#now that we have the LV name let's extend it with the new LV in our LV group
lvextend /dev/vg_echo360/lv_echo360 /dev/sdf
#check that the volume has been successfully extended
vgdisplay -v
lvdisplay
#activate the logical volumes in the volume group vg_echo360
vgchange -ay vg_echo360
#check the filesystem before resizing
e2fsck -f /dev/mapper/vg_echo360-lv_echo360
#proceed to resize the ext2/3 filesystem to the new volume size
resize2fs /dev/mapper/vg_echo360-lv_echo360

Taking LVM snapshots for recovering changes

Take a snapshot of the disk before removing raw files older than 120 days. Here is the find command which will be used.

mkdir /mnt/snapshot_recovery
mount /dev/vg_echo360/echo_snapshot1 /mnt/snapshot_recovery
#Now the path /mnt/snapshot_recovery contains the filesystem at a state from when the snapshot was taken.

Removing the snapshot

Code:

lvremove /dev/vg_echo360/echo_snapshot1
#Do not allow the LVG to allocate data to /dev/loop0 any longer. This sets the PV Status to NOT allocatable.
pvchange -xn /dev/loop0
#Check out the status of /dev/loop0 compared to the other devices.
vgdisplay -v
#Remove the loopback device from the LVG entirely.
vgreduce vg_echo360 /dev/loop0
#See that the device is missing in the following command?
vgdisplay -v
#Now that the device is removed from the LVG you can remove the loopback device from the system entirely.
losetup -a
#/dev/loop0 is the device I want to remove which is using /app/loop.
losetup -d /dev/loop0
rm /app/loop
#If you accidentally removed the loopback device before removing it from the LVM that's okay. Just be sure to run the following command on the LVG.
vgreduce --removemissing vg_echo360

That's about it. Use the man pages to exercise a better understanding!