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: docs/books/admin_guide/10-boot.md
+63-25Lines changed: 63 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,45 +101,81 @@ Why protect the bootloader with a password?
101
101
102
102
To password protect the GRUB2 bootloader:
103
103
104
-
* Remove `-unrestricted` from the main `CLASS=` statement in the `/etc/grub.d/10_linux` file.
104
+
1. Log in to the operating system as root user and execute the `grub2-mkpasswd-pbkdf2` command. The output of this command is as follows:
105
105
106
-
* If a user has not yet been configured, use the `grub2-setpassword` command to provide a password for the root user:
106
+
```bash
107
+
Enter password:
108
+
Reenter password:
109
+
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.D0182EDB28164C19454FA94421D1ECD6309F076F1135A2E5BFE91A5088BD9EC87687FE14794BE7194F67EA39A8565E868A41C639572F6156900C81C08C1E8413.40F6981C22F1F81B32E45EC915F2AB6E2635D9A62C0BA67105A9B900D9F365860E84F1B92B2EF3AA0F83CECC68E13BA9F4174922877910F026DED961F6592BB7
110
+
```
107
111
108
-
```bash
109
-
# grub2-setpassword
110
-
```
112
+
You need to enter your password in the interaction. The ciphertext of the password is the long string "grub.pbkdf2.sha512...".
111
113
112
-
A `/boot/grub2/user.cfg` file will be created if it was not already present. It contains the hashed password of the GRUB2.
114
+
2. Paste the password ciphertext in the last line of the **/etc/grub.d/00_header** file. The pasted format is as follows:
113
115
114
-
!!! Note
116
+
```
117
+
cat <<EOF
118
+
set superusers='frank'
119
+
password_obkdf2 frank grub.pbkdf2.sha512.10000.D0182EDB28164C19454FA94421D1ECD6309F076F1135A2E5BFE91A5088BD9EC87687FE14794BE7194F67EA39A8565E868A41C639572F6156900C81C08C1E8413.40F6981C22F1F81B32E45EC915F2AB6E2635D9A62C0BA67105A9B900D9F365860E84F1B92B2EF3AA0F83CECC68E13BA9F4174922877910F026DED961F6592BB7
120
+
EOF
121
+
```
115
122
116
-
This command only supports configurations with a single root user.
123
+
The 'frank' user can be replaced with any custom user.
You can also set a plaintext password, for example:
126
+
127
+
```
128
+
cat <<EOF
129
+
set superusers='frank'
130
+
password frank rockylinux8.x
131
+
EOF
132
+
```
133
+
134
+
3. The final step is to execute the command`grub2-mkconfig -o /boot/grub2/grub.cfg` to update the settings of GRUB2.
135
+
136
+
4. Restart the operating system to verify the encryption of GRUB2. Select the first boot menu item and type the ++"e"++ key, and then enter the corresponding user and password.
137
+
138
+
```
139
+
Enter username:
140
+
frank
141
+
Enter password:
142
+
143
+
```
122
144
123
-
* Recreate the configuration file with the `grub2-mkconfig` command:
145
+
After successful verification, enter ++ctrl+"x"++ to start the operating system.
146
+
147
+
Sometimes you may see in some documents that the `grub2-set-password` (`grub2-setpassword`) command is used to protect the GRUB2 bootloader:
After executing the `grub2-set-password` command, the **/boot/grub2/user.cfg** file will be automatically generated.
136
170
137
-
All entries defined in the GRUB menu will now require a user and password to be entered at each boot. The system will not boot a kernel without direct user intervention from the console.
171
+
Select the first boot menu item and type the ++"e"++ key, and then enter the corresponding user and password:
138
172
139
-
* When the user is requested, enter `root`;
140
-
* When a password is requested, enter the password provided at the `grub2-setpassword` command.
173
+
```
174
+
Enter username:
175
+
root
176
+
Enter password:
141
177
142
-
To protect only the editing of GRUB menu entries and access to the console, the execution of the `grub2-setpassword` command is sufficient. There may be cases where you have good reasons for doing only that. This might be particularly true in a remote data center where entering a password each time a server is rebooted is either difficult or impossible to do.
178
+
```
143
179
144
180
## Systemd
145
181
@@ -180,6 +216,8 @@ Systemd introduces the concept of unit files, also known as systemd units.
180
216
181
217
All service unit operations are subject to a default timeout of 5 minutes to prevent a malfunctioning service from freezing the system.
182
218
219
+
Due to space limitations, this document will not provide a very detailed introduction to Systemd. If you are interested in Systemd, we have provided a very detailed introduction in [this document](./16-about-sytemd.md),
220
+
183
221
### Managing system services
184
222
185
223
Service units end with the `.service` file extension and have a similar purpose to init scripts. The `systemctl`command is used to `display`, `start`, `stop`, `restart` a system service:
0 commit comments