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/guides/tools-reference/custom-kernels-distros/install-a-custom-distribution/index.md
+60-27Lines changed: 60 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -251,34 +251,67 @@ Next, you need to determine which partition your root file system is installed o
251
251
252
252
Depending upon your distribution, it may use different parameters for your root disk under the "options" section. These can be adjusted as needed. Note that you're using `/dev/sda` instead of the `sda1` root partition that was identified previously.
253
253
254
-
1. Confirm the location of your `grub.cfg` file. Some distributions (notably, CentOS and Fedora) place this file under the `/boot/grub2` directory, while others have it under `/boot/grub`. Your new setup uses Linode's *Grub 2* mode, which looks for a configuration file under `/boot/grub/grub.cfg`. You can confirm if your `grub.cfg` is located in the necessary spot with the `ls` command:
254
+
1. Confirm the location of your `grub.cfg` file. Some distributions (notably, CentOS and Fedora) place this file under the `/boot/grub2` directory, while others have it under `/boot/grub`. Your new setup uses Linode's *Grub 2* mode, which looks for a configuration file under `/boot/grub/grub.cfg`.
255
+
Use the following script to detect the correct path and set up the expected location without creating an unnecessary symlink:
256
+
257
+
```bash
258
+
if [ -f /boot/grub2/grub.cfg ] && [ -f /boot/grub/grub.cfg ]; then
259
+
# Both exist — /boot/grub/grub.cfg is already in the right place
260
+
GRUB_CFG=/boot/grub/grub.cfg
261
+
echo "Using existing /boot/grub/grub.cfg"
262
+
elif [ -f /boot/grub2/grub.cfg ]; then
263
+
# Only grub2 path exists — create the directory and symlink
echo "ERROR: grub.cfg not found in /boot/grub/ or /boot/grub2/"
274
+
echo "Run 'update-grub' or 'grub2-mkconfig' first to generate it."
275
+
exit 1
276
+
fi
277
+
```
278
+
279
+
This script defaults to `/boot/grub2/grub.cfg` when both paths exist on systems like CentOS/Fedora, and only creates the symlink when `/boot/grub2/grub.cfg` exists but `/boot/grub/grub.cfg` does not. This avoids overwriting an existing config with a symlink.
280
+
281
+
1. Open your `grub.cfg` file and replace all instances of the old partition location and UUID with the new intended location. Run the following commands, replacing the UUID value with the one for your current root partition (determined in step 2 of the current section).
282
+
283
+
Change these example lines in `grub.cfg` referencing the old partition:
284
+
285
+
```
286
+
linux /boot/vmlinuz-5.10.0-19-amd64 root=/dev/sda1 ro quiet
linux /vmlinuz root=UUID=59a7ea75-58c8-46cc-8b71-86f07b56f41f ro
294
+
```
295
+
296
+
To these lines pointing to `/dev/sda`):
297
+
298
+
```
299
+
linux /boot/vmlinuz-5.10.0-19-amd64 root=/dev/sda ro quiet
300
+
```
301
+
```
302
+
search --no-floppy --set=root /dev/sda
303
+
```
304
+
```
305
+
set root='hd0'
306
+
linux /vmlinuz root=/dev/sda ro
307
+
```
308
+
309
+
The specific lines in your file vary by distribution and kernel version. The general rule is: replace every occurrence of `/dev/sda1` with `/dev/sda`, and replace every occurrence of the UUID (`59a7ea75-58c8-46cc-8b71-86f07b56f41f` in this example with your actual UUID from step 2) with `/dev/sda`.
255
310
256
-
```command {title="Lish console or Glish command prompt"}
257
-
ls -la /boot/grub/grub.cfg
258
-
```
259
-
260
-
The output should display information for that file, if it exists.
261
-
262
-
``` {title="Lish console or Glish command prompt"}
263
-
-r--r--r-- 1 root root 5235 Dec 28 08:05 /boot/grub/grub.cfg
264
-
```
265
-
266
-
If the Grub config is located under `/boot/grub2` instead, create a symlink to provide the correct configuration to the bootloader:
267
-
268
-
```command {title="Lish console or Glish command prompt"}
269
-
mkdir /boot/grub
270
-
ln -s /boot/grub2/grub.cfg /boot/grub/grub.cfg
271
-
```
272
-
273
-
1. Open your `grub.cfg` file and replace all instances of the old partition location and UUID with the new intended location. Run the following commands, replacing the UUID value with the one for your current root partition (determined in step 2 of the current section). You may also need to make adjustments to the following commands if your root partition is at a location other than `/dev/sda1`:
274
-
275
-
```command {title="Lish console or Glish command prompt"}
276
-
sed -i -e 's$/dev/sda1$/dev/sda$g' /boot/grub/grub.cfg
277
-
sed -i -e 's$--fs-uuid --set=root 59a7ea75-58c8-46cc-8b71-86f07b56f41f$--set=root /dev/sda$g' /boot/grub/grub.cfg
278
-
sed -i -e 's$root=UUID=59a7ea75-58c8-46cc-8b71-86f07b56f41f$root=/dev/sda$g' /boot/grub/grub.cfg
279
-
```
311
+
{{< note >}}
312
+
If your root partition is at a location other than `/dev/sda1`, adjust accordingly.
313
+
{{< /note >}}
280
314
281
-
Keep in mind that if your `grub.cfg` is located under `/boot/grub2`, you should adjust this command to reflect that.
282
315
283
316
### Transfer the System to a New Ext4 Disk
284
317
@@ -346,4 +379,4 @@ You now should have a Linux system that's compatible with the Linode Platform. F
346
379
347
380
## Save the System as a Custom Image
348
381
349
-
If you wish to save a copy of this system to quickly deploy later, you may want to use Linode's Custom Image feature. This lets you create a Compute Instance based on this system without needing to go through this guide again. See [Capture an Image](/docs/products/tools/images/guides/capture-an-image/) for instructions on creating the image.
382
+
If you wish to save a copy of this system to quickly deploy later, you may want to use Linode's Custom Image feature. This lets you create a Compute Instance based on this system without needing to go through this guide again. See [Capture an Image](/docs/products/tools/images/guides/capture-an-image/) for instructions on creating the image.
0 commit comments