# Mount a disk in OCI
The following command mounts a disk in Oracle Cloud Infrastructure (OCI):
https://docs.oracle.com/en-us/iaas/Content/Block/Tasks/connectingtoavolume_topic-Connecting_to_iSCSIAttached_Volumes.htm
## Mounting commands via iscsiadm
The following commands are found in the three dot menu for each volume.
The volume iqn is found in the volume page.
```
$ iscsiadm -m node -o new -T <volume IQN> -p <iSCSI IP address>:<iSCSI port>
New iSCSI node [tcp:[hw=,ip=,net_if=,iscsi_if=default] 169.254.0.2,3260,-1 iqn.2015-12.us.oracle.com:c6acdaXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX] added
$ iscsiadm -m node -T <volume IQN> -o update -n node.startup -v automatic
$ iscsiadm -m node -T <volume's IQN> -p <iSCSI IP Address>:<iSCSI port> -l
Logging in to [iface: default, target: iqn.2015-12.us.oracle.com:c6acdaXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, portal: 169.254.0.2,3260] (multiple)
Login to [iface: default, target: iqn.2015-12.us.oracle.com:c6acdaXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, portal: 169.254.0.2,3260] successful.
```
Note: Some of these commands produce no output.
## Locate the disk with fdisk
Verify the disk exists using **fdisk**.
This will display extended disk information for all disks.
Newer disks will appear near the bottom of the output.
```
$ fdisk -l
...
...
Disk /dev/sdb: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Disk model: BlockVolume
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
...
```
# Prepare the disk
Next, prepare the disk for a file system using **fdisk** or **parted**
## Prepare the disk with parted
Create the partitions using **parted** with the following:
```
sudo parted /dev/sdc mklabel gpt
sudo parted -a optimal /dev/sdc mkpart primary ext4 0% 100%
```
The command above utilizes the entire disk.
## Prepare the disk with fdisk
Create the partition using the **fdisk** command.
The fdisk command is interactive.
The first command will be **n** to create a new parition.
Then, select the defaults options.
Lastly, use **w** to write the changes.
```
# Walk through with fdisk
sudo fdisk /dev/sdc
Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x3fdba443.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-2147483647, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-2147483647, default 2147483647):
Created a new partition 1 of type 'Linux' and of size 1024 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
```
# Format the new filesytem
Now that the disk is partitioned, format the disk.
In this example, we will used **ext4**.
The command takes a few moments as the drive is formatted.
```
sudo mkfs.ext4 /dev/sdc1
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done
Creating filesystem with 268435200 4k blocks and 67108864 inodes
Filesystem UUID: cf468075-167f-4673-8689-8412bf6cc071
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 (262144 blocks): done
Writing superblocks and filesystem accounting information: done
```
# Create a mount point directory and mount the drive
Create a directory that will host the drive.
```
sudo mkdir /mnt/backups
```
Next, mount the drive on the newly created directory
```
sudo mount /dev/sdc1 /mnt/backups
```
# Modify the /etc/fstab file
We need to persist the changes in the fstab file.
## Obtain the disk UUID
First, get the UUID for the disk.
```
$ sudo blkid /dev/sdc1
/dev/sdc1: UUID="cf468075-167f-4673-8689-8412bf6cc071" TYPE="ext4" PARTUUID="3fdba443-01"
```
## Update /etc/fstab
With the UUID in hand, we will update the **/etc/fstab** file.
```
sudo nano /etc/fstab
```
Navigate to the bottom of the file and add the following line with the UUID and the following settings.
```
UUID=your-uuid-here /mnt/backups ext4 defaults,_netdev,nofail,noatime,nodiratime,data=journal 0 2
```
The settings are as follows:
- noatime: Skips updating access timestamps—reduces unnecessary I/O.
- nodiratime: Skips access timestamps on directories (optional, often bundled with noatime).
- data=journal: Writes metadata and file data to the journal. Safer for backups, slightly slower than data=ordered, but ensures recovery in the event of power loss or crashes.
- _netdev: Prevents the disk from mounting until network is available—essential for iSCSI drives.
- nofail: allows the boot process to continue even if the specified filesystem fails to mount.
- defaults: Includes typical options like rw, suid, dev, exec, auto, nouser, and async.
# Mount and Reboot
Lastly, we will mount the new drive and reboot the server
```
$ sudo mount -a
$ sudo reboot
```