Skip to content

Commit cb1e30d

Browse files
authored
Update serial-console-grub-proactive-configuration.md
Edit review per CI 7097
1 parent 7fffe70 commit cb1e30d

1 file changed

Lines changed: 69 additions & 68 deletions

File tree

support/azure/virtual-machines/linux/serial-console-grub-proactive-configuration.md

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -24,67 +24,67 @@ You can improve the recovery times of your IaaS Linux virtual machine (VM) in mo
2424
You might have to perform a VM recovery for any of the following reasons:
2525

2626
- Corrupted file system, kernel, or MBR (Master Boot Record)
27+
- Corrupted SSHD configurations files
2728
- Failed kernel upgrades
2829
- Incorrect GRUB kernel parameters
2930
- Incorrect fstab configuration
30-
- Firewall configuration
3131
- Lost password
32-
- Mangled sshd configurations files
32+
- Firewall configuration
3333
- Networking configuration
3434

35-
Many other scenarios as detailed [here](./serial-console-linux.md#common-scenarios-for-accessing-the-serial-console).
35+
Many other scenarios are also possible, as detailed in the "Common scenarios for accessing the Serial Console" section of [Azure Serial Console for Linux](./serial-console-linux.md#common-scenarios-for-accessing-the-serial-console). Refer to this article for more help if you're a new user of the Serial Console.
3636

3737
Verify that you can access GRUB and the Serial Console on your VMs that are deployed in Azure.
3838

39-
If you're a new user of the Serial Console, refer to [this article](./serial-console-linux.md).
40-
4139
> [!TIP]
4240
> Back up your files before you make changes.
4341
4442
The following video demonstrates how you can quickly recover your Linux VM after you have access to GRUB.
4543

4644
[Recover Linux VM Video](https://youtu.be/KevOc3d_SG4)
4745

48-
There are several methods to improve recovery of Linux VMs. In a Cloud environment, this process has been challenging. We're continually updating our tooling and program features to improving the recovery time for services.
46+
## Recovery methods
47+
48+
There are several methods to improve recovery of Linux VMs. In a Cloud environment, this process has been challenging. We're continually updating our tooling and program features to improve recovery time for services.
4949

5050
By using the Azure Serial Console, you can interact with your Linux VM as if you were at a system's console. You can manipulate many configuration files and processes, including how the kernel starts up.
5151

52-
The more experienced Linux or Unix sysstem admins will appreciate the **single user** and **emergency** modes that are accessible through the Azure Serial Console. These features make Disk Swap and VM deletion operations redundant for many recovery scenarios.
52+
More experienced Linux or Unix system administrators can appreciate the Single User and Emergency modes that are accessible through the Azure Serial Console. These features make Disk Swap and VM deletion operations redundant for many recovery scenarios.
5353

5454
The method of recovery depends on the problem that you experience. For example, a lost or misplaced password can be reset through Azure portal options by using **Reset Password**. The **Reset Password** feature is known as an *extension*. The feature communicates with the Linux Guest agent.
5555

56-
Other extensions, such as Custom Script, are available. However, these options require that the Linux **waagent** is running and in a healthy state.
56+
Other extensions, such as Custom Script, are available. However, these options require that the Azure Linux VM Agent (waagent) is running and in a healthy state.
5757

5858
:::image type="content" source="media/serial-console-grub-proactive-configuration/agent-status.png" alt-text="Screenshot of the Agent status in the Properties page in Azure portal.":::
5959

6060
If you have access to the Azure Serial Console and GRUB, you can manage a password change or fix an incorrect configuration in minutes instead of hours. In the scenario in which your primary kernel becomes corrupted, you could even force the VM to start from an alternative kernel, if you have multiple kernels on the disk.
6161

62-
:::image type="content" source="media/serial-console-grub-proactive-configuration/more-kernel.png" alt-text="Screenshot of the selected OS startup screen in GRUB showing multiple kernels that can be chosen.":::
62+
:::image type="content" source="media/serial-console-grub-proactive-configuration/more-kernel.png" alt-text="Screenshot of the selected OS startup screen in GRUB showing multiple kernels that you can choose.":::
6363

64-
## Suggested order of recovery methods
64+
### Suggested order of recovery methods
6565

6666
- Azure Serial Console
6767

6868
- [Disk Swap](/azure/virtual-machines/windows/os-disk-swap)
6969

7070
- Legacy Method
7171

72-
## Disk swap video
72+
### Disk swap video
7373

7474
If you don't have access to GRUB, watch [this video](https://youtu.be/m5t0GZ5oGAc) to see how you can easily automate the disk swap procedure to recover your VM.
7575

76-
## Challenges
76+
## Configuration methods and challenges
7777

7878
By default, not all Linux Azure VMs are configured for GRUB access or to be interrupted by the SysRq commands. Some older distros, such as LES 11, aren't configured to display a sign-in prompt in the Azure Serial Console. The following sections review various Linux distributions and discuss configurations that make GRUB available.
7979

80-
## How to configure Linux VM to accept SysRq keys
80+
### How to configure Linux VM to accept SysRq keys
8181

8282
By default, the SysRq key is enabled on some newer Linux distros. On other distros, it might be configured for accepting values only for certain SysRq functions.
8383
On older distros, it might be disabled completely.
8484

85-
The SysRq feature is useful for rebooting a crashed or non-responding VM directly from the Azure Serial Console. It's also helpful to gain access to the GRUB menu. Aalternatively restarting a VM from another portal window or SSH session might drop your current console connection and end GRUB time-outs that used to display the GRUB menu.
85+
The SysRq feature is useful for restarting a non-responding VM directly from the Azure Serial Console. It's also helpful to gain access to the GRUB menu. Aalternatively, restarting a VM from another portal window or SSH session might drop your current console connection and end GRUB timeouts that previously displayed the GRUB menu.
8686

87-
The VM must be configured to accept a value of **1** for the kernel parameter. This setting enables all functions of SysRq or 128, which enables restart and power off processes.
87+
The VM must be configured to accept a value of **1** for the kernel parameter. This setting enables all functions of SysRq or 128 for restart and power off processes.
8888

8989
[Enable SysRq video](https://youtu.be/0doqFRrHz_Mc)
9090

@@ -116,7 +116,7 @@ The system should log a reset message that resembles the message in the followin
116116

117117
:::image type="content" source="media/serial-console-grub-proactive-configuration/retting-log.png" alt-text="Screenshot of the reset message log in the command-line interface.":::
118118

119-
## Ubuntu GRUB configuration
119+
### Ubuntu GRUB configuration
120120

121121
By default, you should be able to access GRUB by holding the **Esc** key during the VM restart. If the GRUB menu doesn't appear, you can force the GRUB menu to appear and stay on screen in the Azure Serial Console by using one of the following options.
122122

@@ -144,7 +144,7 @@ Then, add the following line:
144144
GRUB_TIMEOUT_STYLE=countdown
145145
```
146146

147-
## Ubuntu 12\.04
147+
#### Ubuntu 12\.04
148148

149149
Ubuntu 12.04 allows access to the serial console but doesn't offer the ability to interact. A **login:** prompt isn't displayed.
150150

@@ -172,7 +172,7 @@ For Ubuntu 12.04 to obtain a **login:** prompt, follow these steps:
172172

173173
For the required settings that you need to configure the serial console for Ubuntu versions, see the [SerialConsoleHowto](https://help.ubuntu.com/community/SerialConsoleHowto) Ubuntu documentation.
174174

175-
## Ubuntu Recovery mode
175+
#### Ubuntu Recovery mode
176176

177177
Additional recovery and clean-up options are available for Ubuntu through GRUB. However, these settings are accessible only if you configure kernel parameters accordingly.
178178
If you don't configure the kernel boot parameter, the Recovery menu is automatically sent to the Azure Diagnostics component and not to the Azure Serial Console. To get access to the Ubuntu Recovery menu, follow these steps:
@@ -205,9 +205,9 @@ If all goes well, the Recovery menu now displays additional options that can hel
205205

206206
:::image type="content" source="media/serial-console-grub-proactive-configuration/additional-recovery-options-ubuntu.png" alt-text="Screenshot that shows the Serial console at the Recovery menu that offers additional recovery options.":::
207207

208-
## Red Hat GRUB configuration
208+
### Red Hat GRUB configuration
209209

210-
### Red Hat 7\.4\+ GRUB configuration
210+
#### Red Hat 7\.4\+ GRUB configuration
211211

212212
The default /etc/default/grub configuration on these versions is adequately configured
213213

@@ -222,15 +222,15 @@ GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0 earlyprintk=ttyS0"
222222
GRUB_DISABLE_RECOVERY="true"
223223
```
224224

225-
Enable the SysRq key
225+
Enable the SysRq key:
226226

227227
```console
228228
sysctl -w kernel.sysrq=1;echo kernel.sysrq = 1 >> /etc/sysctl.conf;sysctl -a | grep -i sysrq
229229
```
230230

231-
### Red Hat 7\.2 and 7\.3 GRUB configuration
231+
#### Red Hat 7\.2 and 7\.3 GRUB configuration
232232

233-
The file to modify is /etc/default/grub – a default config looks like this example:
233+
The file to modify is /etc/default/grub. The default configuration resembles the following example:
234234

235235
```console
236236
GRUB_TIMEOUT=1
@@ -242,31 +242,29 @@ GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0 earlyprintk=ttyS0"
242242
GRUB_DISABLE_RECOVERY="true"
243243
```
244244

245-
Change the following lines in /etc/default/grub
245+
1. Locate the following (nonconsecutive) lines in /etc/default/grub:
246246

247247
```console
248248
GRUB_TIMEOUT=1
249249

250-
to
251-
252-
GRUB_TIMEOUT=5
250+
GRUB_TERMINAL_OUTPUT="console"
253251
```
254252

255-
```console
256-
GRUB_TERMINAL_OUTPUT="console"
253+
Change these to the following:
257254

258-
to
255+
```console
256+
GRUB_TIMEOUT=5
259257

260258
GRUB_TERMINAL="serial console"
261259
```
262260

263-
Also add this line:
261+
Also, add this line:
264262

265263
```console
266264
GRUB_SERIAL_COMMAND="serial –speed=115200 –unit=0 –word=8 –parity=no –stop=1″
267265
```
268266

269-
/etc/default/grub should now look similar to this example:
267+
The example /etc/default/grub file should now appear as follows:
270268

271269
```console
272270
GRUB_TIMEOUT=5
@@ -278,24 +276,24 @@ GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0 earlyprintk=ttyS0"
278276
GRUB_DISABLE_RECOVERY="true"
279277
```
280278

281-
Complete and update grub configuration using
279+
1. Complete and update the GRUB configuration by running the following command:
282280

283281
`grub2-mkconfig -o /boot/grub2/grub.cfg`
284282

285-
Set the SysRq kernel parameter:
283+
1. Set the SysRq kernel parameter:
286284

287285
`sysctl -w kernel.sysrq = 1;echo kernel.sysrq = 1 >> /etc/sysctl.conf;sysctl -a | grep -i sysrq`
288286

289287
Alternatively, you can configure GRUB and SysRq by using a single line, either in the shell or through the Run Command. Back up your files before you run this command:
290288

291289
`cp /etc/default/grub /etc/default/grub.bak; sed -i 's/GRUB_TIMEOUT=1/GRUB_TIMEOUT=5/g' /etc/default/grub; sed -i 's/GRUB_TERMINAL_OUTPUT="console"/GRUB_TERMINAL="serial console"/g' /etc/default/grub; echo "GRUB_SERIAL_COMMAND=\"serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1\"" >> /etc/default/grub;grub2-mkconfig -o /boot/grub2/grub.cfg;sysctl -w kernel.sysrq=1;echo kernel.sysrq = 1 /etc/sysctl.conf;sysctl -a | grep -i sysrq`
292290

293-
### Red Hat 6\.x GRUB configuration
291+
#### Red Hat 6\.*x* GRUB configuration
294292

295-
The file to modify is /boot/grub/grub.conf. The `timeout` value will determine how long GRUB is shown for.
293+
The file to modify is /boot/grub/grub.conf. The `timeout` value will determine how long GRUB is dispplayed.
296294

297295
```console
298-
#boot=/dev/vda
296+
#boot=/dev/vda1
299297
default=0
300298
timeout=15
301299
splashimage=(hd0,0)/grub/splash.xpm.gz
@@ -305,53 +303,55 @@ terminal serial
305303
terminal --timeout=5 serial console
306304
```
307305

308-
The last line *terminal –-timeout=5 serial console* will further increase **GRUB** timeout by adding a prompt of 5 seconds displaying **Press any key to continue.**
306+
The last line, *terminal –-timeout=5 serial console*, further increases the **GRUB** timeout value by adding a prompt of five seconds duration that displays the message, **Press any key to continue.**
307+
308+
:::image type="content" source="media/serial-console-grub-proactive-configuration/press-any-key-to-continue.png" alt-text="Screenshot that shows console output.":::
309309

310-
:::image type="content" source="media/serial-console-grub-proactive-configuration/press-any-key-to-continue.png" alt-text="Screenshot shows a console with output.":::
310+
The GRUB menu should appear on-screen for the configured value of **timeout=15** without having to press Esc. Select the console in the browser to make the menu active, and then select the required kernel.
311311

312-
GRUB menu should appear on-screen for the configured timeout=15 without the need to press Esc. Make sure to click in the Console in the Browser to make active the menu and select the required kernel.
312+
:::image type="content" source="media/serial-console-grub-proactive-configuration/select-kernel.png" alt-text="Screenshot that shows a console that contains two Linux options.":::
313313

314-
:::image type="content" source="media/serial-console-grub-proactive-configuration/select-kernel.png" alt-text="Screenshot shows a console with two Linux options.":::
314+
### SuSE GRUB configuration
315315

316-
## SuSE
316+
#### SLES 12 SP1
317317

318-
### SLES 12 sp1
318+
Use either of the following methods:
319319

320-
Either use YaST bootloader as per the official [docs](./serial-console-grub-single-user-mode.md#grub-access-in-suse-sles)
320+
- Use the YaST bootloader per the steps in [Use Serial Console to access GRUB and single-user mode](./serial-console-grub-single-user-mode.md#general-single-user-mode-access).
321321

322-
Or add/change to /etc/default/grub the following parameters:
322+
- Modify the /etc/default/grub file by specifying the following parameters:
323323

324324
```console
325325
GRUB_TERMINAL=serial
326326
GRUB_TIMEOUT=5
327327
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --parity=no"
328+
```
328329

329-
```console
330-
Verify that ttys0 is used in the GRUB_CMDLINE_LINUX or GRUB_CMDLINE_LINUX_DEFAULT
330+
Verify that `ttys0` is used in the GRUB_CMDLINE_LINUX or GRUB_CMDLINE_LINUX_DEFAULT command, as follows:
331331

332332
```console
333333
GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,9600n"
334334
```
335335

336-
Recreate the grub.cfg
336+
Re-create the Grub.cfg file, as follows:
337337

338338
`grub2-mkconfig -o /boot/grub2/grub.cfg`
339339

340-
### SLES 11 SP4
340+
#### SLES 11 SP4
341341

342-
The Serial Console appears and displays boot messages but doesn't display a **login:** prompt
342+
The Serial Console appears and displays startup messages but doesn't display a **login:** prompt. To resolve this problem, follow these steps:
343343

344-
Open an ssh session into the VM and update the file **/etc/inittab** by un-commenting this line:
344+
1. Open an SSH session on the VM, and update the **/etc/inittab** file by uncommenting the following line:
345345

346346
```console
347347
#S0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt102
348348
```
349349

350-
Next run the command
350+
1. Run the following command:
351351

352352
`telinit q`
353353

354-
To enable GRUB, the following changes should be made to /boot/grub/menu.lst
354+
1. To enable GRUB, specify the following parameters in the /boot/grub/menu.lst file:
355355

356356
```console
357357
timeout 5
@@ -363,38 +363,39 @@ kernel /boot/vmlinuz-3.0.101-108.74-default root=/dev/disk/by-uuid/ab6b62bb--
363363
1a8c-45eb-96b1-1fbc535b9265 disk=/dev/sda USE_BY_UUID_DEVICE_NAMES=1 earlyprinttk=ttyS0 console=ttyS0 showopts vga=0x314
364364
```
365365

366-
This configuration will enable the message **Press any key to continue** to appear on the console for 5 seconds
366+
This configuration triggers a prompt of five seconds duration on the console that displays the message, **Press any key to continue.**
367+
368+
It then displays the GRUB menu for an additional five seconds. Press the down arrow to interrupt the counter, and then select a kernel that you want to start. You can make either of the following changes:
367369

368-
It will then display the GRUB menu for an additional 5 seconds - by pressing the down arrow you will interrupt the counter and select a kernel you want to boot either append the keyword **single** for single user mode that requires root password to be set.
370+
- Append the command **init=/bin/bash** to load the kernel and also make sure that the init program is replaced by a bash shell. In this manner, you gain access to a shell without having to enter a password. You can then update the password for Linux accounts or make other configuration changes.
369371

370-
Appending the command **init=/bin/bash** will load the kernel but ensures that the init program is replaced by a bash shell.
372+
- Append the keyword **single** to force Single User mode. This mode requires that you set a root password.
371373

372-
You will gain access to a shell without having to enter a password. You can then proceed to update password for Linux accounts or make other configuration changes.
374+
#### Force the kernel to a bash prompt
373375

374-
## Force the kernel to a bash prompt
376+
Having access to GRUB allows you to interrupt the initialization process. This interaction is useful for many recovery procedures. If you don't have a root password (as required by Single User mode), you can start the kernel by replacing the init program with a bash prompt.
375377

376-
Having access to GRUB allows you to interrupt the initialization process this interaction is useful for many recovery procedures.
377-
If you don't have root password and single user requires you to have a root password, you can boot the kernel replacing the init program with a bash prompt – this interrupt can be achieved by appending init=/bin/bash to the kernel boot line
378+
1. To trigger the interruption, append `init=/bin/bash` to the kernel boot line.
378379

379-
:::image type="content" source="media/serial-console-grub-proactive-configuration/bash-kernel-boot.png" alt-text="Screenshot shows a console with the updated boot line.":::
380+
:::image type="content" source="media/serial-console-grub-proactive-configuration/bash-kernel-boot.png" alt-text="Screenshot that shows a console that contains the updated boot line.":::
380381

381-
Remount your / (root) file system RW using the command
382+
1. Remount your / (root) file system RW by running the following command:
382383

383384
`mount -o remount,rw /`
384385

385-
:::image type="content" source="media/serial-console-grub-proactive-configuration/bash-remount.png" alt-text="Screenshot shows a console with a re-mount action.":::
386+
:::image type="content" source="media/serial-console-grub-proactive-configuration/bash-remount.png" alt-text="Screenshot that shows a console that contains a remount action.":::
386387

387-
Now you can perform a root password change or other Linux configuration change.
388+
1. Perform a root password change or other Linux configuration change.
388389

389-
:::image type="content" source="media/serial-console-grub-proactive-configuration/bash-change-password.png" alt-text="Screenshot shows a console where you can change root password and other configuration.":::
390+
:::image type="content" source="media/serial-console-grub-proactive-configuration/bash-change-password.png" alt-text="Screenshot that shows a console in which you can change the root password or make other configurations.":::
390391

391-
Restart the VM by running the following command:
392+
1. Restart the VM by running the following command:
392393

393394
`/sbin/reboot -f`
394395

395-
## Single User mode
396+
#### Force Single User mode
396397

397-
Alternatively, you might have to access the VM in Single User or Emergency mode. Select the kernel that you want to start or interrupt by using the arrow keys. Enter the desired mode by appending the keyword **single** or **1** to the kernel boot line. On RHEL systems, you can also append **rd.break**.
398+
You might have to access the VM in Single User or Emergency mode. Select the kernel that you want to start or interrupt by using the arrow keys. Enter the desired mode by appending the keyword **single** or **1** to the kernel boot line. On RHEL systems, you can also append **rd.break**.
398399

399400
For more information about how to access Single User mode, see [Use Serial Console to access GRUB and single-user mode](./serial-console-grub-single-user-mode.md#general-single-user-mode-access)
400401

0 commit comments

Comments
 (0)