Operations grimoire/How to attach a new virtual disk: Difference between revisions
From Nasqueron Agora
(Created page with "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...") |
|||
Line 37: | Line 37: | ||
# <code>fdisk /dev/sdb</code> | # <code>fdisk /dev/sdb</code> | ||
# Check the journal contains an entry for your new partition, like <code>Sep 17 21:54:42 equatower.nasqueron.org kernel: sdb: sdb1</code> | # Check the journal contains an entry for your new partition, like <code>Sep 17 21:54:42 equatower.nasqueron.org kernel: sdb: sdb1</code> | ||
# Now, you need a volume group: | |||
## If it's a new volume group, <code>vgcreate <volume group name> /dev/sdb1</code> | |||
## If the volume group exists, <code>vgextend <volume group name> /dev/sdb1</code> | |||
# Create a logical volume: <code>lvcreate -l 50%FREE -n <name> <volume group name></code> | |||
# Format it: <code>mkfs -t xfs /dev/<volume group>/<name>code> | |||
# Mount it: <code>echo "/dev/mapper/centos_dwellers-wharf /wharf xfs defaults 1 2" >> /etc/fstab</code> |
Latest revision as of 09:12, 19 September 2018
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
- Now, you need a volume group:
- If it's a new volume group,
vgcreate <volume group name> /dev/sdb1
- If the volume group exists,
vgextend <volume group name> /dev/sdb1
- If it's a new volume group,
- Create a logical volume:
lvcreate -l 50%FREE -n <name> <volume group name>
- Format it:
mkfs -t xfs /dev/<volume group>/<name>code>
- Mount it:
echo "/dev/mapper/centos_dwellers-wharf /wharf xfs defaults 1 2" >> /etc/fstab