Scenario
A new 2G disk was attached to a RHEL VM for a temporary data staging task. Before handing the VM to an automation pipeline, you need to initialize the disk with GPT, create a small partition to validate the workflow, verify the kernel sees it, then remove the partition to return the disk to a clean state.
Confirm the target disk before writing labels or deleting partitions. GPT operations will destroy any existing partition layout on the selected device.
Objective
- Confirm
/dev/sdbexists and is not mounted. - Detect an unknown or uninitialized partition table.
- Write a GPT disk label with
parted mklabel gpt. - Create a MiB-aligned partition with explicit boundaries.
-
Verify the partition via
parted,lsblk, and/proc/partitions. - Remove the partition and re-verify a clean kernel view.
Concepts
- GPT is the modern default partition table and supports larger disks and more partitions than MBR.
-
Starting at
1MiBis a common alignment practice and avoids reserved areas at the beginning of the disk. -
partedwrites the partition table, but the kernel may need to re-read it before/dev/sdb1appears or disappears. -
/proc/partitionsis a kernel-exported view that helps confirm whether the kernel sees the partition even if a userspace tool seems stale. - Removing a partition deletes the entry from GPT but does not wipe disk blocks.
Walkthrough
/dev/sdb is present and not mounted.
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
This is your fast safety check: the disk exists, has the expected size, and has no mountpoints.
NAME MAJ:MIN RM SIZE RO TYPE FSTYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
└─sda1 8:1 0 20G 0 part xfs /
sdb 8:16 0 2G 0 disk
/dev/sdb.
sudo parted /dev/sdb print
On a blank disk, parted reports an unrecognized label. That’s expected and confirms
you are starting clean.
Error: /dev/sdb: unrecognised disk label
Model: Virtio Block Device (virtblk)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
sudo parted /dev/sdb mklabel gpt
This initializes the disk with GPT. On real systems, always do this only after you have confirmed the correct target device.
Information: You may need to update /etc/fstab.
sudo parted /dev/sdb print
Your verification signal is the Partition Table: gpt line.
Model: Virtio Block Device (virtblk)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
sudo parted /dev/sdb mkpart primary 1MiB 101MiB
Starting at 1MiB keeps boundaries aligned. The goal here is repeatable,
deterministic partition creation.
Information: You may need to update /etc/fstab.
parted.
sudo parted /dev/sdb print
Confirm you see partition 1 with the expected start and end.
Number Start End Size File system Name Flags
1 1049kB 106MB 105MB primary
/dev/sdb1.
lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS
This checks device node creation and the kernel’s current block device layout.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
└─sda1 8:1 0 20G 0 part /
sdb 8:16 0 2G 0 disk
└─sdb1 8:17 0 100M 0 part
/proc/partitions reflects the partition.
tail /proc/partitions
/proc/partitions is the kernel-exported view. This is useful when userspace tools
disagree or a device node seems stale.
major minor #blocks name
8 0 20971520 sda
8 1 20970496 sda1
8 16 2097152 sdb
8 17 102400 sdb1
sudo parted /dev/sdb rm 1
This removes the partition entry from the GPT. It does not wipe blocks, but it returns the partition layout to no partitions.
Information: You may need to update /etc/fstab.
parted.
sudo parted /dev/sdb print
Model: Virtio Block Device (virtblk)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
/proc/partitions no longer lists sdb1.
tail /proc/partitions
major minor #blocks name
8 0 20971520 sda
8 1 20970496 sda1
8 16 2097152 sdb
sdb1 is gone in lsblk.
lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS
You should only see the disk now. If sdb1 still appears, the kernel may not have
re-read the table yet.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
└─sda1 8:1 0 20G 0 part /
sdb 8:16 0 2G 0 disk
Common breakpoints
The kernel may not have re-read the partition table yet. In real ops, you might run
partprobe or trigger a rescan so the new partition device node is created.
You removed the partition entry, but userspace still sees a stale device. Re-check with
parted print first, then refresh the kernel view if needed.
Always verify identity and size before writing labels:
lsblk -o NAME,SIZE,MODEL,SERIAL
(fields depend on platform). The fastest way to lose a system is to partition the wrong disk.
parted may display in MB/GB while you create partitions in MiB. That’s normal.
Keep using explicit MiB boundaries when you need repeatability.
Cleanup checklist
Confirm the partition entry is removed and only the base disk remains visible.
sudo parted /dev/sdb print
lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS | grep -E '^sdb'
grep -E 'sdb$|sdb1$' /proc/partitions || true
parted shows no partitions, and lsblk does not list sdb1.
Reference
-
lsblk: Validate device presence and mounts.-
-o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS: Show fields used for safety checks.
-
-
parted: Inspect and modify partition tables.print: Show disk geometry and current partition table.mklabel gpt: Write GPT partition table to disk.mkpart primary 1MiB 101MiB: Create a partition using MiB boundaries.rm 1: Remove a partition by number.
-
/proc/partitions: Kernel-exported view of block devices and partitions.- Useful to confirm kernel state when userspace appears stale.
After every write operation (mklabel, mkpart, rm), verify with
parted print immediately, then confirm kernel view with lsblk or
/proc/partitions.