How to Create a Partition in Linux (fdisk & parted)

Jun 29, 2026 07:00 AM - 2 days ago 2732

Creating a partition successful Linux lets you disagreement a azygous beingness disk into separate, independent sections that the strategy treats for illustration chopped drives. Partitioning is really you allocate dedicated abstraction for circumstantial uses, isolate the operating strategy from personification data, group up swap, tally much than 1 operating strategy connected 1 machine, and limit the harm erstwhile a filesystem becomes corrupted. Because each partition behaves for illustration a abstracted disk, a problem connected 1 leaves the information connected the others untouched.

In this tutorial, you will study really to create a partition successful Linux from the bid statement utilizing the 2 astir communal tools, fdisk and parted. You will take betwixt an MBR and a GPT partition table, place the correct disk safely, create and group the type of a caller partition, format it pinch a filesystem specified arsenic ext4 aliases xfs, equine it temporarily, make the equine persistent done /etc/fstab, delete a partition, and hole the errors that travel up astir often.

Warning: Partitioning and formatting are destructive operations. Writing a caller partition array aliases moving mkfs connected the incorrect instrumentality will permanently erase data. Always corroborate the target disk pinch lsblk and sudo fdisk -l earlier you constitute immoderate changes, and backmost up important information first.

Key takeaways

  • Partitioning divides 1 beingness disk into independent sections, each of which tin clasp its ain filesystem and beryllium mounted separately.
  • A disk needs a partition array earlier it tin clasp partitions, and the 2 communal types are MBR (msdos) and GPT.
  • MBR supports disks up to astir 2.2 TB (2,199,023,255,040 bytes pinch 512-byte sectors) and a maximum of 4 superior partitions, truthful it suits older BIOS systems and mini disks.
  • GPT removes the 2 TB ceiling, supports up to 128 partitions by default, and is the correct default for ample disks and UEFI systems.
  • fdisk is an interactive instrumentality disposable by default connected astir distributions and handles some MBR and GPT. GPT support was introduced arsenic experimental successful util-linux 2.23 and became unchangeable successful later releases; modern distributions vessel a afloat tin version.
  • parted supports ample disks natively and tin tally non-interactively, which makes it the amended prime for scripting and automation.
  • Creating a partition is only the first step: you must format it pinch a filesystem (for illustration mkfs.ext4 aliases mkfs.xfs) and equine it earlier you tin shop information connected it.
  • Adding a UUID-based introduction to /etc/fstab makes a partition equine automatically each clip the strategy boots.

Prerequisites

Before you create a partition, make judge you person the pursuing successful place.

You request a Linux strategy pinch a 2nd disk aliases unallocated abstraction to activity on, and entree to a personification relationship pinch sudo privileges truthful you tin tally administrative commands. If you request to group this up first, travel the guideline connected how to create a caller sudo-enabled user. You should besides beryllium comfortable moving successful a Linux terminal, since each measurement successful this tutorial uses the bid line.

Both fdisk and parted are portion of modular utilities connected astir distributions. fdisk ships pinch the util-linux package and is almost ever present, while parted whitethorn request to beryllium installed connected a minimal strategy pinch sudo apt instal parted connected Ubuntu and Debian aliases sudo dnf instal parted connected Fedora, Rocky Linux, and different Red Hat based distributions.

Understanding partition tables: GPT vs MBR

A disk cannot clasp partitions until it has a partition table, the mini building astatine the commencement of the disk that records wherever each partition originates and ends. The 2 formats you will brushwood are MBR (also shown arsenic msdos) and GPT, and choosing the correct 1 matters earlier you create anything.

MBR (Master Boot Record) is the older standard. It tin reside disks only up to astir 2.2 TB (2,199,023,255,040 bytes pinch 512-byte sectors) and allows a maximum of 4 superior partitions. To transcend four, MBR lets you move 1 superior partition into an extended partition that holds further logical partitions.

GPT (GUID Partition Table) is the modern replacement defined by the UEFI standard. It removes the 2 TB limit (addressing disks up to astir 9.4 zettabytes), supports up to 128 partitions by default without extended aliases logical partitions, and keeps a backup transcript of the array astatine the extremity of the disk for resilience.

As a speedy rule, take MBR for bequest BIOS systems aliases disks nether 2 TB that request compatibility pinch older systems, and take GPT for immoderate disk larger than 2 TB, for UEFI systems, aliases simply arsenic a modern default.

You tin cheque which partition array a disk already uses earlier making changes. The pursuing bid prints disk details, including the partition array type:

  1. sudo fdisk -l /dev/vda

Look for the Disklabel type statement successful the output, which reports either dos (MBR) aliases gpt:

Output

Disk /dev/vda: 160 GiB, 171798691840 bytes, 335544320 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: DCDD7CFE-DCA3-4181-877E-B1DFCF70E9AA

Linux gives you respective devices for the aforesaid job, and the champion 1 depends connected your disk size, whether you want to book the process, and whether you person a desktop environment. The 3 astir communal options are fdisk, an interactive command-line instrumentality installed by default connected astir each distribution that handles some MBR and GPT (GPT support was introduced arsenic experimental successful util-linux 2.23 and is unchangeable successful each modern releases); parted, a command-line instrumentality that supports ample disks natively and tin tally non-interactively pinch the --script flag, which makes it good suited for automation; and GParted, a graphical beforehand extremity that is convenient connected desktops pinch a GUI but is not typically disposable connected headless servers.

The pursuing array compares the 3 devices truthful you tin prime the correct 1 for your situation:

Feature fdisk parted GParted
Interface Interactive CLI CLI (interactive aliases scripted) Graphical (GUI)
Partition tables MBR and GPT MBR and GPT MBR and GPT
Disks larger than 2 TB Yes (with GPT) Yes Yes
Scripting and automation Limited Yes (--script) No
Default availability Installed connected astir distros Often preinstalled, whitethorn request install Desktop only
Best for Quick interactive edits connected a server Automation, scripting, and ample disks Visual editing connected a desktop

How to place your target disk utilizing lsblk and fdisk -l

Before you partition anything, you must place the correct disk, because choosing the incorrect instrumentality tin destruct data. Two commands springiness you a clear image of the disks and partitions connected your system.

The lsblk bid lists each artifact devices successful an easy-to-read tree, showing each disk and its existing partitions on pinch their sizes and equine points:

  1. lsblk

The output shows your disks and immoderate partitions beneath them:

Output

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 160G 0 disk ├─sda1 8:1 0 159G 0 portion / ├─sda14 8:14 0 4M 0 part ├─sda15 8:15 0 106M 0 portion /boot/efi └─sda16 8:16 0 913M 0 portion /boot sdb 8:16 0 20G 0 disk

In this example, sdb is simply a 20 GiB disk pinch nary partitions, which makes it the disk to activity on. For a much elaborate position that includes partition tables, types, and sizes, usage fdisk -l:

  1. sudo fdisk -l

Output

Disk /dev/sda: 160 GiB, 171798691840 bytes, 335544320 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: DCDD7CFE-DCA3-4181-877E-B1DFCF70E9AA Device Start End Sectors Size Type /dev/sda1 2099200 335544286 333445087 159G Linux filesystem /dev/sda14 2048 10239 8192 4M BIOS boot /dev/sda15 10240 227327 217088 106M EFI System /dev/sda16 227328 2097152 1869825 913M Linux extended boot Partition array entries are not in disk order. Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

You will beryllium prompted for your password to corroborate your sudo privileges. The bid lists each disk and its existent partition layout, which lets you corroborate the instrumentality way (for illustration /dev/sdb) earlier you continue.

How to create a partition utilizing fdisk

fdisk is simply a text-based inferior for viewing and managing disk partitions, and its interactive bid mode is the classical measurement to create a partition successful Linux. The steps beneath locomotion done a complete session, from opening the disk to penning the changes. Start by opening the target disk successful bid mode, replacing /dev/sdb pinch the disk you identified earlier:

  1. sudo fdisk /dev/sdb

Once you are successful bid mode, fdisk waits for single-character commands. The interface tin beryllium confusing astatine first, truthful property m astatine immoderate clip to spot the afloat database of disposable commands:

Output

Welcome to fdisk (util-linux 2.40.2). Changes will stay in representation only, until you determine to write them. Be observant earlier utilizing the write command. Command (m for help):

Output

Help: GPT M participate protective/hybrid MBR Generic d delete a partition F database free unpartitioned space l database known partition types n add a caller partition p people the partition table t alteration a partition type v verify the partition table one people accusation astir a partition Misc m people this menu x other functionality (experts only) Script I load disk layout from sfdisk book file O dump disk layout to sfdisk book file Save & Exit w write array to disk and exit q discontinue without redeeming changes Create a caller label g create a caller quiet GPT partition table G create a caller quiet SGI (IRIX) partition table o create a caller quiet MBR (DOS) partition table s create a caller quiet Sun partition table Command (m for help):

If the disk has nary partition array yet, create 1 earlier adding partitions. Press g to create a caller quiet GPT partition table, aliases o to create an MBR (dos) table, depending connected which type you chose earlier.

To create the partition, type n and property ENTER. On an MBR disk, fdisk first asks for the partition type: take p for a superior partition aliases l for a logical partition. For this tutorial, create a superior partition by entering p. On a GPT disk this punctual does not appear, because GPT does not usage the primary, extended, and logical distinction.

Next, fdisk asks for the starting sector; property ENTER to judge the first free sector. It past asks for the past sector, wherever you tin property ENTER to usage each remaining abstraction aliases specify a size specified arsenic +10G for a 10 GB partition aliases +512M for 512 MB. A number pinch nary portion is interpreted arsenic sectors, truthful +1024 intends 1024 sectors from the start.

On MBR disks, fdisk assigns the caller partition the type Linux (hex codification 83) by default. On GPT disks, the balanced default type is Linux filesystem, identified by a GUID alternatively than a hex code. To group a different type, specified arsenic Linux LVM, usage the t bid and property L to database each disposable types and aliases. On a GPT disk, participate the matter othername lvm to group the partition type to Linux LVM:

Output

Command (m for help): t Partition number (1,14-16, default 16): 1 Partition type aliases alias (type L to database all): 44 Changed type of partition 'Linux filesystem' to 'Linux LVM'.

Before penning thing to disk, reappraisal your work. All changes truthful acold unrecorded only successful memory, truthful property p to people the existent partition array and corroborate it looks correct:

Output

Command (m for help): p Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors Disklabel type: gpt Device Start End Sectors Size Type /dev/sdb1 2048 20973567 20971520 10G Linux LVM

When you are satisfied, constitute the changes to disk pinch w. This is the constituent of nary return, truthful make judge the target is correct:

Output

Command (m for help): w The partition array has been altered. Calling ioctl() to re-read partition table. Syncing disks.

If you determine not to support your changes, property q alternatively of w to discontinue fdisk without penning anything, leaving the disk untouched.

How to create a partition utilizing parted

parted is good suited for automation and scripting, and besides useful good for interactive use. You tin tally it interactively aliases walk commands straight connected the bid line. The interactive convention beneath creates a GPT array and a azygous partition that fills the disk.

Open the target disk pinch parted:

  1. sudo parted /dev/sdb

Inside the parted prompt, group the partition array type pinch mklabel. Use gpt for a GPT array aliases msdos for an MBR table:

  1. (parted) mklabel gpt

Create the partition pinch mkpart. The pursuing bid creates a partition named information that spans the full disk, from the commencement (0%) to the extremity (100%):

  1. (parted) mkpart information ext4 0% 100%

Note: The filesystem type you walk to mkpart (here ext4) only tags the partition; it does not really create a filesystem. You still request to tally mkfs afterward, arsenic shown successful the adjacent section.

Verify the consequence pinch the people command, which displays the disk’s partition table:

  1. (parted) print

The output confirms the caller partition and its size:

Output

Model: Virtio Block Device (virtblk) Disk /dev/sdb: 20 GiB Partition Table: gpt Disk Flags: Number Start End Size File strategy Name Flags 1 1049kB 20 GiB 20 GiB data

Type discontinue to exit parted. Because parted writes changes immediately, location is nary abstracted constitute measurement arsenic location is successful fdisk. To do the aforesaid point successful a azygous non-interactive command, which is perfect for automation, walk the commands pinch the --script flag:

  1. sudo parted --script /dev/sdb mklabel gpt mkpart information ext4 0% 100%

How to format a partition

Creating a partition reserves the space, but you cannot shop files connected it until you format it pinch a filesystem. Formatting is done pinch the due mkfs command, and the 2 astir communal choices are ext4 and xfs.

Warning: Running mkfs erases everything connected the target partition. Double-check the partition way (for illustration /dev/sdb1, not the full disk /dev/sdb) earlier you tally it.

To format the caller partition pinch the ext4 filesystem, tally mkfs.ext4 against the partition path:

  1. sudo mkfs.ext4 /dev/sdb1

The bid reports the filesystem specifications arsenic it writes them:

Output

mke2fs 1.47.0 (5-Feb-2023) Creating filesystem pinch 5242880 4k blocks and 1310720 inodes Filesystem UUID: 9c5a3f7e-1b2c-4d8e-9f10-2a3b4c5d6e7f Superblock backups stored connected blocks: 32768, 98304, 163840, 229376, 294912 Allocating group tables: done Writing inode tables: done Creating diary (16384 blocks): done Writing superblocks and filesystem accounting information: done

If you for illustration xfs, which is the default connected Red Hat Enterprise Linux and Rocky Linux, format the partition pinch mkfs.xfs instead:

  1. sudo mkfs.xfs /dev/sdb1

When to take ext4 vs xfs

Both filesystems are mature and reliable, truthful the correct prime depends connected your workload. The ext4 filesystem is the default connected Ubuntu and Debian and is simply a sensible general-purpose choice, particularly for guidelines and location partitions, because it is resilient and is the only 1 of the 2 that tin beryllium shrunk to reclaim abstraction later. The xfs filesystem is the default connected Red Hat based distributions and excels successful high-throughput, high-I/O server environments and pinch very ample filesystems; it tin beryllium grown while mounted but cannot beryllium shrunk. As a norm of thumb, take ext4 for wide usage aliases wherever you mightiness request to shrink the filesystem, and take xfs for large-scale, high-parallelism storage.

How to equine a partition successful Linux

A formatted partition still needs to beryllium mounted to a directory earlier you tin usage it. Mounting attaches the partition’s filesystem to a location successful your directory tree, called a equine point.

First, create a directory to service arsenic the equine point:

  1. sudo mkdir -p /mnt/data

Then equine the partition to that directory:

  1. sudo mount /dev/sdb1 /mnt/data

Confirm the partition is mounted and spot really overmuch abstraction it has pinch df -h, which reports filesystem usage successful a human-readable format:

  1. df -h /mnt/data

The output shows the device, its size, and wherever it is mounted:

Output

Filesystem Size Used Avail Use% Mounted on /dev/sdb1 20G 24K 19G 1% /mnt/data

This equine is temporary: it will not past a reboot. To make it permanent, adhd an introduction to /etc/fstab arsenic described next.

How to equine a partition permanently utilizing fstab

To equine a partition automatically each clip the strategy boots, you adhd it to the /etc/fstab file. The recommended measurement to reference the partition is by its UUID, a unsocial identifier assigned erstwhile the partition is formatted, because UUIDs do not alteration erstwhile disks are reordered the measurement instrumentality names for illustration /dev/sdb1 can.

First, find the UUID of the partition pinch blkid:

  1. sudo blkid /dev/sdb1

The output includes the UUID worth you need:

Output

/dev/sdb1: UUID="9c5a3f7e-1b2c-4d8e-9f10-2a3b4c5d6e7f" TYPE="ext4" PARTLABEL="data" PARTUUID="a1b2c3d4-0001"

Next, unfastened /etc/fstab successful a matter editor:

  1. sudo nano /etc/fstab

Add a statement astatine the extremity of the record utilizing the UUID from the erstwhile step. The six fields are the source, the equine point, the filesystem type, the equine options, the dump flag, and the filesystem cheque order:

/etc/fstab

UUID=9c5a3f7e-1b2c-4d8e-9f10-2a3b4c5d6e7f /mnt/data ext4 defaults 0 2

Save and adjacent the file. Rather than rebooting to trial the entry, equine everything listed successful /etc/fstab pinch equine -a, which catches errors safely:

  1. sudo mount -a

If the bid returns nary output, the introduction is valid and the partition will equine automatically connected each boot. If it reports an error, hole the /etc/fstab statement earlier rebooting, because an invalid introduction tin interrupt the footwear process.

How to delete a partition successful Linux

You tin region a partition pinch fdisk erstwhile you nary longer request it aliases want to reorganize a disk. Deleting a partition removes it from the partition array and makes its information inaccessible.

Warning: Deleting a partition destroys the information it contains. Unmount the partition first and make judge you person selected the correct 1 earlier penning the change.

If the partition is mounted, unmount it earlier you delete it:

  1. sudo umount /dev/sdb1

Open the disk successful fdisk, past usage the d bid to delete a partition. If the disk has much than 1 partition, fdisk asks which partition number to remove:

Output

Command (m for help): d Partition number (1-3, default 3): 1 Partition 1 has been deleted.

As pinch creating a partition, the deletion lives only successful representation until you property w to constitute the alteration to disk. Press q alternatively if you alteration your mind and want to time off the partition successful place.

Troubleshooting communal partitioning errors

Partitioning operations occasionally neglect pinch errors that person clear causes. Let’s look astatine immoderate of the astir communal ones, and really to resoluteness them.

“Device aliases assets busy” erstwhile penning the partition table

This correction appears erstwhile you effort to modify a disk that has a partition presently mounted aliases successful use, specified arsenic an progressive switch partition. Unmount each partition connected the disk pinch sudo umount /dev/sdbN and disable immoderate switch connected it pinch sudo swapoff /dev/sdbN, past tally your fdisk aliases parted bid again. You cannot repartition the disk that holds the moving strategy without booting from a unrecorded environment.

Partition not visible aft creation

Sometimes a recently created partition does not look erstwhile you tally lsblk, because the kernel has not yet reread the partition table. Force the kernel to reload it pinch the pursuing command, replacing /dev/sdb pinch your disk:

  1. sudo partprobe /dev/sdb

After moving partprobe, tally lsblk again and the caller partition should appear. If it still does not, a reboot will ever make the kernel reread the table.

“Partition array entries are not successful disk order”

This connection warns that the partition numbers do not tally successful the aforesaid bid arsenic their positions connected the disk, which tin hap aft you delete and recreate partitions. It is simply a informing alternatively than a failure, and the partitions still work. In older versions of fdisk you could reorder entries pinch the x master paper and the f command; connected modern systems the informing is mostly safe to ignore.

FAQs

1. What is the quality betwixt fdisk and parted successful Linux?

fdisk is an interactive command-line instrumentality that supports some MBR and GPT partition tables and is disposable by default connected astir Linux distributions, which makes it perfect for quick, hands-on edits connected a azygous disk. parted besides supports MBR and GPT, tin tally non-interactively pinch the --script emblem for automation, and is commonly preferred for scripted aliases repeatable workflows.

2. How do I database each disks and partitions successful Linux earlier creating a partition?

Use lsblk to show each artifact devices successful a character format that shows each disk pinch its partitions, sizes, and equine points. For a much elaborate position that includes the partition array type, tally sudo fdisk -l, which lists each disk on pinch its partitions and types.

3. What partition array should I use: MBR aliases GPT?

Use GPT for disks larger than 2 TB aliases connected systems that usage UEFI firmware, because GPT removes the MBR size ceiling and supports up to 128 partitions. Use MBR for bequest BIOS systems aliases disks nether 2 TB wherever compatibility pinch older systems is required, and erstwhile successful uncertainty connected modern hardware, GPT is the safer default.

4. How do I format a caller partition arsenic ext4 successful Linux?

After creating the partition, tally sudo mkfs.ext4 /dev/sdXN, wherever sdXN is the partition identifier specified arsenic /dev/sdb1. Be observant to target the partition (for illustration /dev/sdb1) and not the full disk (/dev/sdb), because mkfs erases the target.

5. How do I make a partition equine automatically connected footwear successful Linux?

Get the partition UUID pinch sudo blkid, past adhd an introduction to /etc/fstab utilizing the format UUID=<uuid> /mount/point ext4 defaults 0 2. Run sudo equine -a to trial the introduction without rebooting, since utilizing the UUID alternatively than a instrumentality sanction keeps the equine reliable moreover if disk ordering changes.

6. Can I create a partition connected a disk that is already successful use?

Creating a partition connected a disk that has mounted partitions is imaginable but not recommended without first unmounting progressive partitions and disabling switch if applicable. For the disk that holds the moving operating system, footwear from a unrecorded USB aliases rescue situation first, because operating connected it straight risks information corruption.

7. What is the quality betwixt primary, extended, and logical partitions?

These distinctions use only to MBR partition tables. MBR supports up to 4 superior partitions, and to spell beyond that you person 1 superior partition into an extended partition that holds logical partitions. GPT has nary specified limit and supports up to 128 partitions by default, truthful the favoritism does not beryllium connected GPT disks.

8. How do I verify a partition was created successfully successful Linux?

Run lsblk to corroborate the caller partition appears successful the artifact instrumentality tree, aliases tally sudo fdisk -l /dev/sdX to inspect the partition array of a circumstantial disk. After formatting and mounting, tally df -h to corroborate the partition is accessible and shows the expected size astatine its equine point.

Conclusion

You now cognize really to create a partition successful Linux from commencement to decorativeness utilizing some fdisk and parted, including really to take betwixt an MBR and a GPT partition table, format the partition pinch ext4 aliases xfs, equine it, make that equine persistent done /etc/fstab, delete a partition, and troubleshoot the astir communal errors. Because each partition behaves for illustration a abstracted disk, this workflow lets you reserve abstraction for circumstantial tasks and support information connected 1 partition safe moreover if different becomes corrupted.

For repeatable, automated setups, see scripting the process pinch parted --script, and for image-based aliases unreality workflows you whitethorn besides want to research systemd-repart, a newer instrumentality (introduced successful systemd 245) that creates and grows GPT partitions declaratively from configuration files.

To study much astir Linux, we urge checking retired the pursuing DigitalOcean tutorials:

  • How To Partition and Format Storage Devices successful Linux
  • 50+ Essential Linux Commands You Should Know
  • An Introduction to the Linux Terminal
  • How To Create a New Sudo-Enabled User
  • Initial Server Setup pinch Ubuntu

Creative CommonsThis activity is licensed nether a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.

More