Identify a newly attached disk, create a primary partition using fdisk, and write the partition table safely.
Verify the new device node exists and prepare it for use by formatting the partition with ext4.
A new 10GB disk has been attached at /dev/sdc. You are tasked with confirming the disk is present,
creating a new primary partition using fdisk, writing the changes, and preparing the partition for use
by formatting it.
Partitioning is irreversible when done wrong. The job is not “run commands,” it is proving you targeted the correct disk, wrote the expected table, and verified the partition exists before you touch filesystems or mounts.
/dev/sdc is present and unpartitioned.fdisk and create a new primary partition./dev/sdc1).ext4 to prepare it for use.lsblk.
fdisk.
fdisk actions: create (n) vs write (w).
lsblk or fdisk -l.
mkfs.ext4.
lsblk
lsblk
is your first proof that the kernel can see the disk. You use it to confirm size and naming so you do not accidentally
partition the wrong device.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 512M 0 part /boot
└─sda2 8:2 0 39.5G 0 part /
sdc 8:32 0 10G 0 disk
fdisk on the whole disk.
sudo fdisk /dev/sdc
You run fdisk on the disk device (not a partition). From here, you create a new partition interactively.
Nothing is committed until you write changes.
Welcome to fdisk. Type 'm' for help, 'n' to create a new partition.
fdisk.
n
n
creates a new partition definition in the in-memory partition table. You typically accept defaults for a single primary partition
that consumes the disk, unless you have specific sizing requirements.
Partition type: primary (default p)
Partition number: 1
First sector: (default)
Last sector: (default)
Created a new partition 1 of type 'Linux' and size ~10 GiB.
w
w
commits changes to disk and exits fdisk. This is the point of no return. After writing, the kernel may immediately
pick up the new partition table, and the new partition node should appear.
Partition table written. Syncing disks.
lsblk
# OR
sudo fdisk -l
After writing the table, you confirm the kernel sees the partition. If the partition does not appear, you might need to rescan
the device or re-run lsblk. In real environments you might use partprobe or replug the device.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 0 10G 0 disk
└─sdc1 8:33 0 10G 0 part
sudo mkfs.ext4 /dev/sdc1
Formatting creates the filesystem that higher-level tools and mounts can use. Once this completes, the partition is ready to be mounted to a directory and used for storage.
Filesystem created on /dev/sdc1
lsblk
: Lists block devices and partitions to confirm device presence and structure.
fdisk <disk>
: Interactive partition editor for MBR/DOS-style partition tables (commonly used in basic lab scenarios).
n
: Creates a new partition definition.
w
: Writes the partition table to disk and exits.
fdisk -l
: Lists partition tables for disks (useful for verification).
mkfs.ext4 <partition>
: Creates an ext4 filesystem on a partition.