1LOSETUP(8)                   MAINTENANCE COMMANDS                   LOSETUP(8)
2
3
4

NAME

6       losetup - set up and control loop devices
7

SYNOPSIS

9       Get info:
10
11            losetup loopdev
12
13            losetup -a
14
15            losetup -j file [-o offset]
16
17       Delete loop:
18
19            losetup -d loopdev...
20
21       Print name of first unused loop device:
22
23            losetup -f
24
25       Setup loop device:
26
27            losetup [{-e|-E} encryption] [-o offset] [--sizelimit size]
28                    [-p pfd] [-r] {-f[--show]|loopdev} file
29
30       Resize loop device:
31
32            losetup -c loopdev
33

DESCRIPTION

35       losetup  is  used to associate loop devices with regular files or block
36       devices, to detach loop devices and to  query  the  status  of  a  loop
37       device. If only the loopdev argument is given, the status of the corre‐
38       sponding loop device is shown.
39
40
41   Encryption
42       It is possible to specify transfer functions (for encryption/decryption
43       or  other  purposes) using one of the -E and -e options.  There are two
44       mechanisms to specify the desired encryption: by number and by name. If
45       an encryption is specified by number then one has to make sure that the
46       Linux kernel knows about the encryption with that number,  probably  by
47       patching the kernel. Standard numbers that are always present are 0 (no
48       encryption) and 1 (XOR encryption).   When  the  cryptoloop  module  is
49       loaded  (or  compiled  in),  it uses number 18.  This cryptoloop module
50       will take the name of an arbitrary encryption type and find the  module
51       that knows how to perform that encryption.
52

OPTIONS

54       The  size and offset arguments may be followed by binary (2^N) suffixes
55       KiB, MiB, GiB, TiB, PiB and EiB (the "iB" is optional, e.g. "K" has the
56       same  meaning  as  "KiB") or decimal (10^N) suffixes KB, MB, GB, PB and
57       EB.
58
59
60       -a, --all
61              show status of all loop devices
62
63       -c, --set-capacity loopdev
64              force loop driver to reread size of the file associated with the
65              specified loop device
66
67       -d, --detach loopdev...
68              detach  the  file  or  device associated with the specified loop
69              device(s)
70
71       -e, -E, --encryption encryption_type
72              enable data encryption with specified name or number
73
74       -f, --find
75              find the first  unused  loop  device.  If  a  file  argument  is
76              present, use this device. Otherwise, print its name
77
78       -h, --help
79              print help
80
81       -j, --associated file
82              show status of all loop devices associated with given file
83
84       -o, --offset offset
85              the  data start is moved offset bytes into the specified file or
86              device
87
88       --sizelimit size
89              the data end is set to no more than size bytes  after  the  data
90              start
91
92       -p, --pass-fd num
93              read the passphrase from file descriptor with number num instead
94              of from the terminal
95
96       -r, --read-only
97              setup read-only loop device
98
99       --show print device name if the -f  option  and  a  file  argument  are
100              present.
101
102              The  short  form  of this option (-s) is deprecated.  This short
103              form could be in collision with  Loop-AES  implementation  where
104              the same option is used for --sizelimit.
105
106       -v, --verbose
107              verbose mode
108
109

RETURN VALUE

111       losetup returns 0 on success, nonzero on failure. When losetup displays
112       the status of a loop device, it returns 1 if the device is not  config‐
113       ured  and 2 if an error occurred which prevented losetup from determin‐
114       ing the status of the device.
115
116

FILES

118       /dev/loop0, /dev/loop1, ...   loop devices (major=7)
119

EXAMPLE

121       If you are using the loadable module you must have  the  module  loaded
122       first with the command
123
124              # modprobe loop
125
126       Maybe also encryption modules are needed.
127
128              # modprobe des # modprobe cryptoloop
129
130       The  following  commands  can  be  used as an example of using the loop
131       device.
132
133              # dd if=/dev/zero of=/file bs=1k count=100
134              # losetup -e des /dev/loop0 /file
135              Password:
136              Init (up to 16 hex digits):
137              # mkfs -t ext2 /dev/loop0 100
138              # mount -t ext2 /dev/loop0 /mnt
139               ...
140              # umount /dev/loop0
141              # losetup -d /dev/loop0
142
143       If you are using the loadable module you may remove the module with the
144       command
145
146              # rmmod loop
147

RESTRICTION

149       DES  encryption  is  painfully slow. On the other hand, XOR is terribly
150       weak.
151
152       Cryptoloop is deprecated in favor of dm-crypt.  For  more  details  see
153       cryptsetup(8).
154

AVAILABILITY

156       The  losetup command is part of the util-linux-ng package and is avail‐
157       able from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
158
159
160
161Linux                             2003-07-01                        LOSETUP(8)
Impressum