Summary Linux Disk Related Commands

Maciej
6 min readDec 6, 2021

Introduction

In this post we will look at commands that relate to disks in Linux.

Commands

  • Information display: lsblk , blkid
  • Partition creation: fdisk , cfdisk , gdisk, cgdisk, sgdisk, parted
  • Mount: mount , umount
  • File system: mkfs , fsck
  • File system (ext2 / 3/4): resize2fs, dumpe2fs, tune2fs
  • Swap: mkswap , swapon, swapoff
  • SMART Information display: smartctl
  • LVM: lvmdiskscan, pvdisplay, pvscan, lvdisplay, lvscan
  • Dealing with Bad sectors: badblocks, ddrescue
  • Finding out which directory is consuming space: ncdu

Information display

You can find almost all the information with fdisk -l You can tell whether it is MBR or GPT by looking at “Disk Label Type”. It doesn’t show where it’s mounted, so use the mount command.

Use Fdisk -l

root@master:/home/ozyrys# fdisk -l  -o +UUID
Disk /dev/loop0: 42.18 MiB, 44220416 bytes, 86368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

--

--

Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.