ASM: Device “/dev/xvdc1” is already labeled for ASM disk “”

In preparation for my OCP examination, I am currently playing around with ASM. For this purpose I am using an AWS instance to install and configure my database. So I added my disks, partitioned them using fdisk and installed ASMLib to manage them. But when I wanted to issue the createdisk command, this happened:

[root@ip-10-234-66-103 ~]# oracleasm createdisk DATA0 /dev/xvdc1
Device "/dev/xvdc1" is already labeled for ASM disk ""

So what is the problem here? Before deciding to use ASMLib, I tried to add the disks using only ASM commands from within the ASM instance, which failed for some reason. This is why I then switched to ASMLib.

Now it seems that the ASM instance somehow wrote data into the disk header and therefore the disk was already assigned to a diskgroup (however, since the command then failed it was not really added to any diskgroup).

[root@ip-10-234-66-103 ~]# oracleasm createdisk DATA0 /dev/xvdc1
Device "/dev/xvdc1" is already labeled for ASM disk ""
[root@ip-10-234-66-103 ~]# oracleasm querydisk /dev/xvdc1
Device "/dev/xvdc1" defines a device with no label

To resolve this issue, clear the header of the disk using the dd command (careful, as this may screw up your disk when done for the wrong device!):

[root@ip-10-234-66-103 ~]# dd if=/dev/zero of=/dev/xvdc1 bs=1024 count=4
4+0 records in
4+0 records out
4096 bytes (4.1 kB) copied, 0.0394133 s, 104 kB/s
[root@ip-10-234-66-103 ~]# oracleasm querydisk /dev/xvdc1
Device "/dev/xvdc1" is not marked as an ASM disk

After the header has been written over with zeroes, you can then add the disk via the createdisk command:

[root@ip-10-234-66-103 ~]# oracleasm createdisk DATA0 /dev/xvdc1
Writing disk header: done
Instantiating disk: done
[root@ip-10-234-66-103 ~]# 

Now I was able to use this disk in my diskgroup. For more information about ASM setup and configuration, refer to the documentation. I can also recommend a cookbook I found on flashdba.com.

Hello world

My name is Simon Krenger, I am a Technical Account Manager (TAM) at Red Hat. I advise our customers in using Kubernetes, Containers, Linux and Open Source.

Elsewhere

  1. GitHub
  2. LinkedIn
  3. GitLab