Operating System - Linux
1748224 Members
4517 Online
108759 Solutions
New Discussion

Re: pvcreate error: can't open /dev/sdb1 exclusively. mounted filesystem?

 
SOLVED
Go to solution
Alvin_14
Advisor

pvcreate error: can't open /dev/sdb1 exclusively. mounted filesystem?

we have just added this disk from emc...

1. fdisk /dev/sdb
2. created primary partition /dev/sdb1
3. change type to 8e
4. pvcreate /dev/sdb1
then i get this error "can't open /dev/sdb1 exclusively. mounted filesystem?"

/dev/sdb1 /dev/sdb is not mounted as this is a new disk.

has anybody experienced this before? any additional config that i need to do?

also, we are using multipath.. so from system-config-lvm i can /dev/sdb and /dev/sdi belong to /dev/dm-0..
6 REPLIES 6
Andrew Cowan
Honored Contributor
Solution

Re: pvcreate error: can't open /dev/sdb1 exclusively. mounted filesystem?

Alvin,

I think you've answered your own question here. If you can see the same disk down both paths, then you must refer to it as "dm0", hence "pvcreate/dev/dm-0".
Asif Sharif
Honored Contributor

Re: pvcreate error: can't open /dev/sdb1 exclusively. mounted filesystem?

Hi Alvin,

I agree with Andrew,please click this link.
http://www.linuxquestions.org/questions/showthread.php?t=527940

Regards,
Asif Sharif
Regards,
Asif Sharif
Himadri_Mandal
New Member

Re: pvcreate error: can't open /dev/sdb1 exclusively. mounted filesystem?

Look like the disk /dev/sdb1 was earlier mounted. And the file does exists in /proc.

Try the restarting the host, that could be one of the easy solution.
This genrally happens if you dont export your volumn group(s) before recreating the drive.

isaac_mathew
New Member

Re: pvcreate error: can't open /dev/sdb1 exclusively. mounted filesystem?

You can surely solve this error by a reboot however  the below commands can be used to resolve this online.

I havent faced any Issues so far with these commands hence I believe they are safe to run in a production enviornment.

------------------------------------------------------------------------------------------------------------------------------------------

ERROR:

The error that I get on a new disk while creating physical volume: 

[root@isaacvm01 ~]# pvcreate /dev/sdd1
Can't open /dev/sdd1 exclusively. Mounted filesystem?

Solution:

List  device names first to see if the disk is present:


[root@isaacvm01 ~]# dmsetup ls | grep sdd
sdd1 (253:14) --> yes it is present.

Next remove the disk:


[root@isaacvm01 ~]# dmsetup remove sdd1

Check it again:


[root@isaacvm01 ~]# dmsetup ls | grep sdd
[root@isaacvm01 ~]# -> yes its gone. 

Now try the pvcreate command again:


[root@isaacvm01 ~]# pvcreate /dev/sdd1
Physical volume "/dev/sdd1" successfully created
[root@isaacvm01 ~]#

I hope this helps. Thanks

Matti_Kurkela
Honored Contributor

Re: pvcreate error: can't open /dev/sdb1 exclusively. mounted filesystem?

When you are using multipathing, it means a single physical disk/LUN can show up as multiple devices: one /dev/sd* device per available path. Using these /dev/sd* devices means you're using that LUN using that one specific path only. This is not what you normally want, so you'll want to use a multipathing solution in this case.

Device-mapper-multipathing won't hide the individual /dev/sd* paths for multipathed devices: you might sometimes need them for e.g. diagnosing failures on a specific path. Instead, it creates a multipathed mapping device /dev/dm-* and a link to it with a persistent name: /dev/mapper/mpath* if you have the multipath.conf "friendly names" option enabled (RedHat default), or /dev/mapper/<WWID of the LUN> if the "friendly names" option is disabled (SuSE default).

Dm-multipath attempts to prevent you from accessing the multipathed LUN using both the multipathed device (/dev/dm-* or /dev/mapper/*) and the individual path device(s) /dev/sd* simultaneously: as soon as something is accessing the multipathed device, dm-multipath sets up an exclusive lock to the corresponding /dev/sd* devices.

Note that the /dev/dm-* device names are created from scratch each time the system starts up, so their numbering may vary between one bootup and the next. So you should always use the /dev/mapper/* names instead: those names are guaranteed to be persistent.

Also note that the /dev/dm-* names are not used only for dm-multipath, but also all the other purposes the device-mapper kernel subsystem is used: LVM, cryptsetup and dmraid all use the /dev/dm-* device names. If you're curious, you can use "dmsetup ls --tree" to see a single list of all the things device-mapper subsystem is currently handling on your system.

MK
EmamBasha
New Member

Re: pvcreate error: can't open /dev/sdb1 exclusively. mounted filesystem?

Thanks, it worked for me. Thanks a lot.