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 limit]
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       -a, --all
55              show status of all loop devices
56
57       -c, --set-capacity loopdev
58              force loop driver to reread size of the file associated with the
59              specified loop device
60
61       -d, --detach loopdev...
62              detach the file or device associated  with  the  specified  loop
63              device(s)
64
65       -e, -E, --encryption encryption_type
66              enable data encryption with specified name or number
67
68       -f, --find
69              find  the  first  unused  loop  device.  If  a  file argument is
70              present, use this device. Otherwise, print its name
71
72       -h, --help
73              print help
74
75       -j, --associated file
76              show status of all loop devices associated with given file
77
78       -o, --offset offset
79              the data start is moved offset bytes into the specified file  or
80              device
81
82       --sizelimit limit
83              the  data  end  is set to no more than sizelimit bytes after the
84              data start
85
86       -p, --pass-fd num
87              read the passphrase from file descriptor with number num instead
88              of from the terminal
89
90       -r, --read-only
91              setup read-only loop device
92
93       --show print  device  name  if  the  -f  option and a file argument are
94              present.
95
96              The short form of this option (-s) is  deprecated.   This  short
97              form  could  be  in collision with Loop-AES implementation where
98              the same option is used for --sizelimit.
99
100       -v, --verbose
101              verbose mode
102
103

RETURN VALUE

105       losetup returns 0 on success, nonzero on failure. When losetup displays
106       the  status of a loop device, it returns 1 if the device is not config‐
107       ured and 2 if an error occurred which prevented losetup from  determin‐
108       ing the status of the device.
109
110

FILES

112       /dev/loop0, /dev/loop1, ...   loop devices (major=7)
113

EXAMPLE

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

RESTRICTION

143       DES encryption is painfully slow. On the other hand,  XOR  is  terribly
144       weak.
145
146       Cryptoloop  is  deprecated  in  favor of dm-crypt. For more details see
147       cryptsetup(8).
148

AVAILABILITY

150       The losetup command is part of the util-linux-ng package and is  avail‐
151       able from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
152
153
154
155Linux                             2003-07-01                        LOSETUP(8)
Impressum