TheKoguryo's Tech Blog

 Version 2024.04.01

Warning

This content has been generated by machine translation. The translations are automated and have not undergone human review or validation.

3.6.5 Mount Block Volume

According to the OCI document, if there are two or more volume other than root volume, if the device name is mounted with the device name, the device name and the actual device may be different.As of January 10, 2019, the CONSISTENT Device Path function was released to ensure the response of the device after the server reversion and the actual device.In the unsupported images and instances, the mount ** method is used based on the UUID of ** volume as before.

Mounting with Device Path

  1. You can check the Device Path (/Dev/Oracleoci/OracleVDB) of the Block Volume that was previously Attached in the OCI console.

    image-20220110172551354

  2. Connect the compute instance with ssh and check the device path.

    [opc@examplelinuxinstance ~]$ ls -la /dev/oracleoci/
    total 0
    drwxr-xr-x.  2 root root  140 Jan 10 07:25 .
    drwxr-xr-x. 20 root root 3200 Jan 10 07:25 ..
    lrwxrwxrwx.  1 root root    6 Jan 10 05:41 oraclevda -> ../sda
    lrwxrwxrwx.  1 root root    7 Jan 10 05:41 oraclevda1 -> ../sda1
    lrwxrwxrwx.  1 root root    7 Jan 10 05:41 oraclevda2 -> ../sda2
    lrwxrwxrwx.  1 root root    7 Jan 10 05:41 oraclevda3 -> ../sda3
    lrwxrwxrwx.  1 root root    6 Jan 10 07:35 oraclevdb -> ../sdb
    
  3. Create a directory to mount

    sudo mkdir /mnt/vol1
    
  4. /etc/fstab update

    sudo vi /etc/fstab Add the following contents based on the device path you confirmed by performing the command.

    According to the recommendations of the OCI document, the _netdev,nofail option must be added to reduce the impact of the failure of the mounted volume when the instance is restarted.

    • Use the _netdev and nofail Options

      sudo vi /etc/fstab
      
    • Update example

      Add a line of mount information at the bottom of the existing content.

      #
      # /etc/fstab
      # Created by anaconda on Wed Dec  1 01:55:42 2021
      ...
      
      ## https://docs.us-phoenix-1.oraclecloud.com/Content/Block/Tasks/connectingtoavolume.htm
      /dev/oracleoci/oraclevdb /mnt/vol1 xfs defaults,_netdev,nofail 0 2
      
  5. Mount

    sudo mount -a
    
    • Mount result

      You can see that /dev/sdb is mounted on /mnt/vol1.

      [opc@examplelinuxinstance ~]$ sudo mount -a
      [opc@examplelinuxinstance ~]$ df -h
      Filesystem      Size  Used Avail Use% Mounted on
      devtmpfs        310M     0  310M   0% /dev
      tmpfs           341M     0  341M   0% /dev/shm
      tmpfs           341M  5.1M  336M   2% /run
      tmpfs           341M     0  341M   0% /sys/fs/cgroup
      /dev/sda3        39G  3.1G   36G   8% /
      /dev/sda1       200M  7.5M  193M   4% /boot/efi
      tmpfs            69M     0   69M   0% /run/user/0
      tmpfs            69M     0   69M   0% /run/user/1000
      tmpfs            69M     0   69M   0% /run/user/994
      /dev/sdb         50G   33M   50G   1% /mnt/vol1
      
  6. Restart the instance

    Since it is added to /etc/fstab, it is automatically mounted even when the instance restarts. Check if it mounts without any problems as shown below. Even after restarting, you can see that it is mounted as /mnt/vol1.

    [opc@examplelinuxinstance ~]$ sudo reboot
    Connection to 146.56.171.40 closed by remote host.
    Connection to 146.56.171.40 closed.
    
    ubuntu@NOTEBOOK-WORK:~/.ssh$ ssh -i privateKey opc@146.56.171.xx
    Last login: Mon Jan 10 08:26:13 2022 from 223.62.21.xx
    [opc@examplelinuxinstance ~]$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        310M     0  310M   0% /dev
    tmpfs           341M     0  341M   0% /dev/shm
    tmpfs           341M  5.0M  336M   2% /run
    tmpfs           341M     0  341M   0% /sys/fs/cgroup
    /dev/sda3        39G  3.1G   36G   8% /
    /dev/sda1       200M  7.5M  193M   4% /boot/efi
    /dev/sdb         50G   33M   50G   1% /mnt/vol1
    tmpfs            69M     0   69M   0% /run/user/0
    tmpfs            69M     0   69M   0% /run/user/1000
    

Mount with UUID

According to the OCI document, if there are more than one volume other than the root volume, the order in which the device name and the actual device correspond to each other may be different after the server restarts if the device name is mounted. So to be precise, I mount it based on the UUID of the Volume.

Please refer to the document below for related information.



As an individual, this article was written with my personal time. There may be errors in the content of the article, and the opinions in the article are personal opinions.

Last updated on 10 Jan 2022