luksmeta.8 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. .\" generated with Ronn/v0.7.3
  2. .\" http://github.com/rtomayko/ronn/tree/0.7.3
  3. .
  4. .TH "LUKSMETA" "1" "June 2017" "" ""
  5. .
  6. .SH "NAME"
  7. \fBluksmeta\fR \- Utility for storing metadata in a LUKSv1 header
  8. .
  9. .SH "SYNOPSIS"
  10. \fBluksmeta test\fR \-d DEVICE
  11. .
  12. .P
  13. \fBluksmeta nuke\fR \-d DEVICE [\-f]
  14. .
  15. .P
  16. \fBluksmeta init\fR \-d DEVICE [\-f] [\-n]
  17. .
  18. .P
  19. \fBluksmeta show\fR \-d DEVICE [\-s SLOT]
  20. .
  21. .P
  22. \fBluksmeta save\fR \-d DEVICE [\-s SLOT] \-u UUID \fIDATA\fR
  23. .
  24. .P
  25. \fBluksmeta load\fR \-d DEVICE \-s SLOT [\-u UUID] DATA
  26. .
  27. .P
  28. \fBluksmeta wipe\fR \-d DEVICE \-s SLOT [\-u UUID] [\-f]
  29. .
  30. .SH "OVERVIEW"
  31. The \fBluksmeta\fR utility enables an administrator to store metadata in the gap between the end of the LUKSv1 header and the start of the encrypted data\. This is useful for storing data that is available before the volume is unlocked, usually for use during the volume unlock process\.
  32. .
  33. .P
  34. The metadata is stored in a series of UUID\-typed slots, allowing multiple blocks of metadata\. Although the \fBluksmeta\fR slots are inspired by the LUKS slots, they are functionally independent and share only a casual relationship\. Slots merely provide a hint that a given chunk of metadata is associated with a specific LUKSv1 password (in a slot with the same number)\. However, \fBluksmeta\fR itself is indifferent to the relationship between a LUKSv1 slot and the correspondly numbered \fBluksmeta\fR slot, with one exception (detailed below)\.
  35. .
  36. .P
  37. After a LUKSv1 volume is initialized using \fBcryptsetup\fR(8), it must also be initialized for metadata storage by \fBluksmeta init\fR\. Once this is complete, the device is ready to store medata\.
  38. .
  39. .P
  40. Data can be written to a slot using \fBluksmeta save\fR or read from a slot using \fBluksmeta load\fR\. You can also erase the data in an existing slot using \fBluksmeta wipe\fR or query the slots using \fBluksmeta show\fR\.
  41. .
  42. .SH "UUID GENERATION"
  43. It is often presumed that saving metadata to a slot requires a specific UUID or that there is an official registry of UUID types\. This is incorrect\.
  44. .
  45. .P
  46. UUID stands for Universally Unique IDentifier\. UUIDs are a standardized, widely\-used data type used for identification without a central registry\. For the relevant standards, see ISO 9834\-8:2005 and RFC 4122\.
  47. .
  48. .P
  49. UUIDs are large enough that collision is practically impossible\. So if your application wants to store data in a \fBluksmeta\fR slot, just generate your own UUID and use it consistently to refer to your type of data\. If you have multiple types of data, feel free to generate multiple UUIDs\.
  50. .
  51. .P
  52. The easiest way to generate a UUID is to use \fBuuidgen\fR(1)\. However, any compliant UUID generator will suffice\.
  53. .
  54. .SH "INITIALIZATION"
  55. Before reading or writing metadata, the LUKSv1 block device must be initialized for metadata storage\. Three commands help with this process: \fBluksmeta test\fR, \fBluksmeta nuke\fR and \fBluksmeta init\fR\.
  56. .
  57. .P
  58. The \fBluksmeta test\fR command simply checks an existing block device to see if it is initialized for metadata storage\. This command does not provide any output, so be sure to check its return code (see below)\.
  59. .
  60. .P
  61. The \fBluksmeta nuke\fR command will zero (erase) the entire LUKSv1 header gap\. Since this operation is destructive, user confirmation will be required before clearing the gap unless the \fB\-f\fR option is supplied\.
  62. .
  63. .P
  64. The \fBluksmeta init\fR command initializes the LUKSv1 block device for metadata storage\. This process will wipe out any data in the LUKSv1 header gap\. For this reason, this command will require user confirmation before any data is written unless the \fB\-f\fR option is supplied\. Note that this command succeeds without any modification if the device is already initialized\. If you would like to force the creation of clean initialization state, you can specify the \fB\-n\fR option to nuke the LUKSv1 header gap before initialization (but after user confirmation)\.
  65. .
  66. .SH "METADATA STATE"
  67. The \fBluksmeta show\fR command displays the current state of slots on the LUKSv1 block device\. If no slot is specified, it prints a table consisting of the slot number, the corresponding LUKSv1 slot state and the UUID of the data stored in the \fBluksmeta\fR slot (or "empty" if no data is stored)\. If a slot is specified, this command simply prints out the UUID of the data in the slot\. If the slot does not contain data, it prints nothing\.
  68. .
  69. .SH "MANAGING METADATA"
  70. Managing the metadata in the slots is performed with three commands: \fBluksmeta save\fR, \fBluksmeta load\fR and \fBluksmeta wipe\fR\. These commands write metadata to a slot, read metadata from a slot and erase metadata in a slot, respectively\.
  71. .
  72. .P
  73. The \fBluksmeta save\fR command reads metadata on standard input and writes it to the specified slot using the specified UUID\. If no slot is specified, \fBluksmeta\fR will search for the first slot number for which the LUKSv1 slot is inactive and the \fBluksmeta\fR slot is empty\. This represents the only official correlation between LUKSv1 slots and \fBluksmeta\fR slots\. In this case, the metadata is written to the first applicable slot using the specified UUID and the slot number is printed to standard output\. In either case, this command will never overwrite existing data\. To replace data in a slot you will need to execute \fBluksmeta wipe\fR before \fBluksmeta save\fR\.
  74. .
  75. .P
  76. The \fBluksmeta load\fR command reads data from the specified slot and writes it to standard output\. If a UUID is specified, the command will verify that the UUID associated with the metadata in the slot matches the specified UUID\. This type check helps to ensure that you always receive the type of data you are expecting as output\. If the UUIDs do not match, the command will fail\.
  77. .
  78. .P
  79. The \fBluksmeta wipe\fR command erases the data from the given slot\. If a UUID is specified, the command will verify that the UUID associated with the metadata in the slot matches the specified UUID\. This type check helps to ensure that you only erase the data you intended to erase\. Because this is a destructive operation, this command will require user confirmation before any data is erased, unless the \fB\-f\fR option is supplied\. Note that this command succeeds if you attempt to wipe a slot that is already empty\.
  80. .
  81. .SH "CAVEATS"
  82. The amount of storage in the LUKSv1 header gap is extremely limited\. It also varies based upon the configuration used by LUKSv1 at device initialization time\. In some LUKSv1 configurations, there is not even enough space for all the metadata slots even at the smallest possible slot size\.
  83. .
  84. .P
  85. During the design of this utility, we considered it likely that users would want to reduce the number of usable slots in exchange for more storage space in the slots used\. In order to provide this flexibility, the amount of storage available per\-slot is dynamic\. Put simply, slots are not a fixed size\. This means that it is possible (and even somewhat likely) to encounter an error during \fBluksmeta save\fR indicating that there is insufficient space\.
  86. .
  87. .P
  88. This error is not a programming bug\. If you encounter this error it likely means that either all space is being consumed by the already\-written slots or that the metadata you are attempting to write simply does not fit\.
  89. .
  90. .P
  91. You can attempt to resolve this problem by calling \fBluksmeta wipe\fR on slots that are no longer in use\. This will release the storage space for use by other slots\. Note that \fBluksmeta\fR does not, however, currently perform defragmentation since the number of usable blocks is rather limited\. You can attempt to manually get around this by extracting all slot data, wiping the slots and reloading them in order\. However, this operation is potentially dangerous and should be undertaken with great care\.
  92. .
  93. .SH "OPTIONS"
  94. .
  95. .TP
  96. \fB\-d\fR \fIDEVICE\fR, \fB\-\-device\fR=\fIDEVICE\fR
  97. The device on which to perform the operation\.
  98. .
  99. .TP
  100. \fB\-s\fR \fISLOT\fR, \fB\-\-slot\fR=\fISLOT\fR
  101. The slot number on which to perform the operation\.
  102. .
  103. .TP
  104. \fB\-u\fR \fIUUID\fR, \fB\-\-uuid\fR=\fIUUID\fR
  105. The UUID to associate with the operation\.
  106. .
  107. .TP
  108. \fB\-f\fR, \fB\-\-force\fR
  109. Forcibly suppress all user prompting\.
  110. .
  111. .SH "RETURN VALUES"
  112. This command uses the return values as defined by \fBsysexit\.h\fR\. The following are general errors whose meaning is shared by all \fBluksmeta\fR commands:
  113. .
  114. .IP "\(bu" 4
  115. \fBEX_OK\fR : The operation was successful\.
  116. .
  117. .IP "\(bu" 4
  118. \fBEX_OSERR\fR : An undefined operating system error occurred\.
  119. .
  120. .IP "\(bu" 4
  121. \fBEX_USAGE\fR : The program was called with invalid parameters\.
  122. .
  123. .IP "\(bu" 4
  124. \fBEX_IOERR\fR : An IO error occurred when writing to the device\.
  125. .
  126. .IP "\(bu" 4
  127. \fBEX_OSFILE\fR : The device is not initialized or is corrupted\.
  128. .
  129. .IP "\(bu" 4
  130. \fBEX_NOPERM\fR : The user did not grant permission during confirmation\.
  131. .
  132. .IP "\(bu" 4
  133. \fBEX_NOINPUT\fR : An error occured while reading from standard input\.
  134. .
  135. .IP "\(bu" 4
  136. \fBEX_DATAERR\fR : The specified UUID does not match the slot UUID\.
  137. .
  138. .IP "\(bu" 4
  139. \fBEX_CANTCREAT\fR : There is insufficient space in LUKSv1 header\.
  140. .
  141. .IP "" 0
  142. .
  143. .P
  144. Additionally, \fBluksmeta save\fR will return \fBEX_UNAVAILABLE\fR when you attempt to save data into a slot that is already used\. Likewise, \fBluksmeta load\fR will return \fBEX_UNAVAILABLE\fR when you attempt to read from an empty slot\.
  145. .
  146. .SH "EXAMPLES"
  147. Destroy all data (including LUKSMeta data) in the LUKSv1 header gap and initalize the gap for LUKSMeta storage:
  148. .
  149. .IP "" 4
  150. .
  151. .nf
  152. $ luksmeta init \-n \-f \-d /dev/sdz
  153. .
  154. .fi
  155. .
  156. .IP "" 0
  157. .
  158. .P
  159. If already initialized, do nothing\. Otherwise, destroy all non\-LUKSMeta data in the LUKSv1 header gap and initialize the gap for LUKSMeta storage:
  160. .
  161. .IP "" 4
  162. .
  163. .nf
  164. $ luksmeta init \-f \-d /dev/sdz
  165. .
  166. .fi
  167. .
  168. .IP "" 0
  169. .
  170. .P
  171. Write some data to a slot:
  172. .
  173. .IP "" 4
  174. .
  175. .nf
  176. $ UUID=`uuidgen`
  177. $ echo $UUID
  178. 31c25e3b\-b8e2\-4eaa\-a427\-23aa882feef2
  179. $ echo "Hello, World" | luksmeta save \-d /dev/sdz \-s 0 \-u $UUID
  180. .
  181. .fi
  182. .
  183. .IP "" 0
  184. .
  185. .P
  186. Read the data back:
  187. .
  188. .IP "" 4
  189. .
  190. .nf
  191. $ luksmeta load \-d /dev/sdz \-s 0 \-u $UUID
  192. Hello, World
  193. .
  194. .fi
  195. .
  196. .IP "" 0
  197. .
  198. .P
  199. Wipe the data from the slot:
  200. .
  201. .IP "" 4
  202. .
  203. .nf
  204. $ luksmeta wipe \-d /dev/sdz \-s 0 \-u $UUID
  205. .
  206. .fi
  207. .
  208. .IP "" 0
  209. .
  210. .P
  211. Erase all trace of LUKSMeta:
  212. .
  213. .IP "" 4
  214. .
  215. .nf
  216. $ luksmeta nuke \-f \-d /dev/sdz
  217. .
  218. .fi
  219. .
  220. .IP "" 0
  221. .
  222. .SH "AUTHOR"
  223. Nathaniel McCallum <npmccallum@redhat\.com>
  224. .
  225. .SH "SEE ALSO"
  226. \fBcryptsetup\fR(8), \fBuuidgen\fR(1)