Loading...
Linux Interview Questions

Fdisk

1. What is fdisk in Linux?
A) fdisk is a command-line utility used to create, delete, view, and manage disk partitions on Linux systems.

2. How do you list all available disks using fdisk?
A) Run:

fdisk -l

3. What are the partition types supported by fdisk?
A)

  • Primary partition (max 4 in MBR).
  • Extended partition (to create logical partitions).
  • Logical partition (inside extended partition).

4. What is the maximum size supported by MBR partitions in fdisk?
A) MBR supports disk sizes up to 2 TB.

5. What is GPT in fdisk?
A) GPT (GUID Partition Table) is a modern partitioning scheme that supports large disks (up to 18 EB) and allows more than 4 partitions.

6. How do you create a new partition using fdisk?
A)

  • Run → fdisk /dev/sdb
  • Press n → new partition
  • Choose p (primary) or e (extended)
  • Define size → +5G
  • Press w → save changes

7. How do you delete a partition using fdisk?
A)

  • Run → fdisk /dev/sdb
  • Press d → select partition number
  • Press w → save changes

8. How do you change the partition type in fdisk?
A)Inside fdisk:

  • Press t → change partition type
  • Enter partition number → choose hex code (e.g., 83 for Linux, 82 for swap).

9. What does w do in fdisk?
A) The w command writes changes to the disk and exits.

10. What does q do in fdisk?
A) The q command quits without saving changes.

11. What does the p option do in fdisk?
A)  p prints the current partition table.

12. What is the difference between primary, extended, and logical partitions?
A)

  • Primary: Max 4 per disk.
  • Extended: Special partition to hold logical partitions.
  • Logical: Created inside extended, allows >4 partitions.

13. What happens after creating a new partition with fdisk?
A) You must format it with a filesystem (e.g., mkfs.ext4) and then mount it.

14. What is the default partition type in Linux when using fdisk?
A) By default, fdisk assigns type 83 (Linux filesystem).

15. How do you check the partition table format (MBR or GPT)?
A) Run:

parted /dev/sda print

or inside fdisk, it will show “Disklabel type: dos” (MBR) or “gpt”.

16. Can you use fdisk on a mounted partition?
A) No, modifying partitions on a mounted disk can cause data loss. Unmount or use another method.

17. What is the difference between fdisk -l and lsblk?
A)

  • fdisk -l: Lists partition tables with details.
  • lsblk: Shows block devices in a tree format, more human-readable.

18. What precautions should you take when using fdisk?
A)

  • Always back up data before partitioning.
  • Do not modify mounted disks.
  • Carefully check device names (/dev/sda, /dev/sdb) to avoid wiping wrong disks.
Leave a Reply

Your email address will not be published. Required fields are marked *