logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

losetup.8 (8158B)


  1. '\" t
  2. .\" Title: losetup
  3. .\" Author: [see the "AUTHOR(S)" section]
  4. .\" Generator: Asciidoctor 2.0.15
  5. .\" Date: 2021-06-01
  6. .\" Manual: System Administration
  7. .\" Source: util-linux {release-version}
  8. .\" Language: English
  9. .\"
  10. .TH "LOSETUP" "8" "2021-06-01" "util\-linux {release\-version}" "System Administration"
  11. .ie \n(.g .ds Aq \(aq
  12. .el .ds Aq '
  13. .ss \n[.ss] 0
  14. .nh
  15. .ad l
  16. .de URL
  17. \fI\\$2\fP <\\$1>\\$3
  18. ..
  19. .als MTO URL
  20. .if \n[.g] \{\
  21. . mso www.tmac
  22. . am URL
  23. . ad l
  24. . .
  25. . am MTO
  26. . ad l
  27. . .
  28. . LINKSTYLE blue R < >
  29. .\}
  30. .SH "NAME"
  31. losetup \- set up and control loop devices
  32. .SH "SYNOPSIS"
  33. .sp
  34. Get info:
  35. .sp
  36. \fBlosetup\fP [\fIloopdev\fP]
  37. .sp
  38. \fBlosetup\fP \fB\-l\fP [\fB\-a\fP]
  39. .sp
  40. \fBlosetup\fP \fB\-j\fP \fIfile\fP [\fB\-o\fP \fIoffset\fP]
  41. .sp
  42. Detach a loop device:
  43. .sp
  44. \fBlosetup\fP \fB\-d\fP \fIloopdev\fP ...
  45. .sp
  46. Detach all associated loop devices:
  47. .sp
  48. \fBlosetup\fP \fB\-D\fP
  49. .sp
  50. Set up a loop device:
  51. .sp
  52. \fBlosetup\fP [\fB\-o\fP \fIoffset\fP] [\fB\-\-sizelimit\fP \fIsize\fP] [\fB\-\-sector\-size\fP \fIsize\fP] [\fB\-Pr\fP] [\fB\-\-show\fP] \fB\-f\fP \fIloopdev file\fP
  53. .sp
  54. Resize a loop device:
  55. .sp
  56. \fBlosetup\fP \fB\-c\fP \fIloopdev\fP
  57. .SH "DESCRIPTION"
  58. .sp
  59. \fBlosetup\fP 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 \fIloopdev\fP argument is given, the status of the corresponding loop device is shown. If no option is given, all loop devices are shown.
  60. .sp
  61. Note that the old output format (i.e., \fBlosetup \-a\fP) with comma\-delimited strings is deprecated in favour of the \fB\-\-list\fP output format.
  62. .sp
  63. It\(cqs possible to create more independent loop devices for the same backing file. \fBThis setup may be dangerous, can cause data loss, corruption and overwrites.\fP Use \fB\-\-nooverlap\fP with \fB\-\-find\fP during setup to avoid this problem.
  64. .sp
  65. The loop device setup is not an atomic operation when used with \fB\-\-find\fP, and \fBlosetup\fP 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.
  66. .SH "OPTIONS"
  67. .sp
  68. The \fIsize\fP and \fIoffset\fP 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.
  69. .sp
  70. \fB\-a\fP, \fB\-\-all\fP
  71. .RS 4
  72. Show the status of all loop devices. Note that not all information is accessible for non\-root users. See also \fB\-\-list\fP. The old output format (as printed without \fB\-\-list)\fP is deprecated.
  73. .RE
  74. .sp
  75. \fB\-d\fP, \fB\-\-detach\fP \fIloopdev\fP...
  76. .RS 4
  77. 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 \fBEBUSY\fP error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later.
  78. .RE
  79. .sp
  80. \fB\-D\fP, \fB\-\-detach\-all\fP
  81. .RS 4
  82. Detach all associated loop devices.
  83. .RE
  84. .sp
  85. \fB\-f\fP, \fB\-\-find\fP [\fIfile\fP]
  86. .RS 4
  87. Find the first unused loop device. If a \fIfile\fP argument is present, use the found device as loop device. Otherwise, just print its name.
  88. .RE
  89. .sp
  90. \fB\-\-show\fP
  91. .RS 4
  92. Display the name of the assigned loop device if the \fB\-f\fP option and a \fIfile\fP argument are present.
  93. .RE
  94. .sp
  95. \fB\-L\fP, \fB\-\-nooverlap\fP
  96. .RS 4
  97. 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 \fB\-\-find\fP.
  98. .RE
  99. .sp
  100. \fB\-j\fP, \fB\-\-associated\fP \fIfile\fP [\fB\-o\fP \fIoffset\fP]
  101. .RS 4
  102. Show the status of all loop devices associated with the given \fIfile\fP.
  103. .RE
  104. .sp
  105. \fB\-o\fP, \fB\-\-offset\fP \fIoffset\fP
  106. .RS 4
  107. The data start is moved \fIoffset\fP bytes into the specified file or device. The \fIoffset\fP may be followed by the multiplicative suffixes; see above.
  108. .RE
  109. .sp
  110. \fB\-\-sizelimit\fP \fIsize\fP
  111. .RS 4
  112. The data end is set to no more than \fIsize\fP bytes after the data start. The \fIsize\fP may be followed by the multiplicative suffixes; see above.
  113. .RE
  114. .sp
  115. \fB\-b\fP, \fB\-\-sector\-size\fP \fIsize\fP
  116. .RS 4
  117. 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.
  118. .RE
  119. .sp
  120. \fB\-c\fP, \fB\-\-set\-capacity\fP \fIloopdev\fP
  121. .RS 4
  122. Force the loop driver to reread the size of the file associated with the specified loop device.
  123. .RE
  124. .sp
  125. \fB\-P\fP, \fB\-\-partscan\fP
  126. .RS 4
  127. 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 \fB\-\-sector\-size\fP together with \fB\-\-partscan\fP.
  128. .RE
  129. .sp
  130. \fB\-r\fP, \fB\-\-read\-only\fP
  131. .RS 4
  132. Set up a read\-only loop device.
  133. .RE
  134. .sp
  135. \fB\-\-direct\-io\fP[\fB=on\fP|\fBoff\fP]
  136. .RS 4
  137. Enable or disable direct I/O for the backing file. The optional argument can be either \fBon\fP or \fBoff\fP. If the argument is omitted, it defaults to \fBoff\fP.
  138. .RE
  139. .sp
  140. \fB\-v\fP, \fB\-\-verbose\fP
  141. .RS 4
  142. Verbose mode.
  143. .RE
  144. .sp
  145. \fB\-l\fP, \fB\-\-list\fP
  146. .RS 4
  147. If a loop device or the \fB\-a\fP 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 \fB\-\-output\fP, \fB\-\-noheadings\fP, \fB\-\-raw\fP, and \fB\-\-json\fP.
  148. .RE
  149. .sp
  150. \fB\-O\fP, \fB\-\-output\fP \fIcolumn\fP[,\fIcolumn\fP]...
  151. .RS 4
  152. Specify the columns that are to be printed for the \fB\-\-list\fP output. Use \fB\-\-help\fP to get a list of all supported columns.
  153. .RE
  154. .sp
  155. \fB\-\-output\-all\fP
  156. .RS 4
  157. Output all available columns.
  158. .RE
  159. .sp
  160. \fB\-n\fP, \fB\-\-noheadings\fP
  161. .RS 4
  162. Don\(cqt print headings for \fB\-\-list\fP output format.
  163. .RE
  164. .sp
  165. \fB\-\-raw\fP
  166. .RS 4
  167. Use the raw \fB\-\-list\fP output format.
  168. .RE
  169. .sp
  170. \fB\-J\fP, \fB\-\-json\fP
  171. .RS 4
  172. Use JSON format for \fB\-\-list\fP output.
  173. .RE
  174. .sp
  175. \fB\-V\fP, \fB\-\-version\fP
  176. .RS 4
  177. Display version information and exit.
  178. .RE
  179. .sp
  180. \fB\-h\fP, \fB\-\-help\fP
  181. .RS 4
  182. Display help text and exit.
  183. .RE
  184. .SH "ENCRYPTION"
  185. .sp
  186. \fBCryptoloop is no longer supported in favor of dm\-crypt.\fP For more details see \fBcryptsetup\fP(8).
  187. .SH "EXIT STATUS"
  188. .sp
  189. \fBlosetup\fP returns 0 on success, nonzero on failure. When \fBlosetup\fP 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.
  190. .SH "NOTES"
  191. .sp
  192. Since version 2.37 \fBlosetup\fP uses \fBLOOP_CONFIGURE\fP ioctl to setup a new loop device by one ioctl call. The old versions use \fBLOOP_SET_FD\fP and \fBLOOP_SET_STATUS64\fP ioctls to do the same.
  193. .SH "ENVIRONMENT"
  194. .sp
  195. LOOPDEV_DEBUG=all
  196. .RS 4
  197. enables debug output.
  198. .RE
  199. .SH "FILES"
  200. .sp
  201. \fI/dev/loop[0..N]\fP
  202. .RS 4
  203. loop block devices
  204. .RE
  205. .sp
  206. \fI/dev/loop\-control\fP
  207. .RS 4
  208. loop control device
  209. .RE
  210. .SH "EXAMPLE"
  211. .sp
  212. The following commands can be used as an example of using the loop device.
  213. .sp
  214. .if n .RS 4
  215. .nf
  216. .fam C
  217. # dd if=/dev/zero of=~/file.img bs=1024k count=10
  218. # losetup \-\-find \-\-show ~/file.img
  219. /dev/loop0
  220. # mkfs \-t ext2 /dev/loop0
  221. # mount /dev/loop0 /mnt
  222. \&...
  223. # umount /dev/loop0
  224. # losetup \-\-detach /dev/loop0
  225. .fam
  226. .fi
  227. .if n .RE
  228. .SH "AUTHORS"
  229. .sp
  230. .MTO "kzak\(atredhat.com" "Karel Zak" ","
  231. based on the original version from
  232. .MTO "tytso\(atathena.mit.edu" "Theodore Ts\(cqo" "."
  233. .SH "REPORTING BUGS"
  234. .sp
  235. For bug reports, use the issue tracker at \c
  236. .URL "https://github.com/karelzak/util\-linux/issues" "" "."
  237. .SH "AVAILABILITY"
  238. .sp
  239. The \fBlosetup\fP command is part of the util\-linux package which can be downloaded from \c
  240. .URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."