
rdev Command in Linux
rdev is a command used in Linux to query or set the root device in the kernel image. Essentially, it allows you to specify which device should be used as the root file system when the system boots. This command is pretty useful for custom or embedded Linux systems where you might need to change the root device without recompiling the kernel.
Table of Contents
Here is a comprehensive guide to the options available with the rdev command â
Syntax of rdev Command
To run the command rdev in Linux, use the following basic syntax −
rdev [options] [image [device]]
Where −
- [options] are optional parameters that modify the command's behavior.
- [image] is the kernel image file you want to query or set the root device for.
- [device] is the new root device to set, if desired.
rdev Command Options
Here are some various options you can apply with the Linux rdev command −
Option | Description |
---|---|
-r | Causes rdev to act like ramsize. |
-R | Causes rdev to act like rootflags. |
-v | Causes rdev to act like vidmode. |
-h | Displays the help information for the command. |
Examples of rdev Command in Linux
Below are a few examples demonstrating how to use the rdev command in different scenarios on a Linux environment −
- Setting Root Device
- Querying Root Device
- Acting Like Ramsize
- Acting Like Rootflags
Setting Root Device
Let's say you want to set the root device for a specific kernel image located at /boot/vmlinuz-4.15.0-66-generic to /dev/sda1. You can achieve this by running the following command −
rdev /boot/vmlinuz-4.15.0-66-generic /dev/sda1
This command updates the root device of the specified kernel to /dev/sda1, ensuring that this device will be used as the root file system upon boot.
Querying Root Device
If you're curious about the current root device setting for a kernel image, you can query it with the following command −
rdev /boot/vmlinuz-4.15.0-66-generic
Executing this command will display the current root device associated with the vmlinuz-4.15.0-66-generic kernel, allowing you to verify its configuration.
Acting Like Ramsize
If you need rdev to behave like the ramsize command, you can use the -r option as follows −
rdev -r /boot/vmlinuz-4.15.0-66-generic
Although this option is not relevant for 2.0.x and newer kernels, it allows rdev to mimic the functionality of ramsize for older kernel versions.
Acting Like Rootflags
To have rdev function like the rootflags command, you can use the -R option −
rdev -R /boot/vmlinuz-4.15.0-66-generic
This option modifies rdev to set or query the rootflags for the specified kernel image, which can be useful for certain boot configurations.
Conclusion
The rdev command is a versatile tool for managing root device settings in custom or embedded Linux systems. By understanding the syntax, available options, and practical examples, you can effectively use rdev to control the root file system configuration of your kernel images.
In this tutorial, we provided you with the necessary information to utilize rdev efficiently and ensure your system boots correctly with the desired root device.