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 proving you targeted the correct disk, wrote the expected table, and verified the partition exists before you touch filesystems.
/dev/sdc is present and unpartitioned.fdisk and create a new primary partition./dev/sdc1).ext4 to prepare it for use.fdisk against the disk device (example: /dev/sdc), not a partition.
fdisk, n defines a partition and w writes it to disk.
/dev/sdc1).
lsblk
lsblk is your first proof that the kernel can see the disk. Confirm size and naming so you do not
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 the partition interactively.
Nothing is committed until you write changes.
Welcome to fdisk. Type 'm' for help.
fdisk.
n
n creates a new partition definition in the in-memory table. For a single partition lab scenario,
you typically accept defaults (partition 1, default first sector, default last sector).
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. After writing, the kernel should pick up the new table
and the partition device node should appear.
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
lsblk
sudo fdisk -l /dev/sdc
Confirm the kernel sees the partition (example: /dev/sdc1). If the partition does not appear,
stop and re-check the device you modified before taking any further action.
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 the OS can mount and use. Once complete, the partition is ready to be mounted to a directory and used for storage.
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 2621440 4k blocks and 655360 inodes
Filesystem UUID: 11112222-3333-4444-aaaa-bbbbccccdddd
Filesystem created successfully.
Stop immediately and document what happened. This is why you confirm with lsblk -p and match by size and layout
before running fdisk. Treat it as a high-risk change.
Re-check with lsblk and sudo fdisk -l /dev/sdc. If the table did not write as expected,
do not format anything until you can prove what is on disk.
Formatting should target the partition node (example: /dev/sdc1), not the whole disk (example: /dev/sdc).
Confirm the target with lsblk -f before re-running mkfs.
If you quit without w, no changes were committed. Re-run sudo fdisk /dev/sdc and confirm whether the partition
exists before repeating steps.
This lab is safe to leave as-is if you are using the partition in the next storage lab. If this was a disposable test disk, confirm you created the expected partition and filesystem before moving on.
lsblk -f
sudo fdisk -l /dev/sdc
lsblk -f shows /dev/sdc1 exists and has an ext4 filesystem.
lsblk: Lists block devices and partitions to confirm device presence and structure.
-f: Show filesystem type, UUID, and label for each device.-p: Show full device paths (example: /dev/sdc, /dev/sdc1).fdisk <disk>: Interactive partition editor for creating and writing a partition table.
n: Create a new partition definition.w: Write changes to disk and exit.p: Print the current partition table in the session.q: Quit without writing changes.fdisk -l <disk>: Lists the partition table for a disk (verification view).
mkfs.ext4 <partition>: Creates an ext4 filesystem on a partition.
-L <label>: Set a filesystem label (example: -L DATA).