megacli - Delete Virtual Disk

The command to delete a virtual disk is simple, but we should be careful with its usage. If the wrong parameter is passed you can end up deleting the wrong virtual disk and end up losing your data.

The command to delete the VD is the below :

root@hv2:~/storage/megacli# megacli -cfglddel -l1 -a0
                                     
Adapter 0: Deleted Virtual Drive-1(target id-1)

Exit Code: 0x00

-l1 - is the ID of the virtual disk. You can use the script in this post to get the ID of the virtual disk you want deleted.

-a0 - its the adapter number. The same script recommended can be used to identify your adapter ID.

Virtual Disks before the command :

{
  "id": "0",
  "raid-type": "  Primary-1, Secondary-0, RAID Level Qualifier-0 ",
  "size": "  136.218 GB ",
  "state": "  Optimal ",
  "number-drives": "  2 ",
  "physical-disks": [
    {
      "enclosure-id": "  17 ",
      "slot": "  0 ",
      "disk-size": "  136.732 GB [0x11177330 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  1 ",
      "disk-size": "  136.732 GB [0x11177330 Sectors] ",
      "disk-state": "  Online, Spun Up "
    }
  ]
}
{
  "id": "1",
  "raid-type": "  Primary-6, Secondary-0, RAID Level Qualifier-3 ",
  "size": "  4.361 TB ",
  "state": "  Optimal ",
  "number-drives": "  10 ",
  "physical-disks": [
    {
      "enclosure-id": "  17 ",
      "slot": "  4 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  5 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  6 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  7 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  8 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  9 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  10 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  11 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  12 ",
      "disk-size": "  558.792 GB [0x45d964b8 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  13 ",
      "disk-size": "  558.911 GB [0x45dd2fb0 Sectors] ",
      "disk-state": "  Online, Spun Up "
    }
  ]
}

And the output after deletion :

{
  "id": "0",
  "raid-type": "  Primary-1, Secondary-0, RAID Level Qualifier-0 ",
  "size": "  136.218 GB ",
  "state": "  Optimal ",
  "number-drives": "  2 ",
  "physical-disks": [
    {
      "enclosure-id": "  17 ",
      "slot": "  0 ",
      "disk-size": "  136.732 GB [0x11177330 Sectors] ",
      "disk-state": "  Online, Spun Up "
    },
    {
      "enclosure-id": "  17 ",
      "slot": "  1 ",
      "disk-size": "  136.732 GB [0x11177330 Sectors] ",
      "disk-state": "  Online, Spun Up "
    }
  ]
}