Linux: Find Out What Partition a File Belongs To

To find out what partition a file belongs to on Linux, you can use the df command with the -P option, which displays the file system space usage, including the file system type, total size, used space, available space, and the mounted file system.

Here’s the basic syntax for using the df command:

df -P <file_path>

For example, if you want to find out what partition the file /etc/fstab belongs to, you would run the following command:

df -P /etc/fstab

The output would show the partition that contains the file /etc/fstab, including the file system type, total size, used space, available space, and the mounted file system:

Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/sda1 495844200 27755556 447881644 6% /

In this example, the file /etc/fstab belongs to the partition /dev/sda1, which is mounted on the root file system (/).

Leave a Comment