You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/virtual-machines/troubleshooting/troubleshoot-recovery-disks-portal-linux.md
+69-61
Original file line number
Diff line number
Diff line change
@@ -24,13 +24,16 @@ If your Linux virtual machine (VM) encounters a boot or disk error, you may need
24
24
## Recovery process overview
25
25
The troubleshooting process is as follows:
26
26
27
-
1. Delete the VM encountering issues, keeping the virtual hard disks.
28
-
2. Attach and mount the virtual hard disk to another Linux VM for troubleshooting purposes.
29
-
3. Connect to the troubleshooting VM. Edit files or run any tools to fix issues on the original virtual hard disk.
30
-
4. Unmount and detach the virtual hard disk from the troubleshooting VM.
31
-
5. Create a VM using the original virtual hard disk.
27
+
1. Stop the affected VM.
28
+
1. Create a snapshot for the OS disk of the VM.
29
+
1. Create a virtual hard disk from the snapshot.
30
+
1. Attach and mount the virtual hard disk to another Windows VM for troubleshooting purposes.
31
+
1. Connect to the troubleshooting VM. Edit files or run any tools to fix issues on the original virtual hard disk.
32
+
1. Unmount and detach the virtual hard disk from the troubleshooting VM.
33
+
1. Swap the OS disk for the VM.
32
34
33
-
For the VM that uses managed disk, see [Troubleshoot a Managed Disk VM by attaching a new OS disk](#troubleshoot-a-managed-disk-vm-by-attaching-a-new-os-disk).
35
+
> [!NOTE]
36
+
> This article does not apply to the VM with unmanaged disk.
34
37
35
38
## Determine boot issues
36
39
Examine the boot diagnostics and VM screenshot to determine why your VM is not able to boot correctly. A common example would be an invalid entry in `/etc/fstab`, or an underlying virtual hard disk being deleted or moved.
@@ -41,58 +44,62 @@ Select your VM in the portal and then scroll down to the **Support + Troubleshoo
41
44
42
45
You can also click **Screenshot** across the top of the boot diagnostics log to download a capture of the VM screenshot.
43
46
47
+
## Take a snapshot of the OS Disk
48
+
A snapshot is a full, read-only copy of a virtual hard drive (VHD). We recommend that you cleanly shut down the VM before taking a snapshot, to clear out any processes that are in progress. To take a snapshot of an OS disk, follow these steps:
49
+
50
+
1. Go to [Azure portal](https://portal.azure.com). Select **Virtual machines** from the sidebar, and then select the VM that has problem.
51
+
1. On the left pane, select **Disks**, and then select the name of the OS disk.
52
+

53
+
1. On the **Overview** page of the OS disk, and then select **Create snapshot**.
54
+
1. Create a snapshot in the same location as the OS disk.
55
+
56
+
## Create a disk from the snapshot
57
+
To create a disk from the snapshot, follow these steps:
58
+
59
+
1. Select **Cloud Shell** from the Azure portal.
60
+
61
+

62
+
1. Run the following PowerShell commands to create a managed disk from the snapshot. You should replace these sample names with the appropriate names.
63
+
64
+
```powershell
65
+
#Provide the name of your resource group
66
+
$resourceGroupName ='myResourceGroup'
67
+
68
+
#Provide the name of the snapshot that will be used to create Managed Disks
69
+
$snapshotName = 'mySnapshot'
70
+
71
+
#Provide the name of theManaged Disk
72
+
$diskName = 'newOSDisk'
73
+
74
+
#Provide the size of the disks in GB. It should be greater than the VHD file size. In this sample, the size of the snapshot is 127 GB. So we set the disk size to 128 GB.
75
+
$diskSize = '128'
76
+
77
+
#Provide the storage type for Managed Disk. PremiumLRS or StandardLRS.
78
+
$storageType = 'StandardLRS'
79
+
80
+
#Provide the Azure region (e.g. westus) where Managed Disks will be located.
81
+
#This location should be same as the snapshot location
Typically you have a container named **vhds** that stores your virtual hard disks. Select the container to view a list of virtual hard disks. Note the name of your VHD (the prefix is usually the name of your VM):
53
-
54
-

55
-
56
-
Select your existing virtual hard disk from the list and copy the URL for use in the following steps:
57
-
58
-

59
-
60
-
61
-
## Delete existing VM
62
-
Virtual hard disks and VMs are two distinct resources in Azure. A virtual hard disk is where the operating system itself, applications, and configurations are stored. The VM itself is just metadata that defines the size or location, and references resources such as a virtual hard disk or virtual network interface card (NIC). Each virtual hard disk has a lease assigned when attached to a VM. Although data disks can be attached and detached even while the VM is running, the OS disk cannot be detached unless the VM resource is deleted. The lease continues to associate the OS disk with a VM even when that VM is in a stopped and deallocated state.
63
-
64
-
The first step to recover your VM is to delete the VM resource itself. Deleting the VM leaves the virtual hard disks in your storage account. After the VM is deleted, you attach the virtual hard disk to another VM to troubleshoot and resolve the errors.
65
-
66
-
Select your VM in the portal, then click **Delete**:
Wait until the VM has finished deleting before you attach the virtual hard disk to another VM. The lease on the virtual hard disk that associates it with the VM needs to be released before you can attach the virtual hard disk to another VM.
71
-
72
-
73
-
## Attach existing virtual hard disk to another VM
74
-
For the next few steps, you use another VM for troubleshooting purposes. You attach the existing virtual hard disk to this troubleshooting VM to be able to browse and edit the disk's content. This process allows you to correct any configuration errors or review additional application or system log files, for example. Choose or create another VM to use for troubleshooting purposes.
75
-
76
-
1. Select your resource group from the portal, then select your troubleshooting VM. Select **Disks** and then click **Attach existing**:
77
-
78
-

79
-
80
-
2. To select your existing virtual hard disk, click **VHD File**:
81
-
82
-

83
-
84
-
3. Select your storage account and container, then click your existing VHD. Click the **Select** button to confirm your choice:
85
-
86
-

87
-
88
-
4. With your VHD now selected, click **OK** to attach the existing virtual hard disk:
89
-
90
-

94
+
## Attach disk to another VM
95
+
For the next few steps, you use another VM for troubleshooting purposes. After you attach the disk to the troubleshooting VM, you can browse and edit the disk's content. This process allows you to correct any configuration errors or review additional application or system log files. To attach the disk to another VM, follow these steps:
91
96
92
-
5. After a few seconds, the **Disks** pane for your VM lists your existing virtual hard disk connected as a data disk:
97
+
1. Select your resource group from the portal, then select your troubleshooting VM. Select **Disks**, select **Edit**, and then click **Add data disk**:
93
98
94
-

99
+

95
100
101
+
2. In the **Data disks** list, select the OS disk of the VM that you identified. If you do not see the OS disk, make sure that troubleshooting VM and the OS disk is in the same region (location).
102
+
3. Select **Save** to apply the changes.
96
103
97
104
## Mount the attached data disk
98
105
@@ -152,19 +159,20 @@ Once your errors are resolved, detach the existing virtual hard disk from your t
152
159
153
160
2. Now detach the virtual hard disk from the VM. Select your VM in the portal and click **Disks**. Select your existing virtual hard disk and then click **Detach**:
154
161
155
-

162
+

156
163
157
164
Wait until the VM has successfully detached the data disk before continuing.
158
165
159
-
## Create VM from original hard disk
160
-
To create a VM from your original virtual hard disk, use [this Azure Resource Manager template](https://github.com/Azure/azure-quickstart-templates/tree/master/201-vm-specialized-vhd-existing-vnet). The template deploys a VM into an existing virtual network, using the VHD URL from the earlier command. Click the **Deploy to Azure** button as follows:
161
-
162
-

166
+
## Swap the OS disk for the VM
163
167
164
-
The template is loaded into the Azure portal for deployment. Enter the names for your new VM and existing Azure resources, and paste the URL to your existing virtual hard disk. To begin the deployment, click **Purchase**:
168
+
Azure portal now supports change the OS disk of the VM. To do this, follow these steps:
165
169
166
-

170
+
1. Go to [Azure portal](https://portal.azure.com). Select **Virtual machines** from the sidebar, and then select the VM that has problem.
171
+
1. On the left pane, select **Disks**, and then select **Swap OS disk**.
172
+

167
173
174
+
1. Choose the new disk that you repaired, and then type the name of the VM to confirm the change. If you do not see the disk in the list, wait 10 ~ 15 minutes after you detach the disk from the troubleshooting VM. Also make sure that the disk is in the same location as the VM.
175
+
1. Select OK.
168
176
169
177
## Re-enable boot diagnostics
170
178
When you create your VM from the existing virtual hard disk, boot diagnostics may not automatically be enabled. To check the status of boot diagnostics and turn on if needed, select your VM in the portal. Under **Monitoring**, click **Diagnostics settings**. Ensure the status is **On**, and the check mark next to **Boot diagnostics** is selected. If you make any changes, click **Save**:
0 commit comments