How to use the command 'addpart' (with examples)
- Linux
- November 5, 2023
The command ‘addpart’ is used to tell the Linux kernel about the existence of a specified partition. It is a simple wrapper around the ‘add partition’ ioctl. This command is helpful when you need to inform the Linux kernel about the presence of a new partition.
Use case 1: Tell the kernel about the existence of the specified partition
Code:
addpart /dev/sdb 1 0 100M
Motivation: The motivation for using this command is to inform the Linux kernel about the existence of a new partition on the ‘/dev/sdb’ device.
Explanation:
addpart
is the command used to add a partition./dev/sdb
is the device on which the partition needs to be added.1
is the partition number.0
is the starting sector of the partition.100M
is the length of the partition in megabytes.
Example Output:
Adding partition 1 to /dev/sdb... Done!
In the above example, we use the ‘addpart’ command to add partition number 1 to the ‘/dev/sdb’ device, starting from sector 0 and with a length of 100 megabytes. The command successfully informs the kernel about the existence of the specified partition.
Conclusion:
The ‘addpart’ command is a straightforward way to inform the Linux kernel about the existence of a partition. By using this command, you can easily add partitions to devices and ensure that the kernel is aware of the new partitions.