Creating and Attaching Block Volumes
Task Flow
No. | Task | Links |
---|---|---|
1. |
Create a block volume. |
|
2. |
Attach the block volume to one or more instances. |
or |
3. | Identify the added block volume and perform administrative tasks. | Find Your Volume in the Instance |
4. |
Configure the volume to automatically mount when the instance is rebooted. |
Configuring Volumes to Automatically Mount (Linux Instances) |
Creating a Block Volume
Block volumes are created using the Block Volume service.
Use tags to set values for the Synchronous Write Bias, Secondary Cache, and volume block size properties. See the OCI CLI procedure for descriptions of these properties. To set values for the Synchronous Write Bias and Secondary Cache properties, you must use the OCI CLI.
Using the Compute Web UI
-
On the dashboard, click the Block Storage/View Block Volumes button.
-
Click the Create Block Volume button.
-
Provide the following volume information:
-
Name: Provide a name or description for the volume. Avoid entering confidential information.
-
Compartment: Select the compartment in which to create the block volume.
-
Size (in GBs): The default size of 1024 GB is shown. To change the size, enter a value from 50 to 32768 (50 GB to 32 TB).
-
High Performance Volume: (Optional) By default, the volume uses balanced performance. To create a block volume that uses the high performance feature, click the Enable High Performance button. For more information, see "Block Volume Performance Options" in the Block Volume Storage Overview chapter in the Oracle Private Cloud Appliance Concepts Guide.
This selection cannot be changed after the volume is created.
-
Backup Policy: (Optional) Select a backup policy from the drop-down list. You might need to change the compartment.
Oracle defined policies are listed, as well as any user defined policies. For information about Oracle defined policies (
bronze
,silver
, andgold
), see "Volume Backups and Clones" in the Block Volume Storage Overview chapter in the Oracle Private Cloud Appliance Concepts Guide.Backup policies can be assigned or changed after the volume is created. A volume can only have only one volume backup policy assigned at a time. For information about creating, editing, and assigning backup policies, see Managing Backup Policies. You can also back up this volume manually as described in Creating a Manual Boot or Block Volume Backup.
-
Tagging: (Optional) Add defined or free-form tags for this volume as described in Adding Tags at Resource Creation. Tags can also be applied later.
-
-
Click Create Block Volume.
The volume is ready to attach to an instance after its icon lists the volume in the Available state. See Attaching a Volume.
Using the OCI CLI
-
Get the OCID of the compartment where you want to create the block volume (
oci iam compartment list
) -
Run the volume create command.
This procedure does not show all available parameters for this command. For information about additional parameters, run the command with the
--help
option.Syntax:
oci bv volume create --availability-domain AD-1 \ --compartment-id compartment_OCID
Example:
This example specifies VPUs, log bias, secondary cache, and volume block size.
VPUs per Gigabyte Option
The value of the
--vpus-per-gb
option is the number of volume performance units (VPUs) that will be applied to this volume per GB. The default value forvpus-per-gb
is 10, for balanced volume performance. For higher performance, you can specify 20 VPUs/GB. For more information, see "Block Volume Performance Options" in the Block Volume Storage Overview chapter in the Oracle Private Cloud Appliance Concepts Guide.VPUs per GB cannot be changed after the volume is created.
Private Cloud Appliance does not support volume performance auto-tuning.
Synchronous Write Bias and Secondary Cache Properties
Synchronous Write Bias and Secondary Cache properties can be set by using defined tags. Specify the
OraclePCA
tag namespace. To set a value for the Synchronous Write Bias, specifylogBias
for the tag key. To set a value for the Secondary Cache, specifysecondaryCache
for the tag key. See Adding Tags at Resource Creation for the syntax to specify a defined tag.The
logBias
or Synchronous Write Bias property controls the use of the write cache flash devices for a share or LUN ("Logzilla"). The value of thelogBias
property must be eitherLATENCY
orTHROUGHPUT
. If this value is not set, the valueLATENCY
is used.The
secondaryCache
property controls the use of the read cache flash devices for a share or LUN ("Readzilla"). The value of thesecondaryCache
property must one ofALL
,METADATA
, orNONE
. If this value is not set, the valueALL
is used.The values of the
logBias
andsecondaryCache
properties can be changed with theupdate
command.Volume Block Size Property
The volume block size can be set by using the
PCA_blocksize
free-form tag. The default block size is 8192 bytes. To specify a different block size, specify a value in bytes for thePCA_blocksize
tag. Supported values are a power of 2 between 512 bytes and 1 megabyte, specified as a string and fully expanded. Note that Oracle recommends setting the value to at least 8192 bytes. See Adding Tags at Resource Creation for the syntax to specify a free-form tag.The block size cannot be modified once the volume has been created.
$ oci bv volume create --availability-domain AD-1 \ --compartment-id ocid1.compartment.unique_ID\ --display-name myblockvolume --size-in-gbs 50 --vpus-per-gb 20 \ --defined-tags '{"OraclePCA":{"logBias":"THROUGHPUT","secondaryCache":"METADATA"}}' --freeform-tags '{"PCA_blocksize": "65536"}' { "data": { "auto-tuned-vpus-per-gb": null, "autotune-policies": null, "availability-domain": "AD-1", "block-volume-replicas": null, "compartment-id": "ocid1.compartment.unique_ID", "defined-tags": { "OraclePCA": { "logBias": "THROUGHPUT", "secondaryCache": "METADATA" } }, "display-name": "myblockvolume", "freeform-tags": { "PCA_blocksize": "65536" }, "id": "ocid1.volume.unique_ID", "is-auto-tune-enabled": null, "is-hydrated": null, "kms-key-id": null, "lifecycle-state": "PROVISIONING", "size-in-gbs": 50, "size-in-mbs": 51200, "source-details": null, "system-tags": null, "time-created": "2022-12-08T21:05:36.647925+00:00", "volume-group-id": null, "vpus-per-gb": 20 }, "etag": "08d0abc9-60c6-4fc7-b6fe-85d0af1c0308", "opc-work-request-id": "ocid1.workrequest.unique_ID" }
A
vpus-per-gb
value of 10 indicates that this is a balanced performance volume. Avpus-per-gb
value of 20 indicates that this is a high performance volume.Any backup policy that you assigned is not shown in this output or in the volume list or get output. Instead, use the command shown at the end of Listing Block Volumes and Block Volume Details to show the OCID of any backup policy that is assigned to this volume.
When the volume is in the AVAILABLE state, you can attach the volume to an instance. See Attaching a Volume.
Attaching a Volume
You can attach a volume to an instance to expand the available storage on the instance. A volume can be attached to more than one instance at the same time. See Attaching a Volume to Multiple Instances.
You can also attach a boot volume that has been detached from its instance to a different instance as a data volume. This operation is convenient for troubleshooting a boot volume and for performing administrative operations while the boot volume is detached from its instance.
Important:
Only attach Linux volumes to Linux instances and Microsoft Windows volumes to Microsoft Windows instances.
Important:
If you are reattaching a volume that was detached, the volume might be associated with a different device name, and the instance operating system might not recognize the volume.
Using the Compute Web UI
-
In the navigation menu, click Compute, then click Instances.
-
Select the compartment where the instance resides.
-
In the Instances list, click the instance that you want to attach a volume to.
-
In the lower left panel, under Resources, select Attached Block Volumes.
-
In the Attached Block Volumes panel, click Attach Block Volume.
-
Select the compartment where the block volume resides.
-
Select a Block Volume.
-
Select one of the following access methods:
-
Read/Write: (Default) Configures the volume attachment with read/write capabilities. The volume cannot be shared with other instances. This option enables attachment to a single instance only.
-
Read/Write - Shareable: Configures the volume attachment as read/write, shareable with other instances. This option enables read/write attachment to multiple instances.
-
Read Only - Shareable: Configures the volume attachment as read-only, enabling attachment to multiple instances.
-
-
Click Attach to Instance.
Using the OCI CLI
This procedure shows the minimum required parameters for this command. For information
about optional parameters, run the command with the --help
option.
The following option is required to attach a shareable volume. The default value of this
option is false
.
--is-shareable true
-
Gather the information that you need to run the command:
-
Instance OCID (
oci compute instance list
) -
Volume OCID (
oci bv volume list
)
-
-
Run the volume attach command.
Syntax:
oci compute volume-attachment attach --instance-id instance_OCID \ --volume-id volume_OCID --type paravirtualized
Example:
This example attaches a volume that is read-write and not shareable.
$ oci compute volume-attachment attach \ --instance-id ocid1.instance.uniqueID \ --volume-id ocid1.volume.uniqueID \ --type paravirtualized { "data": { "attachment-type": "paravirtualized", "availability-domain": "AD-1", "compartment-id": "ocid1.compartment.uniqueID", "device": null, "display-name": "volumeattachment.uniqueID", "id": "ocid1.volumeattachment.uniqueID", "instance-id": "ocid1.instance.uniqueID", "is-pv-encryption-in-transit-enabled": null, "is-read-only": false, "is-shareable": false, "lifecycle-state": "ATTACHED", "time-created": "2021-06-01T17:24:13+00:00", "volume-id": "ocid1.volume.uniqueID" } }
Attaching a Volume to Multiple Instances
The Block Volume service provides the capability to attach a block volume to multiple compute instances. With this feature, you can share block volumes across instances in read/write or read-only mode. Attaching block volumes as read/write and shareable enables you to deploy and manage cluster-aware solutions.
There are important limitations and considerations for attaching volumes to multiple instances. For more information, refer to the Block Volume Storage Overview chapter in the Oracle Private Cloud Appliance Concepts Guide.
Important:
If you are attaching a volume that was detached, the volume might be associated with a different device name and the instance operating system might not recognize the volume.
Configuring Multiple Instance Volume Attachments with Read/Write Access
The Block Volume service does not provide coordination for concurrent write operations to volumes attached to multiple instances. To prevent data corruption from uncontrolled read/write operations, you must install and configure a cluster aware system or solution such as Oracle Cluster File System version 2 (OCFS2) on top of the shared storage before you can use the volume.
Summary of the required steps:
-
Attach the block volume to an instance as Read/Write and Shareable using the UI, CLI, or API.
See Attaching a Volume.
-
Set up your OCFS2/O2CB cluster nodes.
-
Create your OCFS2 file system and mount point.
Configuring Multiple Instance Volume Attachments with Read-Only Mode
Once you attach a block volume to an instance as read-only, it can only be attached to other instances as read-only. If you want to attach the block volume to an instance as read/write, you need to detach the block volume from all instances and then you can reattach the block volume to instances as read/write.
-
Attach the block volume to an instance as read-only using the UI, CLI, or API.
See Attaching a Volume.
-
Attach the block volume to additional instances as read-only using the UI, CLI, or API.
See Attaching a Volume.
Find Your Volume in the Instance
When a block volume is initially attached to an instance, the instance sees the volume as a
new disk, for example as device /dev/sdb
. This procedure describes how to
list the disk devices in an instance so that you can find the volume.
For UNIX images, if you want to mount these volumes
when an instance boots, you need to add the volume to the /etc/fstab
file.
See Configuring Volumes to Automatically Mount (Linux Instances).
Optionally, you can perform various administrative tasks to configure the storage to suit your storage requirements.
The utilities you use to perform the administrative tasks vary depending on the type of OS in the instance. For additional administrative information, refer to the documentation for the version of the OS that is on the instance. These documentation libraries provide access to helpful information:
-
Oracle Operating Systems Documentation: https://docs.oracle.com/en/operating-systems/index.html
-
Oracle Virtualization Documentation: https://docs.oracle.com/en/virtualization/index.html
Identifying the Boot Volume and the Attached Block Volume Devices in the Instance Using Linux Commands
-
Log on to your instance as described in Connecting to a Compute Instance.
-
List the disk devices.
Important:
On UNIX operating systems, the order in which volumes are attached is non-deterministic, so it can change with each reboot. If you refer to a volume using the device name, such as
/dev/sdb
, and you have more than one non-root volume, there is no guarantee that the volume you intend to mount for a specific device name will be the volume mounted. When configuring the OS to recognize the block volume (for example, adding the volume to the/etc/fstab
file), use the volume's SCSI ID as described in this procedure.sudo ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb
In this example, two devices are listed,
/dev/sda
and/dev/sdb
. -
Use the
fdisk
-l
command to view configuration information about the devices.In this example,
/dev/sda
is the boot volume and/dev/sdb
is the attached block volume.sudo fdisk -l Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 8192 bytes / 8192 bytes Disk label type: dos Disk identifier: 0x000af694 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 61442047 29671424 8e Linux LVM Disk /dev/mapper/ol-root: 27.2 GB, 27229421568 bytes, 53182464 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 8192 bytes / 8192 bytes Disk /dev/mapper/ol-swap: 3145 MB, 3145728000 bytes, 6144000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 8192 bytes / 8192 bytes Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes, 2147483648 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 8192 bytes / 8192 bytes
This example output provides this information about
/dev/sda
and/dev/sdb
:-
The size of
/dev/sda
is 53.7 GB (boot volume). -
/dev/sda
has two partitions:/dev/sda1
and/dev/sda2
. -
The size of
/dev/sdb
is 1099.5 GB (the attached block volume), and does not have any partitions.
-
-
Identify the devices that have file systems and are mounted in the OS.
sudo df -T Filesystem Type 1K-blocks Used Available Use% Mounted on devtmpfs devtmpfs 16318164 0 16318164 0% /dev tmpfs tmpfs 16332596 0 16332596 0% /dev/shm tmpfs tmpfs 16332596 8744 16323852 1% /run tmpfs tmpfs 16332596 0 16332596 0% /sys/fs/cgroup /dev/mapper/ol-root xfs 26578248 2907292 23670956 11% / /dev/sda1 xfs 1038336 292512 745824 29% /boot tmpfs tmpfs 3266520 0 3266520 0% /run/user/0
In this example:
-
/dev/sda1
has an xfs file system and it is mounted on/boot
(the boot volume). -
/dev/sdb
is not listed because this block volume was just attached and hasn't had a file system created and is not mountable yet.
-
-
Find the SCSI ID for the newly attached volume.
sudo ls -l /dev/disk/by-id total 0 lrwxrwxrwx. 1 root root 10 Dec 6 18:26 dm-name-ol-root -> ../../dm-0 lrwxrwxrwx. 1 root root 10 Dec 6 18:26 dm-name-ol-swap -> ../../dm-1 lrwxrwxrwx. 1 root root 10 Dec 6 18:26 dm-uuid-LVM-83pr2aUrW2ZdCbWgsN4ZRFqvsXGGNZ8JO6il7j1YTWpywZeewYCiA6ywDmIeho1G -> ../../dm-0 lrwxrwxrwx. 1 root root 10 Dec 6 18:26 dm-uuid-LVM-83pr2aUrW2ZdCbWgsN4ZRFqvsXGGNZ8JsaUihE3RWozk5u4p5nOwG9sFcj34AU3F -> ../../dm-1 lrwxrwxrwx. 1 root root 10 Dec 6 18:26 lvm-pv-uuid-Dh9ydC-Rj90-chhj-tkwq-ZI0Z-mfop-Wtg5bh -> ../../sda2 lrwxrwxrwx. 1 root root 9 Dec 6 18:26 scsi-3600144f096933b92000061ae9bfc0025 -> ../../sda lrwxrwxrwx. 1 root root 10 Dec 6 18:26 scsi-3600144f096933b92000061ae9bfc0025-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 10 Dec 6 18:26 scsi-3600144f096933b92000061ae9bfc0025-part2 -> ../../sda2 lrwxrwxrwx. 1 root root 9 Dec 8 15:17 scsi-3600144f096933b92000061b1129e0037 -> ../../sdb lrwxrwxrwx. 1 root root 9 Dec 6 18:26 wwn-0x600144f096933b92000061ae9bfc0025 -> ../../sda lrwxrwxrwx. 1 root root 10 Dec 6 18:26 wwn-0x600144f096933b92000061ae9bfc0025-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 10 Dec 6 18:26 wwn-0x600144f096933b92000061ae9bfc0025-part2 -> ../../sda2 lrwxrwxrwx. 1 root root 9 Dec 8 15:17 wwn-0x600144f096933b92000061b1129e0037 -> ../../sdb
In this example, the following line shows the SCSI ID assigned to
sdb
:lrwxrwxrwx. 1 root root 9 Dec 8 15:17 scsi-3600144f096933b92000061b1129e0037 -> ../../sdb
where
scsi-3600144f096933b92000061b1129e0037
is the SCSI ID.The SCSI ID is a persistent device name for
/dev/sdb
and is used when performing administrative operations on the device, such as partitioning, creating a file system, and mounting.For more information about mounting a block volume file system to an instance, see Configuring Volumes to Automatically Mount (Linux Instances).
-
Perform administrative tasks to configure the block volume to suit your storage requirements.
The specific tasks you perform depend on the type of OS that runs the instance and how you want the storage configured. Refer to your OS documentation for details.
Configuring Volumes to Automatically Mount (Linux Instances)
On Linux instances, if you want to automatically mount volumes during an instance
boot, you need add the volumes to the /etc/fstab
file.
Before You Begin
Get the SCSI ID for the block volume you plan to mount. See Find Your Volume in the Instance.
On Linux operating systems, specify the volume SCSI ID in the /etc/fstab
file instead of the device name (for example, /dev/sdb
). This is an
example of a Volume SCSI ID:
/dev/disk/by-id/scsi-3600144f096933b92000061b1129e0037
Adding Volumes to the /etc/fstab
File
-
Prepare the newly attached block volume for mounting.
Use the disk administration utilities included with instance OS to perform tasks such as the following:
-
Partition the volume
-
Create file systems on the volume or partitions
Consult the documentation for your instance OS for details.
This is an example of creating an ext4 file system for a block volume attached to a Linux instance:
mkfs.ext4 /dev/disk/by-id/scsi-3600144f096933b92000061b1129e0037 mke2fs 1.42.9 (28-Dec-2013) /dev/disk/by-id/scsi-3600144f096933b92000061b1129e0037 is entire device, not just one partition! Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=2 blocks, Stripe width=2 blocks 67108864 inodes, 268435456 blocks 13421772 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2415919104 8192 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
-
-
Create a mount point for each file system you plan to mount.
mkdir /mnt/volume1
-
Add the volume to the
/etc/fstab
file.For this example, the following new line is added to the
/etc/fstab
file:/dev/disk/by-id/scsi-3600144f096933b92000061b1129e0037 /mnt/volume1 ext4 _netdev,nofail 0 0
Following are descriptions of these field values:
-
Device: Specified using the SCSI ID:
/dev/disk/by-id/scsi-3600144f096933b92000061b1129e003
-
Mount point: The mount point created in the previous step:
/mnt/volume1
-
Type: The type of file system:
ext4
in this example. -
Options:
-
_netdev
– Configures the mount process to initiate before the volumes are mounted. -
nofail
– If the device does not exist, no errors are reported. This is a good option to use when an instance is used to create a custom image. Future instances created with that image will not include the block volume and might fail to boot without this option.
-
-
Dump: The value
0
means do not use the obsoletedump
utility. -
fsck: The value
0
means do not runfsck
.
-
-
Use the following command to mount the volumes that are in the
/etc/fstab
file:sudo mount -a
-
Verify that the file system is mounted:
mount | grep /mnt /dev/sdb on /mnt/volume1 type ext4 (rw,relatime,seclabel,stripe=2,data=ordered,_netdev)