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.
-
Add a test file in the mounted folder /u01
-
Display the total size of the current directory in a human-readable format
du -sh /u01
Run below commands before unmounting block volume
lsblk
df -h
Now unmount block volume which is currently mounted at the /u01 directory
umount /u01
Again run below commands to check volume unmounted or not?
lsblk
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 disconnect command.
Run the iSCSI detach command in putty
and again run lsblk command to check
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.
Save & exit
:wq!
Finally we will detach block volume in OCI
Before proceeding, ensure all the steps listed below are completed.
and click on detach volume .
so, Block volume is detached now.
Step 2 : Detach Boot Volume
(a) Terminate the existing instance
- without selecting option of delete the attached boot volume
Step 3 : Create New Instance
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
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.
so Now, we successfully replaced boot volume.
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.
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
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.
add in last line of fstab file “/dev/mapper/vg_u01-lv_u01 /u01 ext4 defaults,_netdev,nofail 0 2”
run mount –a command
in last, reboot the server and again run df -h and check