How to recover a full OS-Disk from a Linux VM

How to recover a full OS-Disk from a Linux VM

These steps are performed the CST member.

Introduction

When the OSDisk of a VM is full you will be unable to connect to the VM. To recover the data on the OS-disk and to make the VM accessible again you will need to swap the OSDisk with a resized copy of itself (or a completely new disk). This article describes how to do this on a linux VM.

Part 1: Making a copy of the affected OS-Disk

  1. Get permission of the accountable of the workspace. Let them invite you to the workspace. Make sure this is mentioned in the respective ticket.
  2. Create a new VM. You will need one to attach the copied OSDisk to.
  3. Create a snapshot of the affected OSDisk
    1. You will find the OSDisk in the resource group, open it and click on +Create Snapshot. The snapshot must be located in the same resource group.

  1. Locate the snapshot and click on +Create Disk.

    1. Fill in the details but make sure to make the Disk minimally one size bigger than the original OSDisk.
    2. BE AWARE: it automatically is set to premium SSD which is quite expensive. Click on Change size and select Standard SSD from the dropdown. You can leave the other parameters on default.
    3. Click on Review + create to create the disk.

Part 2: Resizing the New OS-Disk

  1. Locate your new VM in the Azure Portal and go to Disks.
  2. Select Attach existing disks and select the disk you've created from the snapshot from the dropdown menu under Disk name. Chose Read/Write under Host caching and press Apply

  3. Connect to the new VM to manually resize the filesystem partition 
    1. To do this use 'df -h' and 'sudo fdisk -l' to find out what the disk is called, for example something like '/dev/sda.
      1. (situational) Sometimes the partition that we need (/dev/sda1 in this example) has not been mounted yet. Do this before continuing. 
    1. Use the 'parted <disknamehere>' command with the name you got from 'df -h',
    2. Use 'resizepart' to increase it to the new size.
    3. (situational) Sometimes the filesystem does not automatically resize. Use 'sudo resize2fs <disknamehere>' if this is the case.
  1. After that you can stop the VM and detach the resized disk.

Part 3: Swapping the New OS-Disk with the Old OS-Disk

  1. Locate the affected VM in the Azure Portal and go to Disks.
  2. Select Swap OS disk select the resized disk from the dropdown menu under Disk name. Press Save. 
  3. The affected VM is now available again.
Suggestion: With permission, it is also advisable to delete the snapshot and the old disk as these also will incur costs. Only do this with permission and after confirmation that all data has been retrieved!


    • Related Articles

    • Software on Windows VMs (UMCU)

      This article is only for UMCU workspaces! To work with data on your Windows VM in a DRE workspace, you of course need software. For UMC Utrecht workspaces, there are a few different ways in which software ends up on a Windows VM: Some software comes ...
    • Larger file uploads from bulk storage/HPC with winscp/scp

      When you want to upload files from bulk storage/HPC to your DRE workspace, you might run into the issue that you don't have the DRE portal available. Therefore, you cannot use the usual upload mechanics. Of course, copying large files to another ...
    • How to remove the red crosses in the Software Store

      This article is only for UMCU workspaces! Introduction By default, the icons of applications within the Software Store on the UMCU template will not be visible, instead a red cross will be shown. This is caused by the missing connection to a blob ...