]>
Commit | Line | Data |
---|---|---|
289619bd | 1 | .TH LOSETUP 8 "November 2015" "util-linux" "System Administration" |
fd6b7a7f KZ |
2 | .SH NAME |
3 | losetup \- set up and control loop devices | |
4 | .SH SYNOPSIS | |
5 | .ad l | |
d162fcb5 KZ |
6 | Get info: |
7 | .sp | |
8 | .in +5 | |
fd6b7a7f | 9 | .B losetup |
26ea6eb1 | 10 | .I loopdev |
d162fcb5 | 11 | .sp |
896352d3 OO |
12 | .B losetup -l |
13 | .RB [ \-a ] | |
8b125fae | 14 | .sp |
26ea6eb1 KZ |
15 | .B losetup -j |
16 | .I file | |
17 | .RB [ \-o | |
18 | .IR offset ] | |
259fcc57 | 19 | .sp |
d162fcb5 | 20 | .in -5 |
c372860d | 21 | Detach a loop device: |
d162fcb5 KZ |
22 | .sp |
23 | .in +5 | |
24 | .B "losetup \-d" | |
f7963004 | 25 | .IR loopdev ... |
d162fcb5 KZ |
26 | .sp |
27 | .in -5 | |
f1453d52 | 28 | Detach all associated loop devices: |
34f9b684 PU |
29 | .sp |
30 | .in +5 | |
31 | .B "losetup \-D" | |
32 | .sp | |
33 | .in -5 | |
c372860d | 34 | Print the name of the first unused loop device: |
d162fcb5 KZ |
35 | .sp |
36 | .in +5 | |
37 | .B "losetup \-f" | |
38 | .sp | |
39 | .in -5 | |
c372860d | 40 | Set up a loop device: |
d162fcb5 KZ |
41 | .sp |
42 | .in +5 | |
43 | .B losetup | |
d162fcb5 KZ |
44 | .RB [ \-o |
45 | .IR offset ] | |
7bcefc7f | 46 | .RB [ \-\-sizelimit |
ca1e1363 | 47 | .IR size ] |
26ea6eb1 | 48 | .in +8 |
c372860d BS |
49 | .RB [ \-Pr ] |
50 | .RB [ \-\-show ] " \-f" | \fIloopdev\fP | |
d162fcb5 | 51 | .I file |
d34ac93a | 52 | .sp |
d162fcb5 | 53 | .in -13 |
c372860d | 54 | Resize a loop device: |
d34ac93a KZ |
55 | .sp |
56 | .in +5 | |
57 | .B "losetup \-c" | |
58 | .I loopdev | |
59 | .in -5 | |
fd6b7a7f KZ |
60 | .ad b |
61 | .SH DESCRIPTION | |
62 | .B losetup | |
63 | is used to associate loop devices with regular files or block devices, | |
c372860d | 64 | to detach loop devices, and to query the status of a loop device. If only the |
26ea6eb1 | 65 | \fIloopdev\fP argument is given, the status of the corresponding loop |
c372860d BS |
66 | device is shown. If no option is given, all loop devices are shown. |
67 | .sp | |
ec3624aa | 68 | Note that the old output format (i.e., \fBlosetup -a\fR) with comma-delimited |
c372860d | 69 | strings is deprecated in favour of the \fB--list\fR output format. |
9a94b634 KZ |
70 | .sp |
71 | It's possible to create more independent loop devices for the same backing | |
72 | file. | |
73 | .B This setup may be dangerous, can cause data loss, corruption and overwrites. | |
ec3624aa | 74 | Use \fB\-\-nooverlap\fR with \fB\-\-find\fR during setup to avoid this problem. |
14576644 | 75 | |
fd6b7a7f | 76 | .SH OPTIONS |
c372860d BS |
77 | The \fIsize\fR and \fIoffset\fR |
78 | arguments may be followed by the multiplicative suffixes KiB (=1024), | |
79 | MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is | |
80 | optional, e.g., "K" has the same meaning as "KiB") or the suffixes | |
81 | KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB. | |
ca1e1363 | 82 | |
c372860d BS |
83 | .TP |
84 | .BR \-a , " \-\-all" | |
85 | Show the status of all loop devices. Note that not all information is accessible | |
86 | for non-root users. See also \fB\-\-list\fR. The old output format (as printed | |
87 | without \fB--list)\fR is deprecated. | |
88 | .TP | |
c372860d BS |
89 | .BR \-d , " \-\-detach " \fIloopdev\fR... |
90 | Detach the file or device associated with the specified loop device(s). | |
91 | .TP | |
b06c1ca6 | 92 | .BR \-D , " \-\-detach\-all" |
c372860d BS |
93 | Detach all associated loop devices. |
94 | .TP | |
ec3624aa FG |
95 | .BR \-f , " \-\-find " "\fR[\fIfile\fR]" |
96 | Find the first unused loop device. If a \fIfile\fR argument is present, use | |
97 | the found device as loop device. Otherwise, just print its name. | |
98 | .IP "\fB\-\-show\fP" | |
99 | Display the name of the assigned loop device if the \fB\-f\fP option and a | |
100 | \fIfile\fP argument are present. | |
289619bd | 101 | .TP |
9a94b634 KZ |
102 | .BR \-L , " \-\-nooverlap" |
103 | Check for conflicts between loop devices to avoid situation when the same | |
104 | backing file is shared between more loop devices. If the file is already used | |
105 | by another device then re-use the device rather than a new one. The option | |
106 | makes sense only with \fB\-\-find\fP. | |
107 | .TP | |
ec3624aa FG |
108 | .BR \-j , " \-\-associated " \fIfile\fR " \fR[\fB\-o \fIoffset\fR]" |
109 | Show the status of all loop devices associated with the given \fIfile\fR. | |
c372860d BS |
110 | .TP |
111 | .BR \-o , " \-\-offset " \fIoffset | |
112 | The data start is moved \fIoffset\fP bytes into the specified file or device. | |
ec3624aa FG |
113 | .IP "\fB\-\-sizelimit \fIsize\fP" |
114 | The data end is set to no more than \fIsize\fP bytes after the data start. | |
c372860d | 115 | .TP |
ec3624aa FG |
116 | .BR \-c , " \-\-set\-capacity " \fIloopdev |
117 | Force the loop driver to reread the size of the file associated with the | |
118 | specified loop device. | |
c372860d BS |
119 | .TP |
120 | .BR \-P , " \-\-partscan" | |
121 | Force the kernel to scan the partition table on a newly created loop device. | |
c372860d | 122 | .TP |
b06c1ca6 | 123 | .BR \-r , " \-\-read\-only" |
c372860d | 124 | Set up a read-only loop device. |
ec3624aa FG |
125 | .TP |
126 | .BR \-\-direct\-io [ =on | off ] | |
127 | Enable or disable direct I/O for the backing file. The optional argument | |
128 | can be either \fBon\fR or \fBoff\fR. If the argument is omitted, it defaults | |
129 | to \fBon\fR. | |
c372860d BS |
130 | .TP |
131 | .BR \-v , " \-\-verbose" | |
132 | Verbose mode. | |
133 | .TP | |
ec3624aa FG |
134 | .BR \-l , " \-\-list" |
135 | If a loop device or the \fB-a\fR option is specified, print the default columns | |
136 | for either the specified loop device or all loop devices; the default is to | |
137 | print info about all devices. See also \fB\-\-output\fP, \fB\-\-noheadings\fP, | |
138 | \fB\-\-raw\fP, and \fB\-\-json\fP. | |
139 | .TP | |
140 | .BR \-O , " \-\-output " \fIcolumn\fR[,\fIcolumn\fR]... | |
141 | Specify the columns that are to be printed for the \fB\-\-list\fP output. | |
142 | Use \fB\-\-help\fR to get a list of all supported columns. | |
143 | .TP | |
144 | .BR \-n , " \-\-noheadings" | |
145 | Don't print headings for \fB\-\-list\fP output format. | |
146 | .IP "\fB\-\-raw\fP" | |
147 | Use the raw \fB\-\-list\fP output format. | |
148 | .TP | |
149 | .BR \-J , " \-\-json" | |
150 | Use JSON format for \fB\-\-list\fP output. | |
151 | .TP | |
c372860d BS |
152 | .BR \-V , " \-\-version" |
153 | Display version information and exit. | |
154 | .TP | |
155 | .BR \-h , " \-\-help" | |
156 | Display help text and exit. | |
ba3809b0 | 157 | |
23b85230 | 158 | .SH ENCRYPTION |
c372860d | 159 | .B Cryptoloop is no longer supported in favor of dm-crypt. |
5593132a | 160 | .B For more details see cryptsetup(8). |
23b85230 | 161 | |
66ee8158 KZ |
162 | .SH RETURN VALUE |
163 | .B losetup | |
c372860d | 164 | returns 0 on success, nonzero on failure. When |
66ee8158 KZ |
165 | .B losetup |
166 | displays the status of a loop device, it returns 1 if the device | |
167 | is not configured and 2 if an error occurred which prevented | |
c372860d | 168 | determining the status of the device. |
66ee8158 | 169 | |
fd6b7a7f | 170 | .SH FILES |
23b85230 KZ |
171 | .TP |
172 | .I /dev/loop[0..N] | |
173 | loop block devices | |
174 | .TP | |
0d0d12ad | 175 | .I /dev/loop-control |
23b85230 KZ |
176 | loop control device |
177 | ||
fd6b7a7f | 178 | .SH EXAMPLE |
fd6b7a7f KZ |
179 | The following commands can be used as an example of using the loop device. |
180 | .nf | |
181 | .IP | |
bda26762 | 182 | # dd if=/dev/zero of=~/file.img bs=1024k count=10 |
23b85230 KZ |
183 | # losetup --find --show ~/file.img |
184 | /dev/loop0 | |
185 | # mkfs -t ext2 /dev/loop0 | |
186 | # mount /dev/loop0 /mnt | |
fd6b7a7f | 187 | ... |
d03dd608 | 188 | # umount /dev/loop0 |
23b85230 | 189 | # losetup --detach /dev/loop0 |
fd6b7a7f | 190 | .fi |
0bf03740 KZ |
191 | .SH ENVIRONMENT |
192 | .IP LOOPDEV_DEBUG=all | |
193 | enables debug output. | |
23b85230 | 194 | .SH AUTHORS |
c372860d | 195 | Karel Zak <kzak@redhat.com>, based on the original version from |
23b85230 | 196 | Theodore Ts'o <tytso@athena.mit.edu> |
86d62711 | 197 | .SH AVAILABILITY |
601d12fb | 198 | The losetup command is part of the util-linux package and is available from |
d673b74e | 199 | https://www.kernel.org/pub/linux/utils/util-linux/. |