• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

pvcreate error : Can’t open /dev/sdx exclusively. Mounted filesystem?

By admin

So, here is the situation – pvcreate and vgcreate command throws errors shown below.

# pvcreate /dev/sdd1
Can't open /dev/sdd1 exclusively. Mounted filesystem?
# vgcreate vg1 /dev/sdd1
Can't open /dev/sdd1 exclusively. Mounted filesystem?
Unable to add physical volume '/dev/sdd1' to volume group 'vg1'.

Probable Cause of the error

LVM will only create a pv label on a device if it is not currently in use. There are some of the other various causes for this issue, which include’s:

  • The device for pvcreate has a mounted filesystem.
  • The device for pvcreate has a partition, but you are running pvcreate on the whole disk.
  • The device for pvcreate is a dm-multipath and no longer has on-disk partitions but may still have partitions mapped in device-mapper tables.
  • The device for pvcreate was previously an LVM PV, and there are still entries in the device-mapper table for this device.

1. Make sure the device is not mounted on which you trying to create PV.

# df -hP
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/vg1-lv1   17G  4.3G   13G  26% /data

You can also run ‘fuser’ command on the partition to see what processes are accessing the device.

# fuser -m -v /dev/sdd1

2. If it is being used by a mount point which is currently mounted, umount it first.

# umount /data

3. If you are running pvcreate on the whole disk, remove any partition on that disk, or create a PV on a new partition.

# pvremove /dev/sdd1

4. Run a scan at PV,LV and VG level.

# pvscan
# vgscan
# lvscan

5. If the device is a dm(device mapper)-multipath device, then check for any stale entries in ‘dmsetup table‘. Remove stale entries if any.

# dmsetup info -C
# dmsetup remove [dm_map_name]
Note : If the device is in use and if any service is using that, stop the service and unmount the file system (if it is mounted ) prior to performing the aforementioned steps.

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 7 : GRUB2 configuration file /boot/grub2/grub.cfg explained
  2. CentOS / RHEL 7 : Booting process
  3. CentOS / RHEL 7 : How to disable Transparent Huge pages (THP)
  4. How to Configure Device File owner/group with udev rules
  5. How to Re-Create the Yum Cache and/or Force a Fetch of the Package List of the Enabled Repositories
  6. How to Run a Script When USB Devices Is Attached or Removed Using UDEV
  7. How to split iso or file using ‘split’ command in Linux
  8. CentOS / RHEL 7 : How to Enable the Old ethX Style Network Interfaces Names
  9. CentOS / RHEL : How to delete a volume group in LVM
  10. Common Error Messages from Command xfs_repair in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Oracle Database – Configuring Secure Application Roles
  • Extend rule sets by using factors in Oracle Database Vault
  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary