Guide: Volumes and Images: Difference between revisions

From bwCloud-OS
Jump to navigation Jump to search
No edit summary
No edit summary
Line 26: Line 26:
# Check available block devices with <code>lsblk</code> The new volume will appear with ''no mount point'').
# Check available block devices with <code>lsblk</code> The new volume will appear with ''no mount point'').
# Create a file system, e.g. for ext4: <code>sudo mkfs.ext4 /dev/vdb </code>
# Create a file system, e.g. for ext4: <code>sudo mkfs.ext4 /dev/vdb </code>
#*⚠️''deletes all existing data on the volume!''
#*⚠️ ''Deletes all existing data on the volume!''
# Create a mount point: <code>sudo mkdir -p /mnt/volume</code>
# Create a mount point: <code>sudo mkdir -p /mnt/volume</code>
# Mount the volume: <code>sudo mount /dev/vdb /mnt/volume</code>
# Mount the volume: <code>sudo mount /dev/vdb /mnt/volume</code>
Line 37: Line 37:
# Test the <code>fstab</code> entry: <code>sudo mount -a</code>
# Test the <code>fstab</code> entry: <code>sudo mount -a</code>


===Safely Detach a Volume===
=== Safely Detach a Volume ===


# Close all open files inside the VM and unmount the volume: <code>sudo umount /mnt/volume</code>
# Close all open files inside the VM and unmount the volume: <code>sudo umount /mnt/volume</code>
# In the Dashboard:
# In the Dashboard:
#* Go to '''Volumes → Volumes'''  
#* Go to '''Volumes → Volumes'''  
#* Select  '''volume''' → '''Manage Attachments''' → '''Detach Volume'''.
#* Select  '''Volume''' → '''Manage Attachments''' → '''Detach Volume'''.


===Notes===
=== Resize a Volume ===


* Device naming may vary depending on the image/driver used (e.g., <code>/dev/vdb</code>, <code>/dev/sdb</code>). Always check with <code>lsblk</code>.
# In the Dashboard:
* To resize a volume, use:
#* Go to '''Volumes → Volumes'''
** In the Dasshbord: '''Volumes → Extend Volume'''  
#* Select  '''Volume''' → '''Extend Volume'''
** Then inside the VM: Expand the filesystem  (e.g. for ext4: <code>sudo resize2fs /dev/vdb</code>).
#* Choose a (larger) '''New Size''' and the target instance and click '''Extend Volume'''
* To create backups, use snapshots:
# Then inside the VM: Expand the filesystem  (e.g. for ext4: <code>sudo resize2fs /dev/vdb</code>)
** Go to '''Volumes → Snapshots → Create Snapshot'''
** You can create a new volume from a snapshot later.


=== Create a Snapshot (Backup) from a Volume ===
'''Note:'''  If the volume is in use, '''forcing''' the snapshot may work, but it’s safer to snapshot '''detached volumes''' when possible.     
# In the Dashboard:
#* Go to '''Volumes → Volumes'''
#* Select  '''Volume''' → '''Create Snapshot'''
#* Choose a descriptive '''Snapshot Name''' click '''Create Volume Snapshot'''
# You can create a new volume from a snapshot later.


== Export and Import (Volume-)Images ==
== Export and Import (Volume-)Images ==

Revision as of 21:24, 21 October 2025


Operations on Volumes

Create and Attach a Volume

  1. Log in to the Dashboard and select the correct region (top left).
  2. Go to Volumes → Volumes → Create Volume
  3. Fill in the form:
    • Name: Assign a descriptive name.
    • Source: No source, empty volume (default).
    • Type: Choose a volume type, if options are available.
    • Size: Set the desired size in GiB (e.g., 20).
    • Click Create Volume.
  4. Once created, go to Volumes → Volumes, select the new volume, then:
    • Click Manage Attachments.
    • Choose the target instance and click Attach Volume.
  5. Note the device name shown after attachment (e.g., /dev/vdb or /dev/sdb).

Format and Mount the Volume inside the VM

  1. SSH into your VM: ssh -i /path/to/private-key <user>@<IP-address>
  2. Check available block devices with lsblk The new volume will appear with no mount point).
  3. Create a file system, e.g. for ext4: sudo mkfs.ext4 /dev/vdb
    • ⚠️ Deletes all existing data on the volume!
  4. Create a mount point: sudo mkdir -p /mnt/volume
  5. Mount the volume: sudo mount /dev/vdb /mnt/volume
  6. (Optional) Set ownership: sudo chown $USER:$USER /mnt/volume

Mount the Volume Automatically at Boot

  1. Find the UUID of the device: lsblk -f
  2. Edit /etc/fstab and add a line like this:
    UUID=<the-UUID>  /mnt/volume  ext4  defaults,nofail  0  2
  3. Test the fstab entry: sudo mount -a

Safely Detach a Volume

  1. Close all open files inside the VM and unmount the volume: sudo umount /mnt/volume
  2. In the Dashboard:
    • Go to Volumes → Volumes
    • Select VolumeManage AttachmentsDetach Volume.

Resize a Volume

  1. In the Dashboard:
    • Go to Volumes → Volumes
    • Select VolumeExtend Volume
    • Choose a (larger) New Size and the target instance and click Extend Volume
  2. Then inside the VM: Expand the filesystem (e.g. for ext4: sudo resize2fs /dev/vdb)

Create a Snapshot (Backup) from a Volume

Note: If the volume is in use, forcing the snapshot may work, but it’s safer to snapshot detached volumes when possible.

  1. In the Dashboard:
    • Go to Volumes → Volumes
    • Select VolumeCreate Snapshot
    • Choose a descriptive Snapshot Name click Create Volume Snapshot
  2. You can create a new volume from a snapshot later.

Export and Import (Volume-)Images

Connect to bwCloud-OS using the OpenStack client.

For volumes, first create an image from the volume:

# openstack volume list
# openstack image create \
    --volume <UUID> \
    my_volume_as_image

Download an image:

# openstack image list
# openstack image save \
    --file my_image_file.img \
    <UUID>

Upload a local image file to the image catalog of the selected region and create its metadata entry:

# openstack image create \
    --property os_distro=linux \
    --property ssh_user=<USER> \
    --property hw_video_model=cirrus \
    --file my_image_file.img \
    <NAME>