Operations grimoire/How to attach a new virtual disk
From Nasqueron Agora
This procedure can is intended to provision storage for a Docker engine, or to add extra space disk to a server.
On the hypervisor
VMWare ESXi
Disks are created on the VMFS datastore. They are generally stored in the server folder.
- Go to the relevant datastore folder:
cd /vmfs/volumes/datastore1
cd some-server
- Create the disk:
vmkfstools -c 200G some-disk-name.vmdk
- Seek the server ID with
vim-cmd vmsvc/getallvms | grep some-server
(the server ID is the first column value) - Attach the disk with
vim-cmd vmsvc/device.diskaddexisting <server ID> /vmfs/volumes/53b61491-b0561938-eec8-0cc47a055d1e/Dwellers/Mastodon.vmdk 0 1
, using absolute path to the disk
If all works, you should see the disk detected as new hardware in the guest journal.
For example, for a CentOS host:
Sep 17 21:49:43 equatower.nasqueron.org kernel: vmw_pvscsi: msg type: 0x0 - MSG RING: 1/0 (5) Sep 17 21:49:43 equatower.nasqueron.org kernel: vmw_pvscsi: msg: device added at scsi0:1:0 Sep 17 21:49:43 equatower.nasqueron.org kernel: scsi 0:0:1:0: Direct-Access VMware Virtual disk 2.0 PQ: 0 ANSI: 6 Sep 17 21:49:43 equatower.nasqueron.org kernel: sd 0:0:1:0: [sdb] 1677721600 512-byte logical blocks: (858 GB/800 GiB) Sep 17 21:49:43 equatower.nasqueron.org kernel: sd 0:0:1:0: [sdb] Write Protect is off Sep 17 21:49:43 equatower.nasqueron.org kernel: sd 0:0:1:0: [sdb] Mode Sense: 61 00 00 00 Sep 17 21:49:43 equatower.nasqueron.org kernel: sd 0:0:1:0: Attached scsi generic sg2 type 0 Sep 17 21:49:43 equatower.nasqueron.org kernel: sd 0:0:1:0: [sdb] Cache data unavailable Sep 17 21:49:43 equatower.nasqueron.org kernel: sd 0:0:1:0: [sdb] Assuming drive cache: write through Sep 17 21:49:43 equatower.nasqueron.org kernel: sd 0:0:1:0: [sdb] Attached SCSI disk
On the guest
CentOS / LVM
You need to create a new partition in the attached disk with fdisk. Afterwards, you can decalre this partition as a physical volume and add it to an existing logical group, or create a new group with this volume. Finally, you add mounting point to fstab.
That means:
fdisk /dev/sdb
- Check the journal contains an entry for your new partition, like
Sep 17 21:54:42 equatower.nasqueron.org kernel: sdb: sdb1