06 ‐ Detaching Boot & Block Volume from existing Instance and attaching them to a newly created instance - SanjeevOCI/Ocidocs GitHub Wiki
Steps to Detach and Reattach Boot & Block Volumes to Another Instance
1. Detach the Block Volume from the exiting Instance
Note:- Before detaching the Block volume, Please follow the below steps to ensure that the block volume data can be validated in the new instance
1) Add a test file in the mounted folder /u01
2) Take a count of the files in /u01 folder --> du -sh /u01
- Navigate to Burger Menu --> Compute --> Instances --> Select "computecompartment" in Compartment section --> Select the Instance --> Click on "Attached Block Volumes" to see the Block Volume attached to the existing Instance
- Navigate to the three dots --> iSCSI commands & information and Copy the Disconnect command.
- Login to the Existing Instance through Putty and unmount the Block Volume drive
As per "df -h command", /u01 folder is no longer available. As per "lsblk" command, the Logical Volume is there, but it is not pointing to any folder. It has been unmounted.
- Execute the copied iSCSI DISCONNECT commands in the server
- Remove the volume from the instance's etc/fstab
- Navigate to the three dots in "Attached Block Volumes" --> Detach the Block Volume
- Block Volume is now removed
2. Delete the Compute Instance
-
Navigate to Burger Menu --> Compute --> Instances --> Select "computecompartment" in Compartment section --> Select the Instance --> Click on "Terminate" to delete the existing instance.
-
Deselect "Permanently delete the attached boot volume" --> Click on "terminate Instance"
3. Create the New Compute Instance
- Follow the Compute Instance creation steps to create a new Instance with the mentioned requirements (Example - New Shape) --> https://github.com/SanjeevOCI/Ocidocs/wiki/Creating-a-Compute-Instance
4. Stop the New Compute Instance
5. Replace the Boot Volume in the New Instance
- In the New Instance, Click on Boot Volume --> It will display the Boot Volume of the New Instance --> Click on "Replace Boot Volume"
- Select the Boot Volume of the deleted instance --> Click on "Save" --> The Old Boot Volume will get attached to the New Instance
6. Start the New Compute Instance
7. Attach the Block Volume
- Navigate to Burger Menu --> Storage --> Block Volumes --> Select the Block Volume to be attached --> Select "Attached Instance" option On the left side --> Click on "Attach to Instance" --> Select New Instance Name and click "Attach" --> Block volume is now attached to the Instance
- Click on the newly created Block Volume --> Select "Attached Instance" option On the left side --> Click on "Attach to Instance" --> Select Instance Name and click "Attach" --> Block volume is now attached to the Instance
8. Login to the New Instance through Putty
- Login to the server through putty using opc and make appropriate changes for root login
- Run lsblk command to check the existing volumes in the server.
9. Reflecting the Block Volume in the server
- Navigate to the three dots in "Attached Block Volumes" --> iSCSI commands & information and Copy the connect command.
- Execute the copied commands in the server.
Running the "lsblk" command shows that the Block volume is now preserved.
10. Mount the logical volume on the directory /u01
- Run the below command to mount the logical volume
mount -t ext4 /dev/mapper/vg_u01-lv_u01 /u01
- Run "df -h" command to confirm that the logical volume is mounted.
11. Mount the volume permanently in /etc/fstab
- Add the line below in /etc/fstab & Run the command "mount -a" to mount this volume permanently
/dev/mapper/vg_u01-lv_u01 /u01 ext4 defaults,_netdev,nofail 0 2
Check for the files created in previous instance to confirm all files in block volume have been copied to the new instance.