LAB 20 ‐ Detach Block Volume - gautam-amitesh/OCI GitHub Wiki

Earlier we attached a block volume to an instance first by using the OCI console then we got iSCI attach commands (updated as Connect) which we used in PuTTY terminal. Now we want to detach this block volume from this instance. First, we need to ensure that no any applications are using the volume. Second, we unmount the filesystem using umount command. Third, we remove or comment out any references to this specific volume in our /etc/fstab file using vi in the PuTTY terminal. Fourth, we run the iSCSI detach commands (updated as Disconnect) that we obtained earlier when attaching it via the OCI console. Finally, we detach the volume using the OCI console.


  1. After ensuring that no any applications are using the volume, unmount the volume but before that we want a reference from where we can compare the current state after performing any operation (eg. unmount) so we run lsblk and df -h

    lsblk
    
    df -h
    
    sudo umount /u01
    
    lsblk
    
    df -h
    
  2. Now we will either comment out the line or delete the line which refernces this volume in /etc/fstab file

    sudo vi /etc/fstab
    
    • comment out the line

      add # before the line
      
    • remove the line

  3. Now we run iSCSI Disconnect command which will show a successful message

    sudo iscsiadm -m node -T iqn.2015-12.com.oracleiaas:d0e3a79c-4036-4db5-8df5-ea1981e21e46 -p 169.254.2.2:3260 -u
    sudo iscsiadm -m node -o delete -T iqn.2015-12.com.oracleiaas:d0e3a79c-4036-4db5-8df5-ea1981e21e46 -p 169.254.2.2:3260
    
  4. Now we will verify if the volume is detached

    lsblk
    
  5. In OCI console navigate to storage details page of the instance and click the actions menu in the Attached block volumes section and click Detach volume

    Navigation menu > Compute > Instances > the instance (bastion-server1) > Storage > Actions > Detach