LAB 22 ‐ Detach Block Volume - DevWithNehaCloud/Oracle-Cloud-Infrastructure-wiki GitHub Wiki
Detach Block Volume from Instance
Before detaching a block volume from an instance, it is important to safely unmount the file system from the operating system level. Unmounting ensures that all pending read/write operations are completed and prevents data corruption or file system issues. In this process, the volume was first unmounted from the Linux instance using PuTTY commands. After confirming that the volume was no longer in use, the block volume was detached from the OCI Console. This approach helps maintain data integrity and ensures the block volume can be safely reattached to another instance if required.
Steps to Detach Block Volume
Before detaching the Block volume, Please use the steps below to confirm the block volume data on the new instance.
Step 1: Run commands in puTTY to confirm the block volume data on the new instance.
- Add a test file in the mounted folder /u01
- Display the total size of the current directory
Run below commands before unmounting block volume
lsblk
df -h
Now unmount block volume that is currently mounted at the /u01 directory
umount /u01
Again, run the commands to check volume is unmounted or not?
df -h
Since the mounted folder is not visible, but the volume is still present, we will execute the iSCSI detach command in PuTTY.
Open that particular attached BV in OCI Go to three dots,
Select iSCSI commands & information and copy the detach commands and run in putty.
sudo iscsiadm -m node -T iqn.2015-12.com.oracleiaas:aab162f9-6a2a-480a-877c-ad8fd94c5a10 -p 169.254.2.2:3260 -u
sudo iscsiadm -m node -o delete -T iqn.2015-12.com.oracleiaas:aab162f9-6a2a-480a-877c-ad8fd94c5a10 -p 169.254.2.2:3260
And again run lsblk command to check
lsblk
So, now the block volume is not showing.
Before detaching the volume in OCI, we'll remove the last line from the fstab file that was added during mounting by pressing esc i and then save by pressing esc:wq.
vi /etc/fstab
you can check that the last line is removed now by using command
cat /etc/fstab
Step 2: Now detach BV using console
Now, we will detach block volume in OCI
Now we can see, block volume has been detached.