Archive for the ‘RAID and LVM’ Category

Learn to create lvm inside RedHat Enterprise Linux. This tutorial is all about lvm creation in Linux and with creation we also learn how to delete lvm,how to delete volume group and how to delete physical volume in Linux. We learn the complete lvm creation and deletion process in just few simple steps.

For this LVM Lab we have total 5 Hard Drive /dev/sda ,dev/sdb,/dev/sdc ,/dev/sdd and /dev/sde


Out of these 5 only 4 Drives are taking part in this LVM Creation Lab

and those Drives are: /dev/sdb,/dev/sdc,/dev/sdd and /dev/sde

Related Articles for You:

How to extend size of LVM Disk

How to Reduce or shrink the size of LVM Disk

How to create and configure STRIPPED LOGICAL VOLUME in Linux

How to create and configure MIRRORED LOGICAL VOLUME in Linux

How to create and configure SNAPSHOT LOGICAL VOLUME in Linux

(more…)

Advertisement

We have already learnt how to increase the size of lvm using lvextend command in linux.But Now here in this tutorial we will learn the reverse process i.e how to Reduce the lvm size in linux and we will do this in few simple steps.So this is basically an example lab showing how to reduce size of lvm in linux.

reduce lvm size

STEP 1:Check the mounted file system using df -h

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 25G 2.1G 22G 9% /
tmpfs 1014M 0 1014M 0% /dev/shm
/dev/mapper/vg00-lv1 1.5G 34M 1.4G 3% /lvmdata
[root@localhost ~]#

STEP 2:Unmount the file system using umount command

[root@localhost ~]# umount /dev/mapper/vg00-lv1

STEP 3:Now run e2fsck command to check if any file system errors.

[root@localhost ~]# e2fsck -f /dev/mapper/vg00-lv1
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg00-lv1: 11/196608 files (9.1% non-contiguous), 14766/390144 blocks
[root@localhost ~]#

STEP 4:shrink size of /lvmdata to desire size whatever you want.

As you can see above i am going to reduce the size to 1G from 1.5 GB

[root@localhost ~]# resize2fs /dev/mapper/vg00-lv1 1G
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mapper/vg00-lv1 to 262144 (4k) blocks.
The filesystem on /dev/mapper/vg00-lv1 is now 262144 blocks long.

STEP5: Now reduce the size using lvreduce command

root@localhost ~]# lvreduce -L 1G /dev/mapper/vg00-lv1
 WARNING: Reducing active logical volume to 1.00 GB
 THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv1? [y/n]: y
 Reducing logical volume lv1 to 1.00 GB
 Logical volume lv1 successfully resized

STEP 6: Now for safer side check the file system error again.

[root@localhost ~]# e2fsck -f /dev/mapper/vg00-lv1
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg00-lv1: 11/131072 files (9.1% non-contiguous), 12805/262144 blocks
STEP 7: Now mount the file system and check the size.
[root@localhost ~]# mount /dev/mapper/vg00-lv1 /lvmdata/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 25G 2.1G 22G 9% /
tmpfs 1014M 0 1014M 0% /dev/shm
/dev/mapper/vg00-lv1 1008M 34M 934M 4% /lvmdata
[root@localhost ~]#
Hence now you can see we have successfully reduced the size of LVM.
root@localhost ~]# lvs
 LV VG Attr LSize Origin Snap% Move Log Copy% Convert
 lv1 vg00 -wi-ao 1.00G
[root@localhost ~]# lvdisplay
 --- Logical volume ---
 LV Name /dev/vg00/lv1
 VG Name vg00
 LV UUID gx22Pn-9YAe-th6G-jGw7-vD2X-Qhov-bi05Ox
 LV Write Access read/write
 LV Status available
 # open 1
 LV Size 1.00 GB
 Current LE 256
 Segments 2
 Allocation inherit
 Read ahead sectors auto
 - currently set to 256
 Block device 253:0
[root@localhost ~]#

If you are working as a Linux System Admin then resizing the file system size is an important task for you and you must know that.Here in this tutorial we are going to learn how to increase or extend lvm partition size.As we all know LVM provides us the facility to increase or reduce the of partition.

So here we will learn to increase lvm size using lvextend command,but before that we will create lvm first and mount it so that it is ready for use.

STEP1: Create Physical Volumes using pvcreate command.

[root@localhost ~]# pvcreate /dev/sda{5,6,7}
 Physical volume "/dev/sda5" successfully created
 Physical volume "/dev/sda6" successfully created
 Physical volume "/dev/sda7" successfully created

now check the create physical volume using pvscan.

[root@localhost ~]# pvscan
 PV /dev/sda5 lvm2 [964.81 MB]
 PV /dev/sda6 lvm2 [964.81 MB]
 PV /dev/sda7 lvm2 [831.46 MB]
 Total: 3 [2.70 GB] / in use: 0 [0 ] / in no VG: 3 [2.70 GB]

STEP2: create Volume Group using vgcreate command

[root@localhost ~]# vgcreate vg00 /dev/sda{5,6,7}
 Volume group "vg00" successfully created
[root@localhost ~]# vgs
 VG #PV #LV #SN Attr VSize VFree
 vg00 3 0 0 wz--n- 2.69G 2.69G
[root@localhost ~]# pvscan
 PV /dev/sda5 VG vg00 lvm2 [964.00 MB / 964.00 MB free]
 PV /dev/sda6 VG vg00 lvm2 [964.00 MB / 964.00 MB free]
 PV /dev/sda7 VG vg00 lvm2 [828.00 MB / 828.00 MB free]
 Total: 3 [2.69 GB] / in use: 3 [2.69 GB] / in no VG: 0 [0 ]
 [root@localhost ~]#

STEP3: Create Logical Volume(lvm) name lv1 using lvcreate command.

[root@localhost ~]# lvcreate -L +1G -n lv1 vg00
 Logical volume "lv1" created
 [root@localhost ~]# lvs
 LV VG Attr LSize Origin Snap% Move Log Copy% Convert
 lv1 vg00 -wi-a- 1.00G
 [root@localhost ~]#
[root@localhost ~]# lvdisplay
 --- Logical volume ---
 LV Name /dev/vg00/lv1
 VG Name vg00
 LV UUID YYXZk0-bs6F-wE8z-88P3-f67R-G4vj-IrohD2
 LV Write Access read/write
 LV Status available
 # open 0
 LV Size 1.00 GB
 Current LE 256
 Segments 2
 Allocation inherit
 Read ahead sectors auto
 - currently set to 256
 Block device 253:0
 [root@localhost ~]#
[root@localhost ~]# pvscan
 PV /dev/sda5 VG vg00 lvm2 [964.00 MB / 0 free]
 PV /dev/sda6 VG vg00 lvm2 [964.00 MB / 904.00 MB free]
 PV /dev/sda7 VG vg00 lvm2 [828.00 MB / 828.00 MB free]
 Total: 3 [2.69 GB] / in use: 3 [2.69 GB] / in no VG: 0 [0 ]
 [root@localhost ~]#

STEP4: Format and Mount it so that it is ready for use.

First format the file system using mkfs.ext3 command.

[root@localhost ~]# mkfs.ext3 /dev/vg00/lv1

Then create a directory to mount newly created File System.

[root@localhost ~]# mkdir /lvmdata
Now mount newly created file system using mount command to use.
[root@localhost ~]# mount /dev/vg00/lv1 /lvmdata

STEP5: View it’s size using lvs, lvdisplay or df -Th command.

[root@localhost ~]# df -h
 Filesystem Size Used Avail Use% Mounted on
 /dev/sda1 25G 2.1G 22G 9% /
 tmpfs 1014M 0 1014M 0% /dev/shm
 /dev/mapper/vg00-lv1 1008M 34M 924M 4% /lvmdata
 [root@localhost ~]#
[root@localhost ~]# lvs
 LV VG Attr LSize Origin Snap% Move Log Copy% Convert
 lv1 vg00 -wi-ao 1.00G
 [root@localhost ~]#

STEP6:Before making change to lvm check the free available space in the volume group “vg00”.

[root@localhost ~]# vgdisplay vg00
 --- Volume group ---
 VG Name vg00
 System ID
 Format lvm2
 Metadata Areas 3
 Metadata Sequence No 2
 VG Access read/write
 VG Status resizable
 MAX LV 0
 Cur LV 1
 Open LV 1
 Max PV 0
 Cur PV 3
 Act PV 3
 VG Size 2.69 GB
 PE Size 4.00 MB
 Total PE 689
 Alloc PE / Size 256 / 1.00 GB
 Free PE / Size 433 / 1.69 GB
 VG UUID vBYPKn-9Bpk-jvK2-tc2e-e78U-V5jq-lgbcbZ
 [root@localhost ~]#

STEP7:Use lvextend command to increase the size of lvm named “lv1”

[root@localhost ~]# lvextend -L +500M /dev/vg00/lv1
 Extending logical volume lv1 to 1.49 GB
 Logical volume lv1 successfully resized

STEP8:check file system size using lvs or lvdisplay.

[root@localhost ~]# lvs
 LV VG Attr LSize Origin Snap% Move Log Copy% Convert
 lv1 vg00 -wi-ao 1.49G
 [root@localhost ~]#

You can see above output the file size increased here.

STEP9:Check Mounted file system size using df -h

[root@localhost ~]# df -Th
 Filesystem Type Size Used Avail Use% Mounted on
 /dev/sda1 ext3 25G 2.1G 22G 9% /
 tmpfs tmpfs 1014M 0 1014M 0% /dev/shm
 /dev/mapper/vg00-lv1
 ext3 1008M 34M 924M 4% /lvmdata
 [root@localhost ~]#

but you can see File system size not updated here because to update it we need to run resize2fs command.

STEP10:Run resize2fs command to resize the file system size.

[root@localhost ~]# resize2fs /dev/vg00/lv1
 resize2fs 1.39 (29-May-2006)
 Filesystem at /dev/vg00/lv1 is mounted on /lvmdata; on-line resizing required
 Performing an on-line resize of /dev/vg00/lv1 to 390144 (4k) blocks.
 The filesystem on /dev/vg00/lv1 is now 390144 blocks long.
 [root@localhost ~]#
STEP11: Again check mounted file system size using df -h.
[root@localhost ~]# df -h
 Filesystem Size Used Avail Use% Mounted on
 /dev/sda1 25G 2.1G 22G 9% /
 tmpfs 1014M 0 1014M 0% /dev/shm
 /dev/mapper/vg00-lv1 1.5G 34M 1.4G 3% /lvmdata
 [root@localhost ~]#

 In this tutorial we will learn how to manually fail a device used in raid and how to add a new to device to existing raid. we will also learn how to use spare device and how to stop and remove software raid completely from our linux machine. But before we starting removing any devices from existing  raid device first check the built topology of created raid.check the number of disk and name of disk used in raid as active device and find out the device name used as spare device using below linux command line tools. (more…)

This tutorial is all about software raid-1 creation in linux.We will learn how to configure software raid-1 in linux having spare devices.In this lab we are going to use RedHat Enterprise Linux 5 to configure software raid-1 with spare device.We use spare device as a reserved disk which is used only when any of disk used in raid-1 failed.

As we know RAID-1 needs minimum of two disk and when any of disk among those two failed or crashes spare device replaces itself with that failed device or disk.

raid1 configuration in linux

 

(more…)

This tutorial is all about how to configure software raid-0  in RedHat Enterprise Linux.Even if you are new to Linux you can easily configure RAID-0 by reading this article.I have written raid-0 creation notes step wise from begining to end.In this article instead of two hard drive i have used two different partitions to show you how to create and configure software RAID-0 in Linux.RAID-0 is also known as No RAID because it doesn’t provides redundancy.To create RAID-0 array minimum device/partitions required is two.RAID-0 write data on different hard drives and hence increase the read-write speed.RAID-0 is needed only where we needs performance but no redundancy.

(more…)

This tutorial is all about LVM SNAPSHOT .Please Don’t think that it is a substitute of media backup,no it’s not.LVM Snapshot features provides the ability to  create virtual images of device at a particular instant without causing any service interruption. so you can also say that Snapshot copies of a file system are just a virtual copy and not a media backup for file system.snapshot features requires a minimal amount of storage.3-5% of the original capacity is enough to store and maintain snapshot data.

Also read:

lvm configuration in Linux.

Now what happen when change is made to original device after a snapshot is taken?

Answer is snapshot features make a copy of the changed data area as it was prior to the changes so that it can reconstruct the state of the device.

(more…)

In the world of computer  data is more important and with increase in internet users it’s increasing very fast and hence now storing data is most challenging task.Now it is not good to store your data on single drive when you know your data is important,because in case of disk failure your data will loss and it will be a huge disaster.So in place of storing data on a single disk it will be intelligent decision to store your data on multiple disk such that if one disk fails your data is still safe on second disk.

Also Read:

How to configure and Delete LVM in Linux.

There are two technology or you can say there are two methods commonly used to store data on multiple disk:

(1)One is to strore data on multiple disk through RAID and

(2)other is through LVM.

Since LVM provides us more flexblity  in handling disk and managing data,so most of us prefer configuring LVM.

In This article i have mentioned how to create and configure mirrored logical volume.here we learn the fundamental concept of LVM Mirroring and also learn to create,manage ad maintain LVM mirror in Linux in few simple steps. (more…)

In this article we learn how to create an LVM striped logical volume that stripes data accross the disks and it is very similar to RAID-O.Here we will learn all the methods to create and configure a striped LVM.Striped Logical Volume Increases the performance because with striping I/O can be done in parallel.Striping enhance the  performance by writing users data to a predetermined numbers of physical volumes in round robin fashion.It also improves the efficiency  of the data I/O for large sequential reads and writes.This Lab will help you to understand LVM configuration and also makes you to learn and grab the configuration of striped logical volume.

Also Read: How to Configure and Delete lvm in Linux (more…)

This article is all about Linux interview questions.In this article i have mentioned only LVM related interviews questions.It will be helpful for all those students who wants to start their career in Linux Field as a Linux System Admin.This article will help you to explore lvm little more and indepth.I have tried my best to include all LVM related interview question in this single article.If you are already a system admin I request you to post LVM related questions in comment section if any question left. (more…)

RAID,LVM & SWAP QUESTION PAPER

This is a test paper or practice paper for students preparing for RHCSA and  RHCE certification exams.In this section i have mentioned only RAId and LVM related questions asked during interviews or during RHCE exams.It will help you to understand the RAID and LVM concept in depth and learn the technology in better way.You can test your skill by solving these problems. (more…)