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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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. lvextend command examples in Linux
  2. “iscsiadm” Discovery TimeOut With Two Or More Network Interfaces in CentOS/RHEL
  3. How to configure interface in “Promiscuous Mode” in CentOS/RHEL
  4. vim: command not found
  5. pscp – ssh_init: Network error: Cannot assign requested address
  6. CentOS / RHEL LVM : Backing Up Volume Group Metadata
  7. test Command Examples in Linux
  8. dir Command Examples in Linux
  9. a2disconf: command not found
  10. chacl Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright