Jump to content

Help:Adding disk space to Cloud VPS instances

From Wikitech

Cloud VPS provides attachable block storage for VMs via the OpenStack Cinder component. A Cinder volume is created separately from a VM; it can then be 'attached' to a VM, formatted, and mounted within that VM's filesystem. A Cinder volume can also be detached and re-attached to a different VM and will persist after any associated VM is deleted.

Volumes can be created, deleted, expanded, and attached via the 'Volumes' tab in Horizon.

Quick start

To add storage to a cloud-vps instance under /extrastorage:

  1. Create a volume in the Horizon Volumes interface with the 'Create Volume' button. Set name, size, and description. Leave the other settings as defaults.
  2. Attach that volume to your instance using the 'Manage Attachments' action in Horizon.
  3. On the VM, run sudo wmcs-prepare-cinder-volume. This command will format and mount the volume, and it will also add the volume ID to /etc/fstab so that the volume will be remounted automatically if the instance is rebooted.
user@cloud-vm:~$ sudo wmcs-prepare-cinder-volume
This tool will partition, format, and mount a block storage device.


Attached storage devices:

    vda: the primary volume containing /
    vdb: already contains ext4 filesystem
    vdc: 

The only block device device available to mount is vdc.  Selecting.

Where would you like to mount it? </srv> /extrastorage
Ready to prepare and mount vdc on /extrastorage. OK to continue? <Y|n>
Formatting as ext4...
mke2fs 1.44.5 (15-Dec-2018)
Creating filesystem with 1048576 4k blocks and 262144 inodes
Filesystem UUID: 116f7a72-1e26-4ca1-b546-fd7015632900
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

Mounting on /extrastorage...
Updating fstab with UUID=116f7a72-1e26-4ca1-b546-fd7015632900 /extrastorage ext4 nofail,x-systemd.device-timeout=2s 0 2
...
Done.

Alternatively, instead of running sudo wmcs-prepare-cinder-volume, you can add the profile::labs::cindermount::srv Puppet profile to the instance or a relevant prefix.

Reattaching to a different instance

Volumes can be detached from an instance and reattached to a different instance.

  1. Unmount the volume from the old instance using sudo umount /path
  2. Use 'Manage attachments' in Horizon to detach the volume and reattach it to the new instance
  3. In the new instance use wmcs-prepare-cinder-volume to mount the volume. Using sudo mount /dev/sdX /path will also work, but using wmcs-prepare-cinder-volume is preferred because it will also add the volume ID to /etc/fstab and the volume will be remounted automatically if the instance is rebooted.
  4. Unless you plan to delete the old instance, you should manually edit /etc/fstab in the old instance and remove the line pointing to the volume that has been moved to another instance. If you don't remove that line, when you reboot the instance it will try and fail to mount the volume because it's no longer attached.

Useful Commands

wmcs-prepare-cinder-volume

The custom wmcs-prepare-cinder-volume script is useful for setting up new or existing Cinder devices. It will format (if not already formatted) and mount the new volume and add an entry to /etc/fstab so that the volume is re-mounted after a reboot.

user@cloud-vm:~$ sudo wmcs-prepare-cinder-volume
This tool will partition, format, and mount a block storage device.


Attached storage devices:

    vda: the primary volume containing /
    vdb: 
    vdd: 
    vde: already contains ext4 filesystem

What device would you like to format and mount? <vdb>

Detecting available volumes

The lsblk tool is useful for locating available devices and volumes and seeing where they're mounted. Typically, your instance's root drive will be vda; other attached volumes will be vd<something>.

user@cloud-vm:~$ lsblk
NAME   MAJ:MIN RM    SIZE RO TYPE MOUNTPOINT
vda    254:0    0     20G  0 disk 
├─vda1 254:1    0 1007.5K  0 part 
├─vda2 254:2    0     19G  0 part /
└─vda3 254:3    0   1023M  0 part 
vdb    254:16   0      1G  0 disk /moreofmydata
vdd    254:48   0      1G  0 disk 
vde    254:64   0      1G  0 disk

Extend a volume

Volumes can be extended using the 'Extend Volume' action in Horizon. This option is only available for volumes that are not currently attached to an instance.

Once the volume has been extended and re-attached to an instance, the filesystem must be resized. Remount on your VM, check the device name (with lsblk), and then resize with resize2fs:

user@cloud-vm:~$ sudo resize2fs /dev/vdc
resize2fs 1.44.5 (15-Dec-2018)
Filesystem at /dev/vdc is mounted on /extrastorage; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/vdc is now 2097152 (4k) blocks long.

Storage Quotas

The default block storage quota for a project is 80Gb. To request additional quota for your project, open a quota request ticket in Phabricator. Most reasonable requests will be granted within 7 days.

Communication and support

Support and administration of the WMCS resources is provided by the Wikimedia Foundation Cloud Services team and Wikimedia movement volunteers. Please reach out with questions and join the conversation:

Discuss and receive general support
Stay aware of critical changes and plans
Track work tasks and report bugs

Use a subproject of the #Cloud-Services Phabricator project to track confirmed bug reports and feature requests about the Cloud Services infrastructure itself

Read stories and WMCS blog posts

Read the Cloud Services Blog (for the broader Wikimedia movement, see the Wikimedia Technical Blog)