Fdisk

Table of Contents

Home DTOS Knowledge Base Community Contribute Support DT’s Work

What is fdisk?

fdisk is a program for managing partition tables and partitions on a hard disk. It understands GPT, MBR, Sun, SGI and BSD partition tables.

Basic commands

List partitions:

sudo fdisk -l

Start the partition manipulator:

sudo fdisk /dev/sdX

Create a new empty partition table:

For a new GPT table:

g

For a new DOS table:

o

Partitioning the disk:

create a partition:

n

change partition type:

t

delete a partition:

d

print the partition table:

p

write the changes made:

w

quit without saving:

q

open a help menu:

m

After fdisk

Make your file system:

  • sudo mkswap /dev/vda1
  • sudo swapon /dev/vda1
  • sudo mkfs.ext4 /dev/vda2
  • sudo mkfs.ext4 /dev/vdb1

sudo blkid

This command gets the UUID of your block devices if you need to add to the fstab. This is useful when wanting to auto-mount partitions that are on their own disk (such as /home or /music).

Editing the fstab:

sudo vim /etc/fstab (or nano, if you prefer)

Add this line at the end of the fstab:

UUID=<noted number from above> /home ext4 defaults 0 2

Now reboot and see if it works!

sudo reboot

Footer

Copyright © 2020-2021 Derek Taylor (DistroTube)

This page is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License (CC-BY-ND 4.0).

The source code for distro.tube can be found on GitLab. User-submitted contributions to the site are welcome, as long as the contributor agrees to license their submission with the CC-BY-ND 4.0 license.

Author: dt

Created: 2021-10-14 Thu 14:34