6. Detach Boot & Block Volume and attach to another instance - Ayushi-srivastav/OCI GitHub Wiki

Step 1 : Detach Block Volume

Before detaching the Block volume, Please use the steps below to confirm the block volume data on the new instance.

  1. Add a test file in the mounted folder /u01

  2. Display the total size of the current directory in a human-readable format

du -sh /u01

image

Run below commands before unmounting block volume

lsblk
df -h

image

image

Now unmount block volume which is currently mounted at the /u01 directory

umount /u01

image

Again run below commands to check volume unmounted or not?

lsblk
df -h

image

image

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 disconnect command.

image

image

Run the iSCSI detach command in putty

image

and again run lsblk command to check

image

so, now 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.

image

image

Save & exit

:wq!

image

Finally we will detach block volume in OCI

image

Before proceeding, ensure all the steps listed below are completed.

and click on detach volume .

image

image

so, Block volume is detached now.

image

Step 2 : Detach Boot Volume

(a) Terminate the existing instance

  • without selecting option of delete the attached boot volume

image

Step 3 : Create New Instance

image

image

Step 4 : Replace Boot Volume

"Now, we will swap the new instance's boot volume with the one we want to use."

so, for this first we need to stop the instance

image

image

Once the instance is stopped, we'll click on the Replace Boot Volume option and choose the boot volume from the specific compartment we want to swap with.

image

image

so Now, we successfully replaced boot volume.

image

But before starting the instance Reboot the instance and than click on start option

and after that just login to putty with OPC user and set the password login.

image

Step 5 : Attach existing Block Volume to a new instance

(1) Browse the Block Volume Click on the Burger Menu in left side, select storage than go to the Block volumes

(2) Click on Block Volume which we want to attach to new instance

Scroll down on the created block volume page. On the right side, you'll see an option for attached instances.

Click on that, then click on Attach to Instance

(3) Select Attachment type &

access type

(4) Select the instance within the specific compartment

where you want to attach the block volume

Than, click on the attach

(5) To attach volume, open that particular attached BV in OCI Go to three dots

select iSCSI commands & information

(6) Copy the connect command

(7) Run these commands in the server

After this

(8) Run lsblk command to check whether volume is showing or not

we can check , volume is showing but not mounted to any folder

(9) for mounting the volume

Create a Directory and mount the logical volume “mkdir /u01”

and mount ext4 file system

“mount –t ext4 /dev/mapper/vg_u01-lv_u01 /u01

mkdir /u01
mount -t ext4 /dev/mapper/vg_u01-lv_u01 /u01

image

image

image

Now we can see the logical volume is mounted.

Mount this volume permanently in /etc/fstab or else after server reboot this volume will be removed.

image

add in last line of fstab file “/dev/mapper/vg_u01-lv_u01 /u01 ext4 defaults,_netdev,nofail 0 2”

image

run mount –a command

image

in last, reboot the server and again run df -h and check

image