HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

losetup — Set up and control loop devices. More information: <https://manned.org/losetup>.

Submitted by: @import:tldr-pages··
0
Viewed 0 times
losetupcommanddevicesandclicontrolloopset
linux

Problem

How to use the losetup command: Set up and control loop devices. More information: <https://manned.org/losetup>.

Solution

losetup — Set up and control loop devices. More information: <https://manned.org/losetup>.

List loop devices with detailed info:
losetup {{[-a|--all]}}


Attach a file to a given loop device:
sudo losetup {{/dev/loop}} /{{path/to/file}}


Attach a file to a new free loop device and scan the device for partitions:
sudo losetup --show {{[-P|--partscan]}} {{[-f|--find]}} /{{path/to/file}}


Attach a file to a read-only loop device:
sudo losetup {{[-r|--read-only]}} {{/dev/loop}} /{{path/to/file}}


Detach all loop devices:
sudo losetup {{[-D|--detach-all]}}


Detach a given loop device:
sudo losetup {{[-d|--detach]}} {{/dev/loop}}

Code Snippets

List loop devices with detailed info

losetup {{[-a|--all]}}

Attach a file to a given loop device

sudo losetup {{/dev/loop}} /{{path/to/file}}

Attach a file to a new free loop device and scan the device for partitions

sudo losetup --show {{[-P|--partscan]}} {{[-f|--find]}} /{{path/to/file}}

Attach a file to a read-only loop device

sudo losetup {{[-r|--read-only]}} {{/dev/loop}} /{{path/to/file}}

Detach all loop devices

sudo losetup {{[-D|--detach-all]}}

Context

tldr-pages: linux/losetup

Revisions (0)

No revisions yet.