Help:Adding Disk Space to Cloud VPS instances

From Wikitech
Jump to navigation Jump to search


Overview

This page explains how to add additional disk space to your Cloud VPS instance.

Cinder: Attachable Block Storage for cloud-vps

Cloud VPS provides attachable block storage for VMs via the OpenStack Cinder project. 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.

Horizon Cinder Screenshot.png

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 Attachements' action in Horizon.
  3. On the VM, run "sudo prepare_cinder_volume".
andrew@abogott-mounttool:~$ sudo 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.

Useful Commands

prepare_cinder_volume

The custom 'prepare_cinder_volume' script is useful for setting up new Cinder devices. It will format and mount the new volume and add an entry to /etc/fstab so that the volume is re-mounted after a reboot.

This tool is only useful for newly-created block devices. It can not be used to reattach formatted volumes or move volumes between instances.

$ sudo 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>'.

andrew@abogott-mounttool:~$ 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:

$ 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 10Gb. To request additional quota for your project, open a quota request ticket in Phabricator. Most reasonable requests will be granted within 7 days.

With LVM (deprecated as of February, 2021)

On VMs created before 2021 when attachable block storage was added as a feature, disk expansion was handled via instance flavor and LVM. If you are creating new VMs or designing new workflows, you should use Cinder volumes. These documents remain in place to support old VMs or puppet classes that rely on the LVM process.

Storage quota on Cloud VPS instances

Cloud VPS instances have a maximum storage quota based on the size of the instance. By default only 20G of the allowed quota is allocated to the instance as the / volume.

The additional space is allocated to /srv. If you already have content in /srv, it will be hidden by the new mount.

Back up your content before proceeding, or see recovery instructions below.

Adding space as a second volume

The additional space can be added to the instance as a separate logical volume. The easiest way to do this is by enabling the role::labs::lvm::srv Puppet role.


If you have Horizon puppet set to 'yaml mode' (the default):

  1. go to https://horizon.wikimedia.org/project/ ;
  2. set "your project" in the project filter;
  3. find the instance you want to change the in the table below that;
  4. click on the Puppet Configuration tab to get to the Puppet management screen for that instance;
  5. Add a new line with "role::labs::lvm::srv" to the "Puppet Classes" field
  6. wait for the Puppet job to run, OR connect to the instance and run sudo puppet agent --test --verbose.


If you have Horizon puppet set to 'guided mode':

  1. go to https://horizon.wikimedia.org/project/ ;
  2. set "your project" in the project filter;
  3. find the instance you want to change the in the table below that;
  4. click on the Puppet Configuration tab to get to the Puppet management screen for that instance;
  5. in the row for role::labs::lvm::srv, click on the Apply Class button;
  6. in the pop-up, click on the Apply;
  7. wait for the Puppet job to run, OR connect to the instance and run sudo puppet agent --test --verbose.

After the Puppet run completes you should see a new volume mounted at /srv. The size of this volume will depend on the amount of remaining quota for your instance.

Mind the /srv. directory will be owned by root., and this will be enforced by puppet. /srv. is a directory for a collection of local content. Best practice is to create subdirectories for each individual service and give permissions to project members appropriately.

Moving old /srv data to new volume

If you only realized that you need more space after you have put things in the /srv directory of the root partition, follow these basic steps to move that data to the new volume:

  1. Add the new volume as shown above
  2. Run mount and make sure the volume is mounted. If it is not force another puppet run.
  3. Run sudo -s to get a root shell. This will make the next steps easier.
  4. puppet agent --disable 'Moving data from /srv to new volume'
  5. umount /srv
  6. mount /dev/mapper/vd-second--local--disk /mnt
  7. Copy data from /srv to /mnt with cd /srv; tar cf - . | (cd /mnt; tar xpvf -)
  8. Verify that /mnt now has the expected data.
  9. Remove old data from /srv with cd /srv; rm -rf *
  10. cd; umount /mnt
  11. mount /dev/mapper/vd-second--local--disk /srv
  12. Verify that mount worked with mount and by examining /srv
  13. puppet agent --enable
  14. puppet agent --test --verbose to make sure things stay as expected

Resize root partition

See Help:Resize root partition for an explanation of how to attempt to resize the / volume for an existing instance.

Communication and support

We communicate and provide support through several primary channels. Please reach out with questions and to join the conversation.

Communicate with us
Connect Best for
Phabricator Workboard #Cloud-Services Task tracking and bug reporting
IRC Channel #wikimedia-cloud connect General discussion and support
Mailing List cloud@ Information about ongoing initiatives, general discussion and support
Announcement emails cloud-announce@ Information about critical changes (all messages mirrored to cloud@)
News wiki page News Information about major near-term plans
Cloud Services Blog Clouds & Unicorns Learning more details about some of our work
Wikimedia Technology Blog techblog.wikimedia.org News and stories from the Wikimedia technical movement