1 .TH LOSETUP 8 "November 2015" "util-linux" "System Administration"
3 losetup \- set up and control loop devices
28 Detach all associated loop devices:
34 Print the name of the first unused loop device:
50 .RB [ \-\-show ] " \-f" | \fIloopdev\fP
63 is used to associate loop devices with regular files or block devices,
64 to detach loop devices, and to query the status of a loop device. If only the
65 \fIloopdev\fP argument is given, the status of the corresponding loop
66 device is shown. If no option is given, all loop devices are shown.
68 Note that the old output format (i.e. \fBlosetup -a\fR) with comma-delimited
69 strings is deprecated in favour of the \fB--list\fR output format.
72 The \fIsize\fR and \fIoffset\fR
73 arguments may be followed by the multiplicative suffixes KiB (=1024),
74 MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is
75 optional, e.g., "K" has the same meaning as "KiB") or the suffixes
76 KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
80 Show the status of all loop devices. Note that not all information is accessible
81 for non-root users. See also \fB\-\-list\fR. The old output format (as printed
82 without \fB--list)\fR is deprecated.
84 .BR \-c , " \-\-set\-capacity " \fIloopdev
85 Force the loop driver to reread the size of the file associated with the
86 specified loop device.
88 .BR \-d , " \-\-detach " \fIloopdev\fR...
89 Detach the file or device associated with the specified loop device(s).
91 .BR \-D , " \-\-detach\-all"
92 Detach all associated loop devices.
94 .BR \-\-direct\-io [ =on | off ]
95 Enable or disable direct I/O for the backing file. The optional argument
96 can be either \fBon\fR or \fBoff\fR. If the argument is omitted, it defaults
100 Find the first unused loop device. If a
102 argument is present, use the found device as loop device.
103 Otherwise, just print its name.
105 .BR \-j , " \-\-associated " \fIfile
106 Show the status of all loop devices associated with the given
109 .BR \-J , " \-\-json"
110 Use JSON format for \fB\-\-list\fP output.
112 .BR \-l , " \-\-list"
113 If a loop device or the \fB-a\fR option is specified, print the default columns
114 for either the specified loop device or all loop devices; the default is to
115 print info about all devices. See also \fB\-\-output\fP, \fB\-\-noheadings\fP
116 \fB\-\-json\fP and \fB\-\-raw\fP.
118 .BR \-n , " \-\-noheadings"
119 Don't print headings for \fB\-\-list\fP output format.
121 .BR \-o , " \-\-offset " \fIoffset
122 The data start is moved \fIoffset\fP bytes into the specified file or device.
124 .BR \-O , " \-\-output " \fIcolumns
125 Specify the columns that are to be printed for the \fB\-\-list\fP output.
127 .BR \-P , " \-\-partscan"
128 Force the kernel to scan the partition table on a newly created loop device.
130 Use the raw \fB\-\-list\fP output format.
132 .BR \-r , " \-\-read\-only"
133 Set up a read-only loop device.
134 .IP "\fB\-\-sizelimit \fIsize\fP"
135 The data end is set to no more than \fIsize\fP bytes after the data start.
137 Display the name of the assigned loop device if the
141 argument are present.
143 .BR \-v , " \-\-verbose"
146 .BR \-V , " \-\-version"
147 Display version information and exit.
149 .BR \-h , " \-\-help"
150 Display help text and exit.
153 .B Cryptoloop is no longer supported in favor of dm-crypt.
154 .B For more details see cryptsetup(8).
158 returns 0 on success, nonzero on failure. When
160 displays the status of a loop device, it returns 1 if the device
161 is not configured and 2 if an error occurred which prevented
162 determining the status of the device.
173 The following commands can be used as an example of using the loop device.
176 # dd if=/dev/zero of=~/file.img bs=1MiB count=10
177 # losetup --find --show ~/file.img
179 # mkfs -t ext2 /dev/loop0
180 # mount /dev/loop0 /mnt
183 # losetup --detach /dev/loop0
186 .IP LOOPDEV_DEBUG=all
187 enables debug output.
189 Karel Zak <kzak@redhat.com>, based on the original version from
190 Theodore Ts'o <tytso@athena.mit.edu>
192 The losetup command is part of the util-linux package and is available from
193 ftp://ftp.kernel.org/pub/linux/utils/util-linux/.