Signup/Sign In

Manage partitions using addpart command in Linux

addpart (add partition) is a basic tool which comes bundled with the util-linux package (It was formerly known as util-linux-ng). util-linux is a standard package, a utility software, distributed by the Linux Kernel Organization for use as part of the Linux operating system. It is a random collection of Linux utilities.

It provides information about the presence of the specified partition to the Linux kernel. The command is merely an "add partition" ioctl wrapper on the command line. This command is not used to modify partitions on a block device.

local cur
case $COMP_CWORD in
OPTS="--help --version $(lsblk -pnro name)"
compopt -o bashdefault -o default
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
# FIXME: how to determine next free partition number
COMPREPLY=( $(compgen -W "start" -- $cur) )
COMPREPLY=( $(compgen -W "length" -- $cur) )
return 0
complete -F _addpart_module addpart

Install addpart command

util-linux comes within the Linux kernel. But, you can also use these commands to install them manually.

Debian based - apt install util-linux
Alpine - apk add util-linux
Arch Linux - pacman -S util-linux
CentOS - yum install util-linux
Fedora - dnf install util-linux
OS X - brew install util-linux
Raspbian - apt-get install util-linux
Docker - docker run addpart

addpart Syntax

addpart <disk device> <partition number> <start> <length>

addpart Options

device The disk device.
partition The partition number.
start The beginning of the partition (in 512-byte sectors).
length The length of the partition (in 512-byte sectors).
--help display this help and exit.
-V, --version output version information and exit.

addpart Examples:

Show addpart syntax and usage.

If addpart isn’t provided with all four parameters, then it will display the following message.

$ addpart
addpart: not enough arguments
Try 'addpart --help' for more information.

View addpart help message.

You can use the -help option to view addpart help message.

$ addpart --help

addpart <disk device> <partition number> <start> <length>

Linux terminal command: addpart, manage drive partitions

Check drive partitions in Linux

We can use lsblk command to list disk and partition information as follows:

Use lsblk command in Linux terminal to list drive and partition information

Use addpart to interact with Linux kernel

To use this command with a system disk device, you may require root privilege. Also, the disk device should not be busy, it should be unmounted to the system.

To tell the Linux kernel about the existence of a file partition, we use the following syntax:

addpart disk_device partition_number start length

Now, Let’s use TAB completion (For BASH shell) to view all disk devices available.

$ addpart
/dev/sda /dev/sda10 /dev/sda12 /dev/sda3 /dev/sda5 /dev/sda7 /dev/sda9 --version
/dev/sda1 /dev/sda11 /dev/sda2 /dev/sda4 /dev/sda6 /dev/sda8 --help
$ addpart

From this list of available disk devices, choose one.

For the next argument we need to specify the partition number as follows.

addpart /dev/sda 1

Now you can specify the remaining two arguments; the name and the length of the partition (in 512-byte sectors).

addpart /dev/sda 1 1 1


In this article, we explored a basic Linux command line utility addpart, which is a part of Linux standard package called util-linux. It is used to interact with the Linux kernel and tell about the existing partitions. This command comes with four options that can be specified as device, partition, start and length.

About the author:
Pradeep has expertise in Linux, Go, Nginx, Apache, CyberSecurity, AppSec and various other technical areas. He has contributed to numerous publications and websites, providing his readers with insightful and informative content.