Loading...

Lab 123: Partition /dev/sdb with msdos (MBR) using parted

Label an uninitialized disk with an MBR (msdos) partition table, create a primary partition with parted, verify the kernel sees it via lsblk and /proc/partitions, then remove the partition and confirm the disk returns to a clean state.

storage parted mbr rhel

Scenario

A new 100MB disk (/dev/sdb) was attached to a RHEL VM for a legacy appliance. The appliance requires an MBR partition table (msdos), not GPT. Your job is to label the disk, create a small primary partition for testing, verify the kernel sees it, then remove the partition to return the disk to a clean state.

Safety note

Double-check the target device before writing partition tables. The commands in this lab are destructive to existing partition layouts on the selected disk.

Objective

  • Confirm the disk has no recognized partition table.
  • Write an MBR (msdos) disk label with parted mklabel.
  • Create a primary partition with MiB-aligned boundaries.
  • Verify the partition appears in parted output.
  • Verify the kernel’s view using lsblk and /proc/partitions.
  • Remove the partition with parted rm and verify cleanup.

Concepts

  • MBR is represented as msdos in parted .
  • Starting at 1MiB is a common alignment practice and avoids MBR reserved space.
  • parted updates the partition table, but the kernel may need to re-read it before /dev/sdb1 appears.
  • /proc/partitions is a simple kernel-exported view that helps confirm the partition exists even when tooling is confusing.
  • Removing a partition deletes the table entry but does not wipe disk blocks.

Walkthrough

Step 1 : Inspect current partition information on /dev/sdb .
Command
sudo parted /dev/sdb print

On an uninitialized disk, parted will report an unrecognized label and show the disk geometry. This confirms you are starting from a blank layout.

Error: /dev/sdb: unrecognised disk label
Model: Virtio Block Device (virtblk)
Disk /dev/sdb: 105MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
Step 2 : Create an MBR partition table (msdos) on /dev/sdb .
Command
sudo parted /dev/sdb mklabel msdos

This writes the disk label. It is destructive if the disk previously contained a partition layout.

Step 3 : Confirm the partition table type is now msdos .
Command
sudo parted /dev/sdb print
Model: Virtio Block Device (virtblk)
Disk /dev/sdb: 105MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags
Step 4 : Create a primary partition aligned to MiB.
Command
sudo parted /dev/sdb mkpart primary 1MiB 101MiB

Starting at 1MiB avoids the MBR gap and aligns partitions cleanly. The end boundary leaves a little room for device geometry and alignment.

Information: You may need to update /etc/fstab.
Step 5 : Verify the partition exists in parted .
Command
sudo parted /dev/sdb print
Number  Start   End     Size    Type     File system  Flags
 1      1.05MiB 101MiB  100MiB  primary
Step 6 : Confirm the kernel created /dev/sdb1 .
Command
lsblk /dev/sdb

This is the practical check that userspace sees the device node and the partition. If /dev/sdb1 does not appear, you may need a rescan.

NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sdb    8:16  0  100M  0 disk
└─sdb1 8:17  0   95M  0 part
Step 7 : Confirm /proc/partitions reflects the new partition.
Command
grep -E 'sdb$|sdb1$' /proc/partitions

/proc/partitions is the kernel’s exported view. This is a clean verification step when troubleshooting device node issues.

8  16 102400 sdb
8  17  97280 sdb1
Step 8 : Remove partition 1.
Command
sudo parted /dev/sdb rm 1

This removes the partition entry from the table. It does not wipe data blocks, but it returns the partition layout to no partitions.

Step 9 : Confirm the partition is gone.
Command
sudo parted /dev/sdb print
Model: Virtio Block Device (virtblk)
Disk /dev/sdb: 105MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags
Step 10 : Verify kernel view updated (no sdb1 ).
Command
lsblk /dev/sdb

You should only see the disk device now. If a stale partition device remains visible, you may need to trigger a rescan.

NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sdb    8:16  0  100M  0 disk

Common breakpoints

Partition does not appear as /dev/sdb1

The kernel may not have re-read the partition table yet. In real environments, you might use partprobe or a device rescan to refresh the kernel’s view.

Wrong disk selected

Always verify device identity using lsblk -o NAME,SIZE,MODEL,SERIAL when available before writing a new disk label.

MBR vs GPT mismatch

Some environments default to GPT. This lab forces msdos explicitly to match legacy requirements.

Cleanup checklist

Confirm the partition entry is removed and only the base disk remains visible.

Commands
sudo parted /dev/sdb print
lsblk /dev/sdb
grep -E 'sdb$|sdb1$' /proc/partitions || true
Success signal

parted shows no partitions, and lsblk does not list sdb1 .

Reference

  • parted /dev/sdb print : Shows disk geometry and partition table.
    • print : Displays current label, partitions, and disk metadata.
  • parted /dev/sdb mklabel msdos : Writes an MBR partition table to the disk.
    • mklabel : Creates a new disk label (partition table).
    • msdos : MBR partition table type.
  • parted /dev/sdb mkpart primary 1MiB 101MiB : Creates a primary partition using MiB boundaries.
    • mkpart : Creates a new partition.
    • primary : Partition type for MBR layouts.
    • 1MiB 101MiB : Start and end positions with MiB alignment.
  • parted /dev/sdb rm 1 : Removes a partition by number.
    • rm : Deletes the partition entry.
    • 1 : The partition number shown in print.
  • lsblk /dev/sdb : Verifies kernel device and partition nodes.
    • Useful for confirming /dev/sdb1 appears or disappears after changes.
  • /proc/partitions : Kernel-exported list of block devices and partitions.
    • Good for confirming kernel state when udev nodes appear stale.
Tip

When you need deterministic boundaries, prefer MiB units ( 1MiB ) and verify with parted print immediately after each write.