Initialize an unused disk (/dev/sdb) with a GPT label,
create a small test partition with parted, verify the
kernel view with lsblk and /proc/partitions,
then remove the partition and confirm the disk returns to a clean state.
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.
/dev/sdb exists and is not mounted.parted mklabel gpt.parted, lsblk, and
/proc/partitions.
1MiB is a common alignment practice and avoids reserved areas at the beginning
of the disk.
parted writes the partition table, but the kernel may need to re-read it before
/dev/sdb1 appears or disappears.
/proc/partitions is a kernel-exported view that helps confirm whether the kernel sees
the partition even if a userspace tool seems stale.
/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
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.
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.
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.
After every write operation (mklabel, mkpart, rm), verify with
parted print immediately, then confirm kernel view with lsblk or
/proc/partitions.