-
Notifications
You must be signed in to change notification settings - Fork 5
/
t
163 lines (110 loc) · 9.13 KB
/
t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
LOSETUP(8) System Administration LOSETUP(8)
NNAAMMEE
losetup - set up and control loop devices
SSYYNNOOPPSSIISS
Get info:
lloosseettuupp [_l_o_o_p_d_e_v]
lloosseettuupp --ll [--aa]
lloosseettuupp --jj _f_i_l_e [--oo _o_f_f_s_e_t]
Detach a loop device:
lloosseettuupp --dd _l_o_o_p_d_e_v ...
Detach all associated loop devices:
lloosseettuupp --DD
Set up a loop device:
lloosseettuupp [--oo _o_f_f_s_e_t] [----ssiizzeelliimmiitt _s_i_z_e] [----sseeccttoorr--ssiizzee _s_i_z_e] [--PPrr] [----sshhooww] --ff _l_o_o_p_d_e_v _f_i_l_e
Resize a loop device:
lloosseettuupp --cc _l_o_o_p_d_e_v
DDEESSCCRRIIPPTTIIOONN
lloosseettuupp is used to associate loop devices with regular files or block devices, to detach loop devices, and to query the status of a loop device. If only the _l_o_o_p_d_e_v argument is given, the status of
the corresponding loop device is shown. If no option is given, all loop devices are shown.
Note that the old output format (i.e., lloosseettuupp --aa) with comma-delimited strings is deprecated in favour of the ----lliisstt output format.
It’s possible to create more independent loop devices for the same backing file. TThhiiss sseettuupp mmaayy bbee ddaannggeerroouuss,, ccaann ccaauussee ddaattaa lloossss,, ccoorrrruuppttiioonn aanndd oovveerrwwrriitteess.. Use ----nnoooovveerrllaapp with ----ffiinndd during setup
to avoid this problem.
The loop device setup is not an atomic operation when used with ----ffiinndd, and lloosseettuupp does not protect this operation by any lock. The number of attempts is internally restricted to a maximum of 16.
It is recommended to use for example flock1 to avoid a collision in heavily parallel use cases.
OOPPTTIIOONNSS
The _s_i_z_e and _o_f_f_s_e_t arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the
same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
--aa, ----aallll
Show the status of all loop devices. Note that not all information is accessible for non-root users. See also ----lliisstt. The old output format (as printed without ----lliisstt)) is deprecated.
--dd, ----ddeettaacchh _l_o_o_p_d_e_v...
Detach the file or device associated with the specified loop device(s). Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not return EEBBUUSSYY error anymore
if device is actively used by system, but it is marked by autoclear flag and destroyed later.
--DD, ----ddeettaacchh--aallll
Detach all associated loop devices.
--ff, ----ffiinndd [_f_i_l_e]
Find the first unused loop device. If a _f_i_l_e argument is present, use the found device as loop device. Otherwise, just print its name.
----sshhooww
Display the name of the assigned loop device if the --ff option and a _f_i_l_e argument are present.
--LL, ----nnoooovveerrllaapp
Check for conflicts between loop devices to avoid situation when the same backing file is shared between more loop devices. If the file is already used by another device then re-use the device
rather than a new one. The option makes sense only with ----ffiinndd.
--jj, ----aassssoocciiaatteedd _f_i_l_e [--oo _o_f_f_s_e_t]
Show the status of all loop devices associated with the given _f_i_l_e.
--oo, ----ooffffsseett _o_f_f_s_e_t
The data start is moved _o_f_f_s_e_t bytes into the specified file or device. The _o_f_f_s_e_t may be followed by the multiplicative suffixes; see above.
----ssiizzeelliimmiitt _s_i_z_e
The data end is set to no more than _s_i_z_e bytes after the data start. The _s_i_z_e may be followed by the multiplicative suffixes; see above.
--bb, ----sseeccttoorr--ssiizzee _s_i_z_e
Set the logical sector size of the loop device in bytes (since Linux 4.14). The option may be used when create a new loop device as well as stand-alone command to modify sector size of the
already existing loop device.
--cc, ----sseett--ccaappaacciittyy _l_o_o_p_d_e_v
Force the loop driver to reread the size of the file associated with the specified loop device.
--PP, ----ppaarrttssccaann
Force the kernel to scan the partition table on a newly created loop device. Note that the partition table parsing depends on sector sizes. The default is sector size is 512 bytes, otherwise you
need to use the option ----sseeccttoorr--ssiizzee together with ----ppaarrttssccaann.
--rr, ----rreeaadd--oonnllyy
Set up a read-only loop device.
----ddiirreecctt--iioo[==oonn|ooffff]
Enable or disable direct I/O for the backing file. The optional argument can be either oonn or ooffff. If the argument is omitted, it defaults to ooffff.
--vv, ----vveerrbboossee
Verbose mode.
--ll, ----lliisstt
If a loop device or the --aa option is specified, print the default columns for either the specified loop device or all loop devices; the default is to print info about all devices. See also
----oouuttppuutt, ----nnoohheeaaddiinnggss, ----rraaww, and ----jjssoonn.
--OO, ----oouuttppuutt _c_o_l_u_m_n[,_c_o_l_u_m_n]...
Specify the columns that are to be printed for the ----lliisstt output. Use ----hheellpp to get a list of all supported columns.
----oouuttppuutt--aallll
Output all available columns.
--nn, ----nnoohheeaaddiinnggss
Don’t print headings for ----lliisstt output format.
----rraaww
Use the raw ----lliisstt output format.
--JJ, ----jjssoonn
Use JSON format for ----lliisstt output.
--VV, ----vveerrssiioonn
Display version information and exit.
--hh, ----hheellpp
Display help text and exit.
EENNCCRRYYPPTTIIOONN
CCrryyppttoolloooopp iiss nnoo lloonnggeerr ssuuppppoorrtteedd iinn ffaavvoorr ooff ddmm--ccrryypptt.. For more details see ccrryyppttsseettuupp(8).
EEXXIITT SSTTAATTUUSS
lloosseettuupp returns 0 on success, nonzero on failure. When lloosseettuupp displays the status of a loop device, it returns 1 if the device is not configured and 2 if an error occurred which prevented
determining the status of the device.
NNOOTTEESS
Since version 2.37 lloosseettuupp uses LLOOOOPP__CCOONNFFIIGGUURREE ioctl to setup a new loop device by one ioctl call. The old versions use LLOOOOPP__SSEETT__FFDD and LLOOOOPP__SSEETT__SSTTAATTUUSS6644 ioctls to do the same.
EENNVVIIRROONNMMEENNTT
LOOPDEV_DEBUG=all
enables debug output.
FFIILLEESS
_/_d_e_v_/_l_o_o_p_[_0_._._N_]
loop block devices
_/_d_e_v_/_l_o_o_p_-_c_o_n_t_r_o_l
loop control device
EEXXAAMMPPLLEE
The following commands can be used as an example of using the loop device.
# dd if=/dev/zero of=~/file.img bs=1024k count=10
# losetup --find --show ~/file.img
/dev/loop0
# mkfs -t ext2 /dev/loop0
# mount /dev/loop0 /mnt
...
# umount /dev/loop0
# losetup --detach /dev/loop0
AAUUTTHHOORRSS
Karel Zak <[email protected]>, based on the original version from Theodore Ts’o <[email protected]>.
RREEPPOORRTTIINNGG BBUUGGSS
For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.
AAVVAAIILLAABBIILLIITTYY
The lloosseettuupp command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.
util-linux 2.37.2 2021-06-02 LOSETUP(8)