Showing posts with label logical volume manager. Show all posts
Showing posts with label logical volume manager. Show all posts

Saturday, 22 January 2022

Can not remove Logical Volume, message "Logical volume contains a filesystem in use"

In my local machine, I have multiple logical volume. When I try to remove below logical volume, getting below error.

[root@redhat001:~]# lvremove /dev/mapper/system-lv_redhat

Logical volume /dev/mapper/system-lv_redhat contains a filesystem in use.

To remove this logical volume in redhat linux system, please follow the below methods. 


1. Please check if any logical volume mounted on your system. To check this you can simply use "mount" command with grep option.

[root@redhat001:~]# mount | grep /dev/mapper/system-lv_redhat

Above command will provide you information if logical system is mount or not.  If you found, file system is mount, then please umount it first, remove entry from /etc/fstab then try to remove logical volume.


2. In case no logical volume mounted but still you are not able to remove logical volume then you need to check this method if any file is open or any active process using by this logical volume. To check this please run the below command. 

[root@redhat001:~]# lsof | grep /dev/mapper/system-lv_redhat

or 

[root@redhat001:~]#ps -ef | grep /dev/mapper/system-lv_redhat

Using first command you can find if any file is open at system end and it is use by this logical volume, so please check this and close files.

Second command use when you get any process using by this logical volume. please kill the particular process. If process use by root file system, I would suggest instead of killing the process, please stop any application if running and reboot the server, so it would automatically kill your process.

3. You can deactivate logical volume and remove it

[root@redhat001:~]# lvchange -an /dev/mapper/system-lv_redhat

[root@redhat001:~]#lvs

[root@redhat001:~]#lvremove -f  /dev/mapper/system-lv_redhat

Please deactivate logical volume using lvchange command and run lvs to verify that logical volume deactivate or not. 

Hope using above three methods you can resolve this error. In case of any query, please drop a comment on this article. 

Sunday, 28 May 2017

How to add a new disk on Logical Volume Manager (LVM) in AIX Operating System

AIX logical volume manager (LVM) is a widely used tool for logical volume management which includes allocating disks and resizing logical volumes.

Using logical volume manager, a hard disk or set of hard disk is allocated to one or more physical volumes. Logical volume manage (LVM) allows users to create partitions from more than one disk and allows them to extend the filesystem size online within few seconds.

In below text, you can find how to add a new drive in AIX operating system using LVM.

Step by step method to add a new disk on LVM:

➤ Initially we need to add the new physical or virtual disk to the logical partition. After successfully adding virtual disk you need to re scan your server hardware so we can get the new disk information.

For scanning please run the below command on AIX server terminal.

ibm_aix:/> cfgmgr

The command output show you the available new disk which are connected to this AIX machine.

➤ Let’s assume that the new disk is hdisk01,please run the below command to check the disk.

ibm_aix:/> lsdev -Cc disk
hdisk00  Available  Virtual SCSI Disk Drive
hdisk01  Available  Virtual SCSI Disk Drive

In above output two disk is available hdisk00 & hdisk01.

➤ You need to create a new group and move the new disk hdisk01 in there. Let's assume the new group named is "rootvg". So please find the below command to create a new group and add the disk in it.

ibm_aix:/> mkvg -y rootvg hdisk01

in this step we add "hdisk01" into "rootvg".

➤ "lspv" command is used for getting an information about the new disk "hdisk01". Please find the "lspv" command output as given below.

ibm_aix:/> lspv hdisk01
PHYSICAL VOLUME:    hdisk01                   VOLUME GROUP:     rootvg
PV IDENTIFIER:      00f68f03d1e42951 VG IDENTIFIER     00f68f0300004c0000000153d1e429c1
PV STATE:           active
STALE PARTITIONS:   0                        ALLOCATABLE:      yes
PP SIZE:            128 megabyte(s)          LOGICAL VOLUMES:  17
TOTAL PPs:          799 (102272 megabytes)   VG DESCRIPTORS:   2
FREE PPs:           118 (15104 megabytes)    HOT SPARE:        no
USED PPs:           681 (87168 megabytes)    MAX REQUEST:      256 kilobytes
FREE DISTRIBUTION:  11..00..00..00..107
USED DISTRIBUTION:  149..160..159..160..53
MIRROR POOL:        None

If you look the above output you can see the all information regarding the new disk in details.

➤ In this step, you need to create a log logical volume for jfs2 file system and this needs to be part of volume group "rootvg".

ibm_aix:/> mklv -t jfs2log rootvg 1

➤ Please check the new logical volume (lv) and  used the "lsvg" command to check the new logical volume present on the AIX server.

ibm_aix:/> lsvg
rootvg

The command shown you he existing logical group on the server.

ibm_aix:/> lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot       1       1       1    closed/syncd  N/A
hd6                 paging     404     404     1    open/syncd    N/A
loglv00             jfs2log    1       1       1    open/syncd    N/A
hd4                 jfs2       4       4       1    open/syncd    /

In above output, you can see "rootvg" is volume group present and in rootvg, you can find the logical volume "loglv00".Now we create a logical volume and fixed their size , lets assume we will used 20GB size and used the logical volume name lv_aix.

ibm_aix:/> lsvg rootvg
ibm_aix:/> mklv -t jfs2 -y lv_aix rootvg 30G
ibm_aix:/> mkfs -o log=/dev/loglv00 -V jfs2 /dev/lv_aix

➤ After successfully create filesystem, we will mount the filesystem to a particular folder.

ibm_aix:/> mkdir /aix
ibm_aix:/> mount -o log=/dev/loglv00 /dev/lv_aix /aix

So, nwly "/aix" filesystem has been created, for permanent it, please make an entry in "/etc/filesystems file. So when you will take a reboot of machine the filesystem not umount.

Please comment on the post, if you have any query regarding this topic.

Monday, 22 May 2017

Basic HP-UX Commands for Logical Volume Manager (LVM)

This post is useful for those users which are beginners on HP-UX platform. They can easily find all the basic command which are required for creation a file system using logical volume manager (LVM).

Concept of LVM are same in all Unix operating system. LVM is basically used for disk management in operating system that allow to manager the physical disks and logical volume. Here, I will provide to you all basic HP-UX commands.

Basic Commands of HP-UX LVM: 

⏩ How to create a new volume group, logical volume and file system on HP-UX operating system
 
For creating a new physical volume group on HP-UX system, please use the below method.

hpx:/>pvcreate /dev/rdsk/c2t1d1

"Pvcreate" command is used for creating a physical volume on operating system.
⏩ How to create a volume group on HP-UX operating system.

For creating a volume group, first we need to create a directory which we used as a volume group. In my case I will use my volume group name "vstorage" so I need to create a directory with name of vstorage.

hpx:/>mkdir /dev/vstorage
hpx:/>mknod /dev/vstorage/group c 64 0x010000

Once you create a directory, then please create a new volume group with the available disk c2t1d1.

hpx:/>vgcreate /dev/vstorage /dev/dsk/c2t1d1

⏩ How to create a logical group on HP-UX operating system.

When you successfully create a new volume group "vstorage" as describe in above step, we will create a logical group as describe below.

hpx:/>lvcreate -L 2048 /dev/vstorage

If you see the above command we have created a 2 GB size of logical volume.

⏩ How to create a filesystem on HP-UX operating system.

When you successfully created a new logical volume group, then we will create a new file system with the help of VG and LV.

Please find the below command to create a filesystem on HP-UX operating system using LVM.

hpx:/>newfs -F vxfs -o largefiles /dev/vstorage/vg_vstorage

Note: Here, we used "vstorage" as a VG and vg_vstorage as a LV. Now we will create a directory where we mount the new LV.

hpx:/>mkdir /hpux
hpx:/>mount /dev/vstorage/vg_vstorage /hpux

Now, your new file system "/hpux" has been created with the help of LVM. You can mount the file system permanently in filesystem configuration file, so once you take a reboot of server, your file system will not disappear.

Please comment on the post, if you are facing any issue regarding this topic.