Reducing LVM logical volume size

First of all make sure you have sufficient disk space available before reducing logical volume (otherwise it would result in data loss). Also, make sure to have valid data backup before going forward and making changes.

It’s important to shrink the file system before reducing it to prevent data loss/corruption. The resize2fs program will resize ext2, ext3 or ext4 file systems. It can be used to enlarge or shrink an unmounted file system located on the device.

Here we are redicing the LVM size by 500GB.

Unmount the file system
[root@nagios soj]# umount /dev/exampleVG/exampleLV

Scan and check the file system to be on the safer side
[root@nagios soj]# e2fsck /dev/exampleVG/exampleLV

Shrink the file system with resize2fs as follows:
[root@nagios soj]# resize2fs /dev/exampleVG/exampleLV 500GB

Reduce the logical volume by 500GB with lvreduce:
[root@nagios soj]# lvreduce -L -500GB /dev/exampleVG/exampleLV

Mount the filesystem and check the disk space with df -h command

Advertisements

Extending LVM Volume

This is in continuation of the previous topic – Managing Storage with LVM
Check the initial size of our lvm volume:


[root@nagios soj]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 5.8G 3.3G 2.3G 60% /
tmpfs 836M 0 836M 0% /dev/shm
/dev/xvdj1 40G 1.3G 37G 4% /drive
/dev/mapper/exampleVG-exampleLV
20G 2.9G 16G 16% /lvmdata
<=

[root@nagios ~]# lvdisplay
--- Logical volume ---
LV Name /dev/exampleVG/exampleLV
VG Name exampleVG
LV UUID xMd0My-l7Ez-dqYb-JM75-cKH3-YOfK-HSV1zx
LV Write Access read/write
LV Status available
# open 0
LV Size 20.00 GiB <=
Current LE 5120
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

In order to extend an LVM partition, you have to use lvextend command as follows:

[root@nagios soj]# lvextend -L +10G /dev/exampleVG/exampleLV
Extending logical volume exampleLV to 30.00 GiB
Logical volume exampleLV successfully resized

Here we are adding additional 500 megs of space to the existing exampleLV logical volume. Note the output of df command now. You will see the additional 500 megs is not reflected on the /lvmdata although we have already added 500 megs to it. This is because we have extended the underlying logical volume, but not the file system itself. The command ‘resize2fs’ will do the trick.


[root@nagios soj]# resize2fs /dev/exampleVG/exampleLV
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/exampleVG/exampleLV is mounted on /lvmdata; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/exampleVG/exampleLV to 7864320 (4k) blocks.
The filesystem on /dev/exampleVG/exampleLV is now 7864320 blocks long.

Now, check the ‘df -h’ command and see the difference. You will see the additional 500 megs added to the /lvmdata/ partition.


[root@nagios soj]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 5.8G 3.3G 2.3G 60% /
tmpfs 836M 0 836M 0% /dev/shm
/dev/xvdj1 40G 1.3G 37G 4% /drive
/dev/mapper/exampleVG-exampleLV
30G 2.9G 26G 11% /lvmdata <=

[root@nagios soj]# lvdisplay
--- Logical volume ---
LV Name /dev/exampleVG/exampleLV
VG Name exampleVG
LV UUID xMd0My-l7Ez-dqYb-JM75-cKH3-YOfK-HSV1zx
LV Write Access read/write
LV Status available
# open 1
LV Size 30.00 GiB <=
Current LE 7680
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

So, now we have extended the logincal volume size.

Swapping and Paging

Swapping occurs when an entire process gets transferred to disk from physical memory or is read back into physical memory from the disk

[root@nagios ~]# vmstat -s -S M | grep M
         1740 M total memory
         1723 M used memory
         1411 M active memory
           91 M inactive memory
           16 M free memory
           36 M buffer memory
          142 M swap cache
         1895 M total swap
            5 M used swap
         1890 M free swap

Paging occurs when part of a process gets transferred to disk from physical memory or is read back into physical memory from disk.

[root@domU-12-31-39-01-C1-54:~] getconf PAGESIZE
4096

For more info, you can check out the URL @ what-is-difference-between-swapping-and.html

Quick notes on SAN, ISCI, DAS and NAS

SAN Advantage

Share storage among different application servers

Data is stored at a block level

Physical elements of the SAN (servers, switches, storage arrays, etc.) are connected with Fibre Channel

SAN is scalability and flexibility.

Storage can be added without disrupting the applications and different types of storage can be added to the pool.

Backups is centralized so reducing workload and providing greater assurance that the backups are complete.

Backup traffic never impacts users on the LAN.

iSCSI SAN Advantages

iSCSI is a lower cost alternative to Fibre Channel SAN infrastructure.

Interconnect is Ethernet cable and the switches are Gigabit Ethernet.

Protocol used is TCP/IP.

iSCSI presents volumes as a block storage device which makes them ideal for use by enterprise applications such as Microsoft Exchange and Microsoft SQL Server. In particular, the Microsoft iSCSI Software Initiator is the component of the overall iSCSI environment that makes it possible to make the iSCSI SAN attached disks appear to be local attached disks.

DAS (Direct Attached Storage) Advantages

The disks may be internal to the server or in an array that is connected directly to the server.

Backups must either be performed on each individual server.

Storage can only be added by taking down the application server, then adding physical disks and then rebuilding the storage array.

NAS (Network Attached Storage) Advantages

NAS accesses data by file.

NAS manages its own file system.

NAS can be accesses across multiple operating systems.

NAS backups are more efficient. (With NAS feature called Snapshot provides an almost instantaneous way for the systems administrator to recover lost, deleted, or corrupted files.)

Administrators can assign shares, security settings as they would for a regular file server.

GPG (GNU Privacy Guard) & PGP (Pretty Good Privacy)

Whenever you are downloading any software, you should look if authors/signer’s key and pgp key is available so you can import the pgp key using gpg tool and then verify if that software is signed by the author.

I have downloaded postfix softare from http://mirror.postfix.jp/postfix-release/index.html

[root@centos downloads]# ll
total 3752
-rw-r–r–. 1 root root 3827595 Jun 22 16:27 postfix-2.10.1.tar.gz (Software)
-rw-r–r–. 1 root root 280 Jun 22 16:28 postfix-2.10.1.tar.gz.sig (Sign)
-rw-r–r–. 1 root root 6390 Feb 28 2005 wietse.pgp (pgp)

You have to import the GPG key using the following command:

[root@centos downloads]# gpg –import wietse.pgp
gpg: key C12BCD99: public key “Wietse Venema ” imported
gpg: key D5327CB9: public key “wietse venema ” imported
gpg: Total number processed: 2
gpg: imported: 2 (RSA: 2)
gpg: no ultimately trusted keys found

You can now check for the imported keys as follows:

[root@centos downloads]# gpg –list-keys
/root/.gnupg/pubring.gpg
————————
pub 2048R/C12BCD99 2005-02-28
uid Wietse Venema

pub 1022R/D5327CB9 1992-09-25
uid wietse venema
uid wietse venema

Now, we are verifying the signature against the software as follows:

[root@centos downloads]# gpg –verify postfix-2.10.1.tar.gz.sig postfix-2.10.1.tar.gz
gpg: Signature made Sun 23 Jun 2013 05:28:00 AM IST using RSA key ID C12BCD99
gpg: Good signature from “Wietse Venema “
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: FF 96 4A 8C 96 88 7C 6E A4 EF AD BF 48 34 E1 BB

In the above output, we are just checking if author has signed the software and that’s confirmed by the line marked in bold (gpg: Good signature from “Wietse Venema “).

Now, you can go ahead and install/configure the software.

Linux Shell

Issue the following command to know what shell you are using by default:

[soj@centos ~]$ echo $SHELL
/bin/bash

You can check the list of installed shell on your system with the following command:

[soj@centos ~]$ chsh –list
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh

You can get the same output if you `cat /etc/shells`

You can change your default shell by issuing the following command:

Make sure you are NOT changing root user shell. That might create problems.

[soj@centos ~]$ chsh -s /bin/sh
Changing shell for soj.
Password:
Shell changed.

Before checking your default shell again, logout and login back:

sh-4.1$ echo $SHELL
/bin/sh