Warning: These steps modify disk partitions and can destroy data. Double-check the device name and back up any important data before proceeding.
- Root access (use
sudo -iorsudo su). - A spare disk or removable media (SD card, USB drive, eMMC) with free space.
- Know the correct device name (e.g.
/dev/sda,/dev/mmcblk0,/dev/nvme0n1).
This document explains how to create a new partition using fdisk, force the kernel to re-read the partition table, and optionally create a filesystem and mount the partition.
Identify the correct disk before making changes:
# list block devices and partitions
lsblk
# or show detailed partition/size information
sudo fdisk -l
# inspect a specific device (example)
lsblk /dev/sda
# or for SD/eMMC devices
lsblk /dev/mmcblk0Carefully confirm which device (for example /dev/sda or /dev/mmcblk0) you will modify.
Open an interactive fdisk session for the target disk (replace /dev/sdX with your device):
sudo fdisk /dev/sdXInside the fdisk prompt:
- Type
nand press Enter to create a new partition. - Choose partition type:
p— primarye— extended (usually not needed on modern systems)
- Choose a partition number (or press Enter to accept the default).
- For the first sector press Enter to accept the default (recommended).
- For the last sector you can press Enter to use the remaining space, or specify a size like
+1G,+500M, etc.
Example interactive session:
Command (m for help): n
Select (default p): p
Partition number (1-4, default 1): [Enter]
First sector (2048-..., default 2048): [Enter]
Last sector, +sectors or +size{K,M,G,T,P} (2048-..., default ...): +2G
The default type is Linux (code 83). To change it:
- Type
tand Enter. - Enter the partition number if prompted.
- Enter the hex code for the type, or type
Lto list available codes and choose one.
Common type codes:
83— Linux filesystem82— Linux swap07— NTFS/exFATef— EFI System (FAT)
When ready, save changes with:
Command (m for help): w
This writes the partition table to disk and exits fdisk. If you quit without w (for example with q), no changes will be saved.
Force the kernel to re-read the partition table so the new partition becomes visible:
sudo partprobe /dev/sdX
# or
sudo partx -a /dev/sdX
# verify
lsblk
sudo fdisk -l /dev/sdXIf the kernel cannot re-read the table, a reboot may be required.
After creating a partition (for example /dev/sdX1) you can create a filesystem:
# create ext4 filesystem
sudo mkfs.ext4 /dev/sdX1
# or create FAT32 (useful for SD cards / cross-platform):
sudo mkfs.vfat -F 32 /dev/sdX1Mount it:
sudo mkdir -p /mnt/my-partition
sudo mount /dev/sdX1 /mnt/my-partition
# check usage
df -h /mnt/my-partitionTo auto-mount at boot, use the partition UUID in /etc/fstab:
sudo blkid /dev/sdX1
# example fstab entry (replace UUID and mount point):
# UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/my-partition ext4 defaults 0 2- ALWAYS double-check the device name; writing to the wrong device will destroy data.
- On eMMC/SD devices, partitions are named like
/dev/mmcblk0p1(note thepbefore the number). - On NVMe devices, device names are like
/dev/nvme0n1and partitions like/dev/nvme0n1p1. - Use
lsblkandfdisk -lto confirm sizes and partitions before and after changes.
- fdisk manual:
man fdisk - lsblk manual:
man lsblk
If you want I can rename this file to How to Create Partition.md and commit that change, or create a separate .md file instead. Tell me which you'd prefer and which branch to use.