Skip to content
IT related

FSTAB

Updated 2 min read

fdisk is a command-line utility used to manipulate disk partition tables on Linux. It's often used for creating, deleting, resizing, and managing disk partitions. Here's a basic cheat sheet for fdisk:

Starting fdisk

  • Launch fdisk on a Specific Disk:
    sudo fdisk /dev/sdX
    
    Replace /dev/sdX with the specific disk (e.g., /dev/sda).

Basic fdisk Commands

  • m: Display the help menu.
  • p: Print the partition table.
  • n: Add a new partition.
  • d: Delete a partition.
  • t: Change a partition's system id (type).
  • l: List known partition types.
  • w: Write the table to disk and exit.
  • q: Quit without saving changes.

Creating a New Partition

  1. Start fdisk: sudo fdisk /dev/sdX.
  2. Create Partition: Press n for a new partition.
  3. Select Type: Choose p for primary or e for extended.
  4. Specify Partition Number: Choose a number (e.g., 1).
  5. Set the Start and End: Accept the default start sector and specify the end (or size).
  6. Write and Exit: Press w to write changes and exit.

Deleting a Partition

  1. Start fdisk: sudo fdisk /dev/sdX.
  2. Delete Partition: Press d.
  3. Select Partition Number: Enter the number of the partition to delete.
  4. Write and Exit: Press w to write changes and exit.

Changing a Partition Type

  1. Start fdisk: sudo fdisk /dev/sdX.
  2. Change Type: Press t.
  3. Select Partition: Enter the partition number.
  4. Enter Hex Code: Enter the hex code for the desired type (use l to list codes).
  5. Write and Exit: Press w to write changes and exit.

Tips

  • Always back up important data before making changes to disk partitions.
  • After changing disk partitions, you may need to format new partitions using mkfs (e.g., mkfs.ext4 for an ext4 filesystem).
  • Use lsblk or fdisk -l to list all block devices and their partition layouts.
  • Be cautious while using fdisk as improper use can lead to data loss.
IT related RSS feed Published with Oblish

Keyboard shortcuts

/
Search
[
Previous page
]
Next page
?
Show this list
Esc
Close