1LOSETUP(8) System Administration LOSETUP(8)
2
3
4
6 losetup - set up and control loop devices
7
9 Get info:
10
11 losetup loopdev
12
13 losetup -l [-a]
14
15 losetup -j file [-o offset]
16
17 Delete loop:
18
19 losetup -d loopdev...
20
21 Delete all used loop devices:
22
23 losetup -D
24
25 Print name of first unused loop device:
26
27 losetup -f
28
29 Set up a loop device:
30
31 losetup [-o offset] [--sizelimit size]
32 [-Pr] [--show] -f|loopdev file
33
34 Resize loop device:
35
36 losetup -c loopdev
37
39 losetup is used to associate loop devices with regular files or block
40 devices, to detach loop devices and to query the status of a loop
41 device. If only the loopdev argument is given, the status of the corre‐
42 sponding loop device is shown.
43
44 Note that the old output format (e.g. losetup -a) with comma delimited
45 strings is deprecated in favour of the --list output format (e.g. los‐
46 etup -a -l).
47
49 +The size and offset arguments may be followed by the multiplicative
50 +suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB,
51 ZiB and YiB +(the "iB" is optional, e.g. "K" has the same meaning as
52 "KiB") or the suffixes +KB=1000, MB=1000*1000, and so on for GB, TB,
53 PB, EB, ZB and YB.
54
55
56 -a, --all
57 show status of all loop devices. Note that not all information
58 are accessible for non-root users. See also --list. The old out‐
59 put format (as printed without --list) is deprecated.
60
61 -c, --set-capacity loopdev
62 force loop driver to reread size of the file associated with the
63 specified loop device
64
65 -d, --detach loopdev...
66 detach the file or device associated with the specified loop
67 device(s). Note that since Linux v3.7 kernel uses "lazy device
68 destruction". The detach operation does not return EBUSY error
69 anymore if device is actively used by system, but it is marked
70 by autoclear flag and destroyed later.
71
72 -D, --detach-all
73 detach all associated loop devices
74
75 -f, --find
76 find the first unused loop device. If a file argument is
77 present, use this device. Otherwise, print its name
78
79 -h, --help
80 print help
81
82 -j, --associated file
83 show status of all loop devices associated with given file
84
85 -l, --list
86 if a loop device or the -a option is specified, print default
87 columns for either the specified loop device or all loop
88 devices, default is to print info about all devices.
89
90 -o, --offset offset
91 the data start is moved offset bytes into the specified file or
92 device
93
94 -O, --output columns
95 specify which columns are to be printed for the --list output
96
97 --sizelimit size
98 the data end is set to no more than size bytes after the data
99 start
100
101 -P, --partscan
102 force kernel to scan partition table on newly created loop
103 device
104
105 -r, --read-only
106 setup read-only loop device
107
108 --show print device name if the -f option and a file argument are
109 present.
110
111 -v, --verbose
112 verbose mode
113
114
116 Cryptoloop is no longer supported in favor of dm-crypt. For more
117 details see cryptsetup(8).
118
119
121 losetup returns 0 on success, nonzero on failure. When losetup displays
122 the status of a loop device, it returns 1 if the device is not config‐
123 ured and 2 if an error occurred which prevented from determining the
124 status of the device.
125
126
128 /dev/loop[0..N]
129 loop block devices
130
131 /dev/loop-cotrol
132 loop control device
133
134
136 The following commands can be used as an example of using the loop
137 device.
138
139 # dd if=/dev/zero of=~/file.img bs=1MiB count=10
140 # losetup --find --show ~/file.img
141 /dev/loop0
142 # mkfs -t ext2 /dev/loop0
143 # mount /dev/loop0 /mnt
144 ...
145 # umount /dev/loop0
146 # losetup --detach /dev/loop0
147
149 Karel Zak <kzak@redhat.com>, based on original version from Theodore
150 Ts'o <tytso@athena.mit.edu>
151
153 The losetup command is part of the util-linux package and is available
154 from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
155
156
157
158util-linux July 2003 LOSETUP(8)