Checking the drives attached to the Linux server or workstation.

  • mount
    • shows all mounted partitions.
    • note that it contains much more than the physical or virtual volumes. It also lists the logical volumes used by the kernel.
  • lsblk
    • lists all disks as a tree with their partitions and respective mounting points.
  • lsblk -S
    • lists all disks in a table with additional information such as Brand, Model, Revision, Serial…
  • sudo disktype /dev/sdX
    • show detailed information about a disk and its partition.


Popular commands for the interactive mode:

  • sudo fdisk /dev/sdX
    • replace X by the letter of disk as the kernel identifies the volume at that time.
  1. m
    1. prints the menu options.
  2. p
    1. prints the partition table.
  3. d
    1. deletes a partition. If there is more than one it will prompt to inform each one.
    2. if only one it will assume and auto select that one.
  4. n
    1. creates a new partition. It will ask for the type of partition desired: extended or primary (up to 4).
    2. next it will ask where the partition will start (what cylinder number) and how bit it will be (in KB, MB, GB or the last cylinder).
  5. t
    1. changes a partition type.
  6. l
    1. lists known partition types.
  7. F
    1. lists the blocks of non-allocated space.
  8. g
    1. wipes the whole drive and creates a new GPT partition table (the recommended type).
  9. o
    1. wipes the whole drive and creates a new MBR partition table (partitions are limited to 2 TB).
  10. v
    1. verifies the integrity of the partition table.
  11. i
    1. prints information about a partition.
  12. w
    1. will write all the changes to the dist and quit.
  13. q
    1. quits without saving any change to the disk.
  14. e
    1. enters the expert mode.
      1. i
        1. changes the disk GUID.
      2. n
        1. changes the name of a partition.
      3. u
        1. changes the UUID of a partition.
      4. l
        1. changes the table length.
      5. A
        1. flags a legacy BIOS partition as bootable.
      6. p
        1. prints the partition table with additional information.
      7. r
        1. returns to the previous menu.

The application fdisk is also capable of execute changes to the disk in a non-interactive mode programmatically via scripts or commands as needed. See documentation for additional information. Search for sfdisk script files in the manual. See examples:

  • sudo fdisk -l
    • will list all the disks attached to the system.


It does the same thing as the fdisk but with an interactive interface that reminds a graphical interface and allows navigation over the partitions and menu options using the arrow keys or using short keys to speed up.

  • sudo cfdisk /dev/sdX
    • opens the application on the drive .


Parted is a powerful partition editor that has a graphical version called gparted (default in most distributions that use GNOME).

Important: there is no additional command to write the changes to the disk. It writes as you go.

  • sudo parted /dev/sdX
    • opens the application to edit the disk X.
  • sudo parted
    • opens the application with out defining the disk to be edited.
  • help
    • prints the available options.
  • select /dev/sdX
    • defines what disk to be edited.
  • print
    • prints the partition table.
  • help mklabel
    • show instruction and options for the command mklabel.
  • mklabel gpt
    • creates a GPT partition table on the disk (caution: it wipes the whole disk).
  • help mkpart
    • shows the available options for creating a partition.
  • mkpart
    • prompts for the necessary information (partition name, type, starting point, ending point or size) and creates a new partition.
  • quit
    • exits the application.


Creating a file system (formatting) on a partition.

After the partitions table is created and the partitions allocate chunks of the available disk sectors, each partition needs to be “formatted”.

Formatting is the process of creating the respective file system type on the allocated disk space.

  • sudo mkfs.ext4 -L “PartitionLabel” /dev/sdX1
    • formats the partition number 1 of the disk X as EXT4 format (recommended) with a label.
    • same for:
      • mkfs.vfat
      • mkfs.fat (outdated)
      • mkfs.ntfs (modern Windows partition)
      • mkfs.ext3 (outdated)
      • mkfs.ext2 (outdated)
      • mkfs.bfs