> For the complete documentation index, see [llms.txt](https://sarpers-organization.gitbook.io/ctftricks/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sarpers-organization.gitbook.io/ctftricks/_chapter-intro-5/filesystem/trick-0259.md).

# Mount Disk Image Partitions

***

````markdown
In Unix-like operating systems, a loop device, or loopback device, is a pseudo-device that makes a computer file accessible as a block device, such as a physical disk or partition. To mount specific partitions from a raw disk image file using a loop device, follow these steps.

First, use `losetup` with the `--find` and `--partscan` options to associate the image file with the first available unused loop device and automatically detect its partitions.

```bash
sudo losetup --find --partscan disk_image.img
````

The `--find` (`-f`) option finds the first unused loop device and uses the specified file (`disk_image.img`) as its backing store. When `--partscan` (`-P`) is also specified (which is automatically used when `--find` is present), the kernel scans the partition table on the newly created loop device and creates device nodes for each partition found. This command will find the next available loop device (e.g., `/dev/loop11`) and automatically create associated devices for each partition found within the image (e.g., `/dev/loop11p1`, `/dev/loop11p2`).

You can verify the loop device assigned using `losetup -a` to list all active loop devices. To list the detected partitions and their details, use `fdisk -l` on the assigned loop device:

```bash
sudo fdisk -l /dev/loop11
```

This command displays the partition table for the loop device, showing information like partition numbers, start and end sectors, and sizes.

Once you identify the desired partition device (e.g., `/dev/loop11p2`) from the `fdisk -l` output, you can mount it like any other block device to a chosen mount point:

```bash
sudo mount /dev/loop11p2 /mnt/mount_point
```

Ensure the mount point directory exists before attempting to mount. These operations typically require root privileges for `losetup` and `mount`.

```
```
