Pvcreate can't open /dev/xvda2 exclusively mounted filesystem

I downloaded the RH Linux 6.7 from RHEL, I wanted to extend the storage for "/" from default 16GB to say 200GB. Here�s the steps I tried is :

  1. Init 1
  2. Using �fdisk /dev/xvda� , delete the swap /dev/xvda3 as well as /dev/xvda2
  3. Re-create /dev/xvda2 with linux LVM using new end blocks
  4. save and exit,
  5. when I try to perform �pvcreate /dev/xvda2�, as there is a chance to re-extend the storage for /dev/xvda2, it fails with below exception:
pvcreate can't open /dev/xvda2 exclusively mounted filesystem

please advice the resolution. Your help is appreciated.

Could you, please, issue the following command as superuser and post the output of it?

dmsetup ls
root@localhost $dmsetup ls
No devices found
root@localhost $

The kernel has to accept the changes you have done and update the tables. Please, issue the following command:

partprobe /dev/xvda

If that does not update the tables, give it a try to:

echo 1 > /sys/block/xvda/device/rescan

If that doesn't do it. You options are reduced to reboot the system. Then, you can pvcreate /dev/xvda2

Neither file "rescan" exists nor reboot system didnt help. Any other answers ?

Until now, I have taken the information you have posted at face value. To continue troubleshooting, some real and undoctored output from the system is necessary.

Please, post the output of the following commands:

lsblk
cat /proc/partitions
fdisk -l
df -h
mount
pvs

[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 126G 0 disk
\u251c\u2500xvda1 202:1 0 102M 0 part /boot
\u251c\u2500xvda2 202:2 0 16G 0 part /
\u2514\u2500xvda3 202:3 0 109.9G 0 part
[root@localhost ~]#

[root@localhost ~]# cat /proc/partitions
major minor #blocks name

202 0 132120576 xvda
202 1 104448 xvda1
202 2 16778240 xvda2
202 3 115236864 xvda3
[root@localhost ~]#

[root@localhost ~]# fdisk -l

Disk /dev/xvda: 135.3 GB, 135291469824 bytes
64 heads, 32 sectors/track, 129024 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b91c5

Device Boot      Start         End      Blocks   Id  System

/dev/xvda1 * 2 103 104448 83 Linux
/dev/xvda2 104 16488 16778240 8e Linux LVM
/dev/xvda3 16489 129024 115236864 8e Linux LVM
[root@localhost ~]#

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda2 16G 5.3G 9.8G 36% /
tmpfs 1.4G 0 1.4G 0% /dev/shm
/dev/xvda1 99M 72M 23M 77% /boot
[root@localhost ~]#

[root@localhost ~]# mount
/dev/xvda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/xvda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
[root@localhost ~]#

[root@localhost ~]# pvs
[root@localhost ~]#

Hi, alnhk
Thank you for posting the information. In deed it shows the cause of the problem.
In your first post you mentioned you have deleted /dev/xvda2 using fdisk . However, the parts I have highlighted in red, show that /dev/xvda2 is not deleted; it has a filesystem and it is mounted. In fact, it can not be deleted unless it is offline, because it is the root ( / ) of the OS filesystem and the operating system will not let you. If you delete that partition booting from another filesystem (like a live CD) you will be erasing the whole OS. I do not think that's what you want.