Compartilhar via


Case Scenario : "no such partition" error while trying to start the VM after attempting to extend the OS drive

This particular scenario is from my recent experience working with a customer facing the error "no such partition" when he tried to boot his Red Hat 7.2 machine on Azure. The issue began after customer attempted to extend his OS drive which was running out of space.

 

The VM was showing up as Running from the Portal, however there was a boot issue with the Operating system.

This error could be seen under Virtual Machine > Boot Diagnostics > Screenshot in the portal

 

untitled1

 

In such cases, we have to look into the OS vhd by attaching it to a working VM.

 

We exported the VM properties using the command below, since it was Classic VM

Export-AzureVm -Name VMName -ServiceName CloudServiceName -Path "E:\Cs logs\redhat1.xml"

We attached the OS disk to working VM of the same linux flavor and version.

 

Note :- We strongly recommend taking a backup copy of the OS vhd prior to making any changes to it.

 

When we ran fdisk on the attached data drive, we found that there was no boot partition present.

Ideally we should see a device /dev/sdc1 with the Boot flag '*' marked in the output below

 

untitled2

 

Now, it is important to understand the steps that the administrator performed on the boot partition, prior to running into this issue.

Since, in this scenario, customer was trying to extend the OS drive using the steps below, I suspected he had accidentally deleted the boot partition and missed recreating it.

https://blogs.msdn.microsoft.com/cloud_solution_architect/2016/05/24/step-by-step-how-to-resize-a-linux-vm-os-disk-in-azure-arm/

We recreated the boot partition by running the command fdisk /dev/sdc

 

Command 'n' for new partition.

Note that, since sdc2 begins from sector 1026048, sdc1 has to end at 1026047

 

untitled3

 

Used command 'a' to toggle the boot flag.

Used command 'p' to list the partition table and verify that the settings are correct and 'w' to commit the writes.

 

untitled4

 

untitled5

 

Note :- In Linux, the partitions can be deleted and recreated, as long as the actual data at the File System level is not disturbed.

However, while doing so, make sure the sector numbers match exactly with the original partitions.

 

Here, the admin had not made any changes at all to the file system, hence simply the recreation of boot partition was needed.

Since the boot partition had now been recreated, we were able to recreate the VM using the xml file saved earlier and it booted up fine, and we were successfully able to SSH to the machine.

 

-Shweta Nayak