Difference between revisions of "Volumes"
(Pasted Volumes Test page) |
|||
(One intermediate revision by the same user not shown) | |||
Line 42: | Line 42: | ||
== Add Storage Capacity == | == Add Storage Capacity == | ||
− | + | To add more storage capacity to your instance, you can: | |
− | * [[#Create | Create a new volume]] | + | * [[#Create | Create a new volume]] and [[#Attach | attach it to the instance]] as described above, then [[Red_Cloud_Linux_Instances#Initialize_and_Mount_a_Volume | format the volume and mount the file system in Linux]] or [[Red_Cloud_Windows_Instances#Initialize_and_Mount_a_Volume | in Windows]]; or |
+ | * [[#Extend_an_Existing_Volume | Increase the size of an existing volume]], if it is not currently the root volume of an instance; or | ||
+ | * [[#Create_a_Bigger_Copy_of_the_Root_Volume_of_an_Instance | Create a volume that is an identical, but bigger, copy of the root volume of an instance]]. | ||
− | + | The second and third possibilities are described in this section. | |
=== Extend an Existing Volume === | === Extend an Existing Volume === | ||
Line 73: | Line 75: | ||
#** Run the <code>xfs_growfs /mount_point</code> command, where <code>/mount_point</code> is the absolute path name on which the file system is mounted. | #** Run the <code>xfs_growfs /mount_point</code> command, where <code>/mount_point</code> is the absolute path name on which the file system is mounted. | ||
# Use the <code>df -h</code> command to verify the new size of the file system. | # Use the <code>df -h</code> command to verify the new size of the file system. | ||
+ | |||
+ | === Create a Bigger Copy of the Root Volume of an Instance === | ||
+ | |||
+ | # For a Linux instance only, ssh to the instance as centos/ubuntu/root using the matching private key. Run <code>sudo yum</code> or <code>sudo apt</code> <code>install cloud-utils-growpart</code>, in case this package is not installed already. | ||
+ | # Shelve the instance. | ||
+ | # Name the volume for the instance to something memorable, like “volume_to_extend”. | ||
+ | # Snapshot this volume. | ||
+ | # Create a new volume from the snapshot, giving it a bigger size as well as a memorable name, like "bigger_volume". | ||
+ | # Launch a new instance from this volume. In the Source pane, you will have to select “Volume” in the pull-down menu so you can select the “bigger_volume” as the source. After it boots up, the instance should automatically extend the file system to encompass the larger space. | ||
+ | # Disassociate the floating IP from smaller instance (if one has been assigned) and associate the floating IP to the larger instance (again, if appropriate). | ||
+ | # Confirm that the new instance works as expected. If you like, you can log in to the instance and run <code>df /</code> (or look at the size of its C: drive) to confirm the new, larger size, as well as check for the expected files and applications. |
Revision as of 16:40, 25 March 2021
A Volume is a collection of data but typically has the functionality of a formatted hard drive and can host a file system. It can be the root partition (the partition containing the operating system) of a virtual machine (VM) that can be booted, or could act like an extra disk that can be mounted by a VM. Volumes are charged for according to their size and for how long they are stored.
Create and Attach a Volume
Volume creation is useful for attaching a data volume or a volume with users' home directories to an instance, as it is often good to separate the concerns of an operating system and user data. This makes it relatively easy to switch operating systems and maintain the same data, and to archive the more important parts of the project (the data) if needed.
Create
- Go to the "Volumes" tab in the OpenStack Web Interface
- Click the "Create Volume" button
- Enter a name and size
- Click "Create Volume"
Attach
- Go to the "Volumes" tab in the OpenStack Web Interface
- On the Actions dropdown menu for the volume you want to attach, select "Manage Attachments"
- Select the instance you wish to attach to and click "Attach Volume"
- Note that the device name specified is usually not important and not always adhered to
Once You Have Attached The Volume
- For Linux:
- Login to your instance
- Run
lsblk
to see which/dev/vdX
is the likely candidate (for some character 'X') - Follow the instructions for initializing and mounting your volume (replace
vdb
with thevdX
discovered in the previous step)
- For Windows:
- Login to your instance
- Follow the instructions for initializing and mounting your volume
- For Linux:
Snapshots
Snapshots of volumes (and of instances, in which case the volume is implicitly the root volume of the instance) create a state save of the existing volume, so you can easily get back to a certain state in the future. This is most useful for OS volumes to create safe checkpoints of working operating system configuration states. It may be less useful for larger data volumes; a more efficient solution might be to use ZFS snapshots on Linux instances.
Snapshots can be created from the Actions dropdown menu. Note that if you are creating a snapshot of a root volume for an instance, it should not be running. You should first stop the instance, and then take the snapshot.
Snapshots of volumes can be shared with users on a different project (or even with yourself, if you are a member of multiple projects). Simply follow the procedure for sharing found on the OpenStack forum. If the snapshot is of an instance, it may be easier to perform the necessary steps from the command line, as found on CAC's Images page.
Add Storage Capacity
To add more storage capacity to your instance, you can:
- Create a new volume and attach it to the instance as described above, then format the volume and mount the file system in Linux or in Windows; or
- Increase the size of an existing volume, if it is not currently the root volume of an instance; or
- Create a volume that is an identical, but bigger, copy of the root volume of an instance.
The second and third possibilities are described in this section.
Extend an Existing Volume
You can increase the size of an existing volume (but not making it smaller) when the volume is in the detached state.
In the special case of extending root volumes, follow the instructions on this page.
- Detach the volume if it is attached to an instance.
- From inside the instance, unmount the file system to make sure all cached changes are flushed back to disk:
umount /mount_point
, where/mount_point
is the absolute path on which the file system is mounted. - Under Project->Volumes->Volumes on the Red Cloud web console, select the volume you want to detach.
- (Optional but recommended)Click on the "Edit Volume" button in the upper right corner to rename the volume so it is easier to be identified in the subsequent steps.
- Under the pull down menu in the upper right corner, select "Manage Attachments."
- Click on the "Detach Volume" button on the next screen and confirm.
- From inside the instance, unmount the file system to make sure all cached changes are flushed back to disk:
- When the volume is in the detached state and back on the Volumes screen, select the volume again. Under the pull down menu in the upper right corner, select "Extend Volume."
- On the next screen specify the new size for the volume and click on the "Extend Volume" button.
- Re-attach the volume to your instance.
- From inside the instance, extend the file system on the extended volume:
- If the file system is
ext3
orext4
,- Run the
resize2fs device_name
command, where device_name is the device name of the newly extended volume, e.g./dev/vdb
. - Re-mount the file system.
- Run the
- If the file system is
xfs
,- First re-mount the file system.
- Run the
xfs_growfs /mount_point
command, where/mount_point
is the absolute path name on which the file system is mounted.
- If the file system is
- Use the
df -h
command to verify the new size of the file system.
Create a Bigger Copy of the Root Volume of an Instance
- For a Linux instance only, ssh to the instance as centos/ubuntu/root using the matching private key. Run
sudo yum
orsudo apt
install cloud-utils-growpart
, in case this package is not installed already. - Shelve the instance.
- Name the volume for the instance to something memorable, like “volume_to_extend”.
- Snapshot this volume.
- Create a new volume from the snapshot, giving it a bigger size as well as a memorable name, like "bigger_volume".
- Launch a new instance from this volume. In the Source pane, you will have to select “Volume” in the pull-down menu so you can select the “bigger_volume” as the source. After it boots up, the instance should automatically extend the file system to encompass the larger space.
- Disassociate the floating IP from smaller instance (if one has been assigned) and associate the floating IP to the larger instance (again, if appropriate).
- Confirm that the new instance works as expected. If you like, you can log in to the instance and run
df /
(or look at the size of its C: drive) to confirm the new, larger size, as well as check for the expected files and applications.