How to Preserve an Orphaned DIsk Before It Is Deleted
search cancel

How to Preserve an Orphaned DIsk Before It Is Deleted

book

Article ID: 381638

calendar_today

Updated On:

Products

VMware Tanzu Application Service

Issue/Introduction

Orphaning a disk rather than deleting it preserves the disk for possible recovery. In circumstances after performing recovery operations, you can reattach the disk to a VM. By default, Bosh will delete the disk automatically after 5 days. If you don't want the orphaned disk to be deleted by Bosh, you can preserve the disk.

Resolution

TO PRESERVE AN ORPHANED DISK:

  • Create a small database deployment. In our example, the plan name for that small deployment is "db-small", and we name the instance "new-parent":
    • cf create-service p.mysql db-small new-parent
  • Stop the new-parent instance:
    • bosh -d service-instance_$(cf service new-parent --guid)  stop
  • Shell onto that VM, sudo as root, and disable mysql config to guard against mysql restart:
    • bosh -d service-instance_$(cf service new-parent --guid) ssh
      sudo -i
      cd /var/vcap/jobs/mysql/config
      mv my.cnf DISABLED_my.cnf
      mv mylogin.cnf DISABLED_mylogin.cnf
      exit
  • Get the instance ID of new-parent's VM (to use in the next step):
    • bosh -d service-instance_$(cf service new-parent --guid) instances --details  # get INSTANCE-ID e.g. mysql/e62c10f7-e1f1-4065-88dc-a8e0b7c0794d
  • List our orphaned disk, and attach it to our new parent instance: (Note, this will also create a new orphan out of new-parent's current disk)
    • bosh disks -o  # get ORPHAN-CID

      bosh -d service-instance_$(cf service new-parent --guid)  attach-disk INSTANCE-ID ORPHAN-CID