How-to

How to Create a Partition on a Linux Server

Partitioning a new drive takes a minute: confirm which disk is empty, write a GPT label, create the partition, then format and mount it.

Which drive can I safely partition?

Look before you write. On a machine with more than one drive, one holds the operating system and you must not touch it.

lsblk -e7 -o NAME,SIZE,TYPE,FSTYPE,PARTLABEL,MOUNTPOINTS
findmnt -n -o SOURCE /

The second command prints the device behind the root filesystem. Any drive that shows partitions with mount points like /, /boot or /boot/efi is the system disk. A drive with no children and no filesystem is empty. On a model such as S9 with 2x 1 TB NVMe, expect one of the two to be in use and the other to be either empty or already partitioned by the installer. When in doubt, stop and check blkid on each.

Should I use GPT or MBR?

GPT. It supports drives over 2 TiB, more than four primary partitions and keeps a backup copy of the table at the end of the disk. MBR only makes sense for very old boot setups. Current server boards boot with UEFI, which expects GPT anyway.

How do I partition with parted?

sudo parted -s /dev/nvme1n1 mklabel gpt
sudo parted -s -a optimal /dev/nvme1n1 mkpart data xfs 1MiB 100%
sudo parted /dev/nvme1n1 print

Starting at 1 MiB aligns the partition to physical blocks on every SSD in use today, and -a optimal double checks it. 100% uses all remaining space. The name data is a GPT partition label; the xfs hint is only a type code and does not format anything. -s runs non interactively, so check the device name twice before you press Enter.

How do I split a drive into several partitions?

sudo parted -s /dev/nvme1n1 mklabel gpt \
  mkpart pgdata ext4 1MiB 600GiB \
  mkpart backups ext4 600GiB 100%
sudo parted /dev/nvme1n1 unit GiB print

parted accepts several commands in one call. Sizes can be in MiB, GiB or percent. Think about whether you need partitions at all; one large filesystem with folders is simpler to manage, and LVM gives you flexible volumes you can resize later.

How do I do the same with fdisk?

fdisk is interactive and good when you want to see each step:

sudo fdisk /dev/nvme1n1
  g        # new GPT table
  n        # new partition, accept number and first sector
  +500G    # size, or Enter for the rest of the disk
  t        # change type if needed, 20 = Linux filesystem, 30 = Linux LVM, 29 = Linux RAID
  p        # print to check
  w        # write and exit

Nothing is written until w. Press q to quit without changes if you are unsure.

Can I script it with sgdisk?

sudo sgdisk --zap-all /dev/nvme1n1
sudo sgdisk -n 1:0:0 -t 1:8300 -c 1:"archive" /dev/nvme1n1
sudo sgdisk -p /dev/nvme1n1

sgdisk from the gdisk package is ideal in provisioning scripts. -n 1:0:0 makes partition 1 from the first free aligned sector to the end, -t sets the type code and -c the name. --zap-all wipes old GPT and MBR structures first, which is destructive by design.

Which partition type should I set?

Usesgdisk codeparted flag
Plain filesystem8300none
LVM physical volume8E00set 1 lvm on
Software RAID memberFD00set 1 raid on
Swap8200set 1 swap on

Type codes are hints that help tools and humans; Linux mounts a partition fine with the wrong code. Set them anyway for clarity.

What comes after creating the partition?

sudo partprobe /dev/nvme1n1
sudo mkfs.xfs -L archive /dev/nvme1n1p1
sudo mkdir -p /archive && sudo mount /dev/nvme1n1p1 /archive

partprobe makes the kernel reread the table if the new partition does not show up yet. Then format it, mount it and add it to fstab by UUID as explained in Linux mount command. Formatting choices are covered in Format a disk on Linux.

Can I partition the second drive as a mirror instead?

Yes, and on two drive models that is often the better use. Create a RAID partition on the empty drive and build a degraded mdadm mirror, or plan the layout with Two-drive mirror (RAID 1). We deliver drives as they are, without an array, so the layout is your choice.

Machines With Spare Drives to Partition

ServerProcessorCores / threadsMemoryStorageNetworkPer monthSmallest order
S3Intel Xeon E-2356G6 / 1264 GB DDR42x 1 TB NVMe2x 10 Gbps$80.38$80.38 (1 month)
S9Intel Xeon E-2356G6 / 12128 GB DDR42x 1 TB NVMe2x 10 Gbps$103.54$103.54 (1 month)
D52x Intel Xeon Gold 5315Y16 / 32256 GB DDR42x 2 TB NVMe2x 25 Gbps$305.34$305.34 (1 month)
D202x Intel Xeon Gold 6336Y48 / 96256 GB DDR44x 4 TB NVMe2x 25 Gbps$990.36$990.36 (1 month)

Keep Reading

Format a disk on Linux

Turn the blank second NVMe drive into usable space: identify it, partition with GPT, choose ext4 or XFS, mount by UUID and keep TRIM on.

Open

Linux mount command

Mount drives, partitions and network shares on Linux, make them permanent in fstab with UUIDs, and unmount safely when something is busy.

Open

Delete a partition in Linux

Remove a partition from a Linux drive with parted, fdisk or sgdisk, clear old signatures with wipefs, and keep fstab and RAID config clean.

Open

Two-drive mirror (RAID 1)

How RAID 1 keeps a full copy of your data on two drives, which machines have two drives and how to check it with mdadm.

Open

FAQ

Quick Answers

Writing a new partition table to a drive makes its old data unreachable. Only partition a drive you have confirmed is empty.

No. Run partprobe and the kernel sees the new partition.

It aligns with SSD erase blocks and is what modern tools pick by default.

Yes with parted resizepart, then grow the filesystem. LVM makes this easier.

Yes. Current fdisk fully supports GPT. Press g to create a new GPT table.