Linux Disk Setup Guide: Partition, Format (XFS), Mount — With Optional LVM
This guide explains how to prepare a new, unpartitioned disk on Linux (example: /dev/sdb) and either:
- Create a standard XFS partition, or
- Use the disk with LVM (Physical Volume → Volume Group → Logical Volume).
Both workflows include instructions for persistent mounting.
1. Identify the New Disk
lsblk
Verify it has no partitions:
sudo fdisk -l /dev/sdb
2. Option A — Create a Standard Partition (Non-LVM)
2.1 Create a partition
sudo fdisk /dev/sdb
Commands to enter:
n # new partition
p # primary
1 # partition number
<enter> # default start
<enter> # default end (use whole disk)
w # write changes
Partition created: /dev/sdb1
2.2 Format the partition with XFS
Install tools if needed:
sudo apt install xfsprogs # Ubuntu/Debian
sudo yum install xfsprogs # RHEL/CentOS
Format:
sudo mkfs.xfs /dev/sdb1
2.3 Create a mount point
sudo mkdir -p /mnt/data
2.4 Mount the partition
sudo mount /dev/sdb1 /mnt/data
2.5 Add to /etc/fstab for persistence
Find UUID:
sudo blkid /dev/sdb1
Edit /etc/fstab:
sudo nano /etc/fstab
Add:
UUID=<your-uuid-here> /mnt/data xfs defaults 0 0
Test:
sudo mount -a
3. Option B — Use the Disk with LVM (PV → VG → LV → XFS)
This option is used when you want flexibility to expand storage later.
3.1 Create an LVM Partition
Use fdisk:
sudo fdisk /dev/sdb
Inside fdisk:
n # new partition
p # primary
1 # partition number
<enter> # default start
<enter> # default end
t # change type
8e # Linux LVM
w # write
Partition created: /dev/sdb1 (type LVM)
3.2 Create a Physical Volume (PV)
sudo pvcreate /dev/sdb1
Verify:
sudo pvs
3.3 Create a Volume Group (VG)
Example VG name: vg_data
sudo vgcreate vg_data /dev/sdb1
Verify:
sudo vgs
3.4 Create a Logical Volume (LV)
Example LV name: lv_data
Use 100% of VG:
sudo lvcreate -l 100%FREE -n lv_data vg_data
Logical volume path becomes:
/dev/vg_data/lv_data
3.5 Format LV with XFS
sudo mkfs.xfs /dev/vg_data/lv_data
3.6 Create a mount point
sudo mkdir -p /mnt/data
3.7 Mount the logical volume
sudo mount /dev/vg_data/lv_data /mnt/data
3.8 Add LV to /etc/fstab (persistent mount)
Get UUID:
sudo blkid /dev/vg_data/lv_data
Edit fstab:
sudo nano /etc/fstab
Add:
UUID=<your-uuid> /mnt/data xfs defaults 0 0
Test for errors:
sudo mount -a
4. Verification After Reboot
sudo reboot
After the system starts:
df -h | grep data
You should see the mounted filesystem.
Summary Table
| Method | Device | Format | Mount | Persistent |
|---|---|---|---|---|
| Standard Partition | /dev/sdb1 | mkfs.xfs | mount /dev/sdb1 /mnt/data | UUID in /etc/fstab |
| LVM | /dev/vg_data/lv_data | mkfs.xfs | mount /dev/vg_data/lv_data /mnt/data | UUID in /etc/fstab |