Operations grimoire/How to attach a new virtual disk

From Nasqueron Agora
Revision as of 09:12, 19 September 2018 by Dereckson (talk | contribs) (→‎CentOS / LVM)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

📕📁📜 Old technical information :: content warning

⌛ This Nasqueron Operations Grimoire page hasn't been updated for a long time.

☣ As our infrastructure evolves quickly, there is a good chance this information is outdated or now inaccurate. Be careful and consider update it.

➡️ To assert the information is still up-to-date or not, you can check the history of the relevant role in our Operations repository.

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.

  1. Go to the relevant datastore folder:
    1. cd /vmfs/volumes/datastore1
    2. cd some-server
  2. Create the disk: vmkfstools -c 200G some-disk-name.vmdk
  3. Seek the server ID with vim-cmd vmsvc/getallvms | grep some-server (the server ID is the first column value)
  4. 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:

  1. fdisk /dev/sdb
  2. Check the journal contains an entry for your new partition, like Sep 17 21:54:42 equatower.nasqueron.org kernel: sdb: sdb1
  3. Now, you need a volume group:
    1. If it's a new volume group, vgcreate <volume group name> /dev/sdb1
    2. If the volume group exists, vgextend <volume group name> /dev/sdb1
  4. Create a logical volume: lvcreate -l 50%FREE -n <name> <volume group name>
  5. Format it: mkfs -t xfs /dev/<volume group>/<name>code>
  6. Mount it: echo "/dev/mapper/centos_dwellers-wharf /wharf xfs defaults 1 2" >> /etc/fstab