losetup
disk managementLinux/Unix
The losetup command is one of the most frequently used commands in Linux/Unix-like operating systems. losetup Set up and control loop devices
Quick Reference
Command Name:
losetup
Category:
disk management
Platform:
Linux/Unix
Basic Usage:
losetup [options] [arguments]
Common Use Cases
Syntax
losetup [options] [loopdev] [file]
Options
Option | Description |
---|---|
-a, --all |
Show the status of all loop devices |
-d, --detach [loopdev...] |
Detach one or more loop devices |
-f, --find [file] |
Find the first unused loop device |
-c, --set-capacity loopdev |
Reread the size of the file associated with the loop device |
-j, --associated file |
Show loop devices associated with the given file |
-l, --list |
List information about all loop devices |
-o, --offset offset |
Start at the specified offset in the file |
--partscan |
Force the kernel to scan the partition table on the loop device |
-r, --read-only |
Set up a read-only loop device |
--show |
Display the name of the assigned loop device |
-v, --verbose |
Verbose mode |
-h, --help |
Display help information and exit |
-V, --version |
Display version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the losetup
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
losetup /dev/loop0 disk.img