xref: /titanic_51/usr/src/man/man1m/lofiadm.1m (revision a29e56d91db891741f1af9f6bbd3e3c3cac5f19b)
1c10c16deSRichard Lowe'\" te
2*a29e56d9SToomas Soome.\" Copyright 2016 Toomas Soome <tsoome@me.com>
3cd69fabeSAlexander Eremin.\" Copyright 2013 Nexenta Systems, Inc. All rights reserved.
4c10c16deSRichard Lowe.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
5c10c16deSRichard Lowe.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
6c10c16deSRichard Lowe.\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
7c10c16deSRichard Lowe.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8*a29e56d9SToomas Soome.Dd Jun 14, 2016
9*a29e56d9SToomas Soome.Dt LOFIADM 1M
10*a29e56d9SToomas Soome.Os
11*a29e56d9SToomas Soome.Sh NAME
12*a29e56d9SToomas Soome.Nm lofiadm
13*a29e56d9SToomas Soome.Nd administer files available as block devices through lofi
14*a29e56d9SToomas Soome.Sh SYNOPSIS
15*a29e56d9SToomas Soome.Nm
16*a29e56d9SToomas Soome.Op Fl r
17*a29e56d9SToomas Soome.Op Fl l
18*a29e56d9SToomas Soome.Fl a Ar file Op Ar device
19*a29e56d9SToomas Soome.Nm
20*a29e56d9SToomas Soome.Op Fl r
21*a29e56d9SToomas Soome.Fl c
22*a29e56d9SToomas Soome.Ar crypto_algorithm
23*a29e56d9SToomas Soome.Fl a
24*a29e56d9SToomas Soome.Ar file Op Ar device
25*a29e56d9SToomas Soome.Nm
26*a29e56d9SToomas Soome.Op Fl r
27*a29e56d9SToomas Soome.Fl c Ar crypto_algorithm
28*a29e56d9SToomas Soome.Fl k Ar raw_key_file
29*a29e56d9SToomas Soome.Fl a  Ar file Op Ar device
30*a29e56d9SToomas Soome.Nm
31*a29e56d9SToomas Soome.Op Fl r
32*a29e56d9SToomas Soome.Fl c Ar crypto_algorithm
33*a29e56d9SToomas Soome.Fl T Ar token_key
34*a29e56d9SToomas Soome.Fl a Ar file Op Ar device
35*a29e56d9SToomas Soome.Nm
36*a29e56d9SToomas Soome.Op Fl r
37*a29e56d9SToomas Soome.Fl c Ar crypto_algorithm
38*a29e56d9SToomas Soome.Fl T Ar token_key
39*a29e56d9SToomas Soome.Fl k Ar wrapped_key_file
40*a29e56d9SToomas Soome.Fl a Ar file Op Ar device
41*a29e56d9SToomas Soome.Nm
42*a29e56d9SToomas Soome.Op Fl r
43*a29e56d9SToomas Soome.Fl c Ar crypto_algorithm
44*a29e56d9SToomas Soome.Fl e
45*a29e56d9SToomas Soome.Fl a Ar file Op Ar device
46*a29e56d9SToomas Soome.Nm
47*a29e56d9SToomas Soome.Fl C Ar algorithm
48*a29e56d9SToomas Soome.Op Fl s Ar segment_size
49*a29e56d9SToomas Soome.Ar file
50*a29e56d9SToomas Soome.Nm
51*a29e56d9SToomas Soome.Fl d Ar file Ns | Ns Ar device
52*a29e56d9SToomas Soome.Nm
53*a29e56d9SToomas Soome.Fl U Ar file
54*a29e56d9SToomas Soome.Nm
55*a29e56d9SToomas Soome.Op Ar file Ns | Ns device
56*a29e56d9SToomas Soome.Sh DESCRIPTION
57*a29e56d9SToomas Soome.Nm
58*a29e56d9SToomas Soomeadministers
59*a29e56d9SToomas Soome.Sy lofi ,
60*a29e56d9SToomas Soomethe loopback file driver.
61*a29e56d9SToomas Soome.Sy lofi
62c10c16deSRichard Loweallows a file to be associated with a block device. That file can then be
63c10c16deSRichard Loweaccessed through the block device. This is useful when the file contains an
64*a29e56d9SToomas Soomeimage of some filesystem (such as a floppy or
65*a29e56d9SToomas Soome.Sy CD-ROM
66*a29e56d9SToomas Soomeimage), because the block device can then be used with the normal system
67*a29e56d9SToomas Soomeutilities for mounting, checking or repairing filesystems. See
68*a29e56d9SToomas Soome.Xr fsck 1M
69*a29e56d9SToomas Soomeand
70*a29e56d9SToomas Soome.Xr mount 1M .
71*a29e56d9SToomas Soome.Pp
72*a29e56d9SToomas SoomeUse
73*a29e56d9SToomas Soome.Nm
74*a29e56d9SToomas Soometo add a file as a loopback device, remove such an
75c10c16deSRichard Loweassociation, or print information about the current associations.
76*a29e56d9SToomas Soome.Pp
77c10c16deSRichard LoweEncryption and compression options are mutually exclusive on the command line.
78c10c16deSRichard LoweFurther, an encrypted file cannot be compressed later, nor can a compressed
79c10c16deSRichard Lowefile be encrypted later.
80*a29e56d9SToomas Soome.Pp
81*a29e56d9SToomas SoomeIn the global zone,
82*a29e56d9SToomas Soome.Nm
83*a29e56d9SToomas Soomecan be used on both the global
843878843aSJerry Jelinekzone devices and all devices owned by other non-global zones on the system.
85*a29e56d9SToomas Soome.Ss Labeled Devices
86*a29e56d9SToomas SoomeIf the command line flag,
87*a29e56d9SToomas Soome.Fl l ,
88*a29e56d9SToomas Soomeis used while creating a loopack device,
89*a29e56d9SToomas Soome.Sy lofi
90*a29e56d9SToomas Soomewill create a labeled loopback
91*a29e56d9SToomas Soomedevice, and will generate device links in
92*a29e56d9SToomas Soome.Pa /dev/{dsk,rdsk}
93*a29e56d9SToomas Soomedirectories for partitions or slices.
94*a29e56d9SToomas Soome.Pp
95*a29e56d9SToomas SoomeBefore using these devices, users should create or verify
96*a29e56d9SToomas Soomepartitioning by using partition management tools such as
97*a29e56d9SToomas Soome.Xr format 1M and
98*a29e56d9SToomas Soome.Xr fdisk 1M .
99*a29e56d9SToomas SoomeOnce the device has been appropriately partitioned, the labeled
100*a29e56d9SToomas Soomedevice can be used as normal disk to create and mount file systems and to store
101*a29e56d9SToomas Soomedata.  Mappings created by
102*a29e56d9SToomas Soome.Nm
103*a29e56d9SToomas Soomeare not permanent and not persisted by the system. If power is lost or the system
104*a29e56d9SToomas Soomeis rebooted, then the mappings will need to be created again.
105*a29e56d9SToomas Soome.Pp
106*a29e56d9SToomas SoomeThe partition table requires space from the mapped file.
107*a29e56d9SToomas Soome.Sy lofi
108*a29e56d9SToomas Soomedoes not support converting previously created unlabeled loopback device images
109*a29e56d9SToomas Soometo labeled loopback devices. If an unlabeled device is used as a labeled device,
110*a29e56d9SToomas Soomewriting to it will corrupt it.
111*a29e56d9SToomas Soome.Sh OPTIONS
112c10c16deSRichard LoweThe following options are supported:
113*a29e56d9SToomas Soome.Bl -tag -width Ds
114*a29e56d9SToomas Soome.It Fl a Ar file Op Ar device
115*a29e56d9SToomas SoomeAdd
116*a29e56d9SToomas Soome.Sy file
117*a29e56d9SToomas Soomeas a block device.
118*a29e56d9SToomas Soome.Pp
119*a29e56d9SToomas SoomeIf
120*a29e56d9SToomas Soome.Sy device
121*a29e56d9SToomas Soomeis not specified, an available device is picked.
122*a29e56d9SToomas Soome.Pp
123*a29e56d9SToomas SoomeIf
124*a29e56d9SToomas Soome.Sy device
125*a29e56d9SToomas Soomeis specified,
126*a29e56d9SToomas Soome.Nm
127*a29e56d9SToomas Soomeattempts to assign it to
128*a29e56d9SToomas Soome.Sy file .
129*a29e56d9SToomas Soome.Sy device
130*a29e56d9SToomas Soomemust be available or
131*a29e56d9SToomas Soome.Nm
132*a29e56d9SToomas Soomewill fail. The ability to specify a device is provided for use in scripts that
133*a29e56d9SToomas Soomewish to reestablish a particular set of associations.
134*a29e56d9SToomas SoomeA device may not be specified when using a labeled lofi device.
135*a29e56d9SToomas Soome.It Fl C Ar {gzip | gzip-N | lzma}
136c10c16deSRichard LoweCompress the file with the specified compression algorithm.
137*a29e56d9SToomas Soome.Pp
138*a29e56d9SToomas SoomeThe
139*a29e56d9SToomas Soome.Sy gzip
140*a29e56d9SToomas Soomecompression algorithm uses the same compression as the open-source
141*a29e56d9SToomas Soome.Sy gzip
142*a29e56d9SToomas Soomecommand. You can specify the
143*a29e56d9SToomas Soome.Sy gzip
144*a29e56d9SToomas Soomelevel by using the value gzip-\fR\fIN\fR where \fIN\fR is 6 (fast) or 9
145*a29e56d9SToomas Soome(best compression ratio). Currently,
146*a29e56d9SToomas Soome.Sy gzip ,
147*a29e56d9SToomas Soomewithout a number, is equivalent to
148*a29e56d9SToomas Soome.Sy gzip-6
149*a29e56d9SToomas Soome(which is also the default for the
150*a29e56d9SToomas Soome.Sy gzip
151*a29e56d9SToomas Soomecommand).
152*a29e56d9SToomas Soome.Pp
153*a29e56d9SToomas Soome.Sy lzma
154*a29e56d9SToomas Soomestands for the LZMA (Lempel-Ziv-Markov) compression algorithm.
155*a29e56d9SToomas Soome.Pp
156c10c16deSRichard LoweNote that you cannot write to a compressed file, nor can you mount a compressed
157c10c16deSRichard Lowefile read/write.
158*a29e56d9SToomas Soome.It Fl d Ar file Ns | Ns Ar device
159*a29e56d9SToomas SoomeRemove an association by
160*a29e56d9SToomas Soome.Sy file
161*a29e56d9SToomas Soomeor
162*a29e56d9SToomas Soome.Sy device
163*a29e56d9SToomas Soomename, if the associated block device is not busy, and deallocates the block
164*a29e56d9SToomas Soomedevice.
165*a29e56d9SToomas Soome.It Fl l
166*a29e56d9SToomas SoomeThis option should be used with
167*a29e56d9SToomas Soome.Fl a
168*a29e56d9SToomas Soomeoption to create labeled loopback device. If created in local zone, the device
169*a29e56d9SToomas Soomehas to be enabled in zone configuration.
170*a29e56d9SToomas Soome.It Fl r
171*a29e56d9SToomas SoomeIf the
172*a29e56d9SToomas Soome.Fl r
173*a29e56d9SToomas Soomeoption is specified before the
174*a29e56d9SToomas Soome.Fl a
175*a29e56d9SToomas Soomeoption, the
176*a29e56d9SToomas Soome.Sy device
177*a29e56d9SToomas Soomewill be opened read-only.
178*a29e56d9SToomas Soome.It Fl s Ar segment_size
179*a29e56d9SToomas SoomeThe segment size to use to divide the file being compressed.
180*a29e56d9SToomas Soome.Sy segment_size
181c10c16deSRichard Lowecan be an integer multiple of 512.
182*a29e56d9SToomas Soome.It Fl U Ar file
183c10c16deSRichard LoweUncompress a compressed file.
184*a29e56d9SToomas Soome.El
185*a29e56d9SToomas Soome.Pp
186c10c16deSRichard LoweThe following options are used when the file is encrypted:
187*a29e56d9SToomas Soome.Bl -tag -width Ds
188*a29e56d9SToomas Soome.It Fl c Ar crypto_algorithm
189c10c16deSRichard LoweSelect the encryption algorithm. The algorithm must be specified when
190c10c16deSRichard Loweencryption is enabled because the algorithm is not stored in the disk image.
191*a29e56d9SToomas Soome.Pp
192*a29e56d9SToomas SoomeIf none of
193*a29e56d9SToomas Soome.Fl e ,
194*a29e56d9SToomas Soome.Fl k ,
195*a29e56d9SToomas Soomeor
196*a29e56d9SToomas Soome.Fl T
197*a29e56d9SToomas Soomeis specified,
198*a29e56d9SToomas Soome.Nm
199*a29e56d9SToomas Soomeprompts for a passphrase, with a minimum length of eight characters, to be
200*a29e56d9SToomas Soomeentered.
201c10c16deSRichard LoweThe passphrase is used to derive a symmetric encryption key using PKCS#5 PBKD2.
202*a29e56d9SToomas Soome.It Fl k Ar raw_key_file | Ar wrapped_key_file
203c10c16deSRichard LowePath to raw or wrapped symmetric encryption key. If a PKCS#11 object is also
204*a29e56d9SToomas Soomegiven with the
205*a29e56d9SToomas Soome.Fl T
206*a29e56d9SToomas Soomeoption, then the key is wrapped by that object. If
207*a29e56d9SToomas Soome.Fl T
208*a29e56d9SToomas Soomeis not specified, the key is used raw.
209*a29e56d9SToomas Soome.It Fl T Ar token_key
210c10c16deSRichard LoweThe key in a PKCS#11 token to use for the encryption or for unwrapping the key
211c10c16deSRichard Lowefile.
212*a29e56d9SToomas Soome.Pp
213*a29e56d9SToomas SoomeIf
214*a29e56d9SToomas Soome.Fl k
215*a29e56d9SToomas Soomeis also specified,
216*a29e56d9SToomas Soome.Fl T
217*a29e56d9SToomas Soomeidentifies the unwrapping key, which must be an RSA private key.
218*a29e56d9SToomas Soome.It Fl e
219c10c16deSRichard LoweGenerate an ephemeral symmetric encryption key.
220*a29e56d9SToomas Soome.El
221*a29e56d9SToomas Soome.Sh OPERANDS
222c10c16deSRichard LoweThe following operands are supported:
223*a29e56d9SToomas Soome.Bl -tag -width Ds
224*a29e56d9SToomas Soome.It Ar crypto_algorithm
225*a29e56d9SToomas SoomeOne of:
226*a29e56d9SToomas Soome.Sy aes-128-cbc ,
227*a29e56d9SToomas Soome.Sy aes-192-cbc ,
228*a29e56d9SToomas Soome.Sy aes-256-cbc ,
229*a29e56d9SToomas Soome.Sy des3-cbc ,
230*a29e56d9SToomas Soome.Sy blowfish-cbc .
231*a29e56d9SToomas Soome.It Ar device
232*a29e56d9SToomas SoomeDisplay the file name associated with the block device
233*a29e56d9SToomas Soome.Sy device .
234*a29e56d9SToomas Soome.Pp
235c10c16deSRichard LoweWithout arguments, print a list of the current associations. Filenames must be
236c10c16deSRichard Lowevalid absolute pathnames.
237*a29e56d9SToomas Soome.Pp
238c10c16deSRichard LoweWhen a file is added, it is opened for reading or writing by root. Any
239*a29e56d9SToomas Soomerestrictions apply (such as restricted root access over
240*a29e56d9SToomas Soome.Sy NFS Ns ).
241*a29e56d9SToomas SoomeThe file is held open until the association is removed. It is not actually
242*a29e56d9SToomas Soomeaccessed until the block device is used, so it will never be written to if the
243*a29e56d9SToomas Soomeblock device is only opened read-only.
244*a29e56d9SToomas Soome.Pp
2453878843aSJerry JelinekNote that the filename may appear as "?" if it is not possible to resolve the
2463878843aSJerry Jelinekpath in the current context (for example, if it's an NFS path in a non-global
2473878843aSJerry Jelinekzone).
248*a29e56d9SToomas Soome.It Ar file
249*a29e56d9SToomas SoomeDisplay the block device associated with
250*a29e56d9SToomas Soome.Sy file .
251*a29e56d9SToomas Soome.It Ar raw_key_file
252c10c16deSRichard LowePath to a file of the appropriate length, in bits, to use as a raw symmetric
253c10c16deSRichard Loweencryption key.
254*a29e56d9SToomas Soome.It Ar token_key
255c10c16deSRichard LowePKCS#11 token object in the format:
256*a29e56d9SToomas Soome.Pp
257*a29e56d9SToomas Soome.Ar token_name Ns : Ns Ar manufacturer_id Ns : Ns Ar serial_number Ns : Ns Ar key_label
258*a29e56d9SToomas Soome.Pp
259c10c16deSRichard LoweAll but the key label are optional and can be empty. For example, to specify a
260*a29e56d9SToomas Soometoken object with only its key label
261*a29e56d9SToomas Soome.Sy MylofiKey ,
262*a29e56d9SToomas Soomeuse:
263*a29e56d9SToomas Soome.Pp
264*a29e56d9SToomas Soome.Fl T Ar ::: Ns Ar MylofiKey
265*a29e56d9SToomas Soome.It Ar wrapped_key_file
266c10c16deSRichard LowePath to file containing a symmetric encryption key wrapped by the RSA private
267*a29e56d9SToomas Soomekey specified by
268*a29e56d9SToomas Soome.Fl T .
269*a29e56d9SToomas Soome.El
270*a29e56d9SToomas Soome.Sh ENVIRONMENT
271*a29e56d9SToomas SoomeSee
272*a29e56d9SToomas Soome.Xr environ 5
273*a29e56d9SToomas Soomefor descriptions of the following environment variables
274*a29e56d9SToomas Soomethat affect the execution of
275*a29e56d9SToomas Soome.Nm
276*a29e56d9SToomas Soome:
277*a29e56d9SToomas Soome.Sy LC_CTYPE ,
278*a29e56d9SToomas Soome.Sy LC_MESSAGES
279*a29e56d9SToomas Soomeand
280*a29e56d9SToomas Soome.Sy NLSPATH .
281*a29e56d9SToomas Soome.Sh EXIT STATUS
282*a29e56d9SToomas SoomeThe following exit values are returned:
283*a29e56d9SToomas Soome.Bl -tag -width Ds
284*a29e56d9SToomas Soome.It Sy 0
285*a29e56d9SToomas SoomeSuccessful completion.
286*a29e56d9SToomas Soome.It Sy >0
287*a29e56d9SToomas SoomeAn error occurred.
288*a29e56d9SToomas Soome.El
289*a29e56d9SToomas Soome.Sh EXAMPLES
290*a29e56d9SToomas Soome.Bl -tag -width Ds
291*a29e56d9SToomas Soome.It Sy Example 1 No Mounting an Existing CD-ROM Image
292c10c16deSRichard LoweYou should ensure that Solaris understands the image before creating the
293*a29e56d9SToomas Soome.Sy CD .
294*a29e56d9SToomas Soome.Sy lofi
295*a29e56d9SToomas Soomeallows you to mount the image and see if it works.
296*a29e56d9SToomas Soome.Pp
297*a29e56d9SToomas SoomeThis example mounts an existing
298*a29e56d9SToomas Soome.Sy CD-ROM
299*a29e56d9SToomas Soomeimage
300*a29e56d9SToomas Soome.Pf ( Sy sparc.iso Ns ),
301*a29e56d9SToomas Soomeof the
302*a29e56d9SToomas Soome.Sy Red Hat 6.0 CD
303*a29e56d9SToomas Soomewhich was downloaded from the Internet. It was created
304*a29e56d9SToomas Soomewith the
305*a29e56d9SToomas Soome.Sy mkisofs
306*a29e56d9SToomas Soomeutility from the Internet.
307*a29e56d9SToomas Soome.Pp
308*a29e56d9SToomas SoomeUse
309*a29e56d9SToomas Soome.Nm
310*a29e56d9SToomas Soometo attach a block device to it:
311*a29e56d9SToomas Soome.Bd -literal
312*a29e56d9SToomas Soome# lofiadm -a /home/mike_s/RH6.0/sparc.iso
313c10c16deSRichard Lowe/dev/lofi/1
314*a29e56d9SToomas Soome.Ed
315*a29e56d9SToomas Soome.Pp
316*a29e56d9SToomas Soome.Nm
317*a29e56d9SToomas Soomepicks the device and prints the device name to the standard
318*a29e56d9SToomas Soomeoutput. You can run
319*a29e56d9SToomas Soome.Nm
320*a29e56d9SToomas Soomeagain by issuing the following command:
321*a29e56d9SToomas Soome.Bd -literal
322*a29e56d9SToomas Soome# lofiadm
323c10c16deSRichard LoweBlock Device     File                           Options
324c10c16deSRichard Lowe/dev/lofi/1      /home/mike_s/RH6.0/sparc.iso   -
325*a29e56d9SToomas Soome.Ed
326*a29e56d9SToomas Soome.Pp
327c10c16deSRichard LoweOr, you can give it one name and ask for the other, by issuing the following
328c10c16deSRichard Lowecommand:
329*a29e56d9SToomas Soome.Bd -literal
330*a29e56d9SToomas Soome# lofiadm /dev/lofi/1
331c10c16deSRichard Lowe/home/mike_s/RH6.0/sparc.iso
332*a29e56d9SToomas Soome.Ed
333*a29e56d9SToomas Soome.Pp
334*a29e56d9SToomas SoomeUse the
335*a29e56d9SToomas Soome.Xr mount 1M
336*a29e56d9SToomas Soomecommand to mount the image:
337*a29e56d9SToomas Soome.Bd -literal
338*a29e56d9SToomas Soome# mount -F hsfs -o ro /dev/lofi/1 /mnt
339*a29e56d9SToomas Soome.Ed
340*a29e56d9SToomas Soome.Pp
341c10c16deSRichard LoweCheck to ensure that Solaris understands the image:
342*a29e56d9SToomas Soome.Bd -literal
343*a29e56d9SToomas Soome# df -k /mnt
344c10c16deSRichard LoweFilesystem            kbytes    used   avail capacity  Mounted on
345c10c16deSRichard Lowe/dev/lofi/1           512418  512418       0   100%    /mnt
346*a29e56d9SToomas Soome# ls /mnt
347c10c16deSRichard Lowe\&./            RedHat/       doc/          ls-lR         rr_moved/
348c10c16deSRichard Lowe\&../           TRANS.TBL     dosutils/     ls-lR.gz      sbin@
349c10c16deSRichard Lowe\&.buildlog     bin@          etc@          misc/         tmp/
350c10c16deSRichard LoweCOPYING       boot/         images/       mnt/          usr@
351c10c16deSRichard LoweREADME        boot.cat*     kernels/      modules/
352c10c16deSRichard LoweRPM-PGP-KEY   dev@          lib@          proc/
353*a29e56d9SToomas Soome.Ed
354*a29e56d9SToomas Soome.Pp
355c10c16deSRichard LoweSolaris can mount the CD-ROM image, and understand the filenames. The image was
356*a29e56d9SToomas Soomecreated properly, and you can now create the
357*a29e56d9SToomas Soome.Sy CD-ROM
358*a29e56d9SToomas Soomewith confidence.
359*a29e56d9SToomas Soome.Pp
360c10c16deSRichard LoweAs a final step, unmount and detach the images:
361*a29e56d9SToomas Soome.Bd -literal
362*a29e56d9SToomas Soome# umount /mnt
363*a29e56d9SToomas Soome# lofiadm -d /dev/lofi/1
364*a29e56d9SToomas Soome# lofiadm
365c10c16deSRichard LoweBlock Device             File             Options
366*a29e56d9SToomas Soome.Ed
367*a29e56d9SToomas Soome.It Sy Example 2 No Mounting a Floppy Image
368c10c16deSRichard LoweThis is similar to the first example.
369*a29e56d9SToomas Soome.Pp
370*a29e56d9SToomas SoomeUsing
371*a29e56d9SToomas Soome.Sy lofi
372*a29e56d9SToomas Soometo help you mount files that contain floppy images is helpful
373c10c16deSRichard Loweif a floppy disk contains a file that you need, but the machine which you are
374c10c16deSRichard Loweon does not have a floppy drive. It is also helpful if you do not want to take
375*a29e56d9SToomas Soomethe time to use the
376*a29e56d9SToomas Soome.Sy dd
377*a29e56d9SToomas Soomecommand to copy the image to a floppy.
378*a29e56d9SToomas Soome.Pp
379*a29e56d9SToomas SoomeThis is an example of getting to
380*a29e56d9SToomas Soome.Sy MDB
381*a29e56d9SToomas Soomefloppy for Solaris on an x86 platform:
382*a29e56d9SToomas Soome.Bd -literal
383*a29e56d9SToomas Soome# lofiadm -a /export/s28/MDB_s28x_wos/latest/boot.3
384c10c16deSRichard Lowe/dev/lofi/1
385*a29e56d9SToomas Soome# mount -F pcfs /dev/lofi/1 /mnt
386*a29e56d9SToomas Soome# ls /mnt
387c10c16deSRichard Lowe\&./            COMMENT.BAT*  RC.D/         SOLARIS.MAP*
388c10c16deSRichard Lowe\&../           IDENT*        REPLACE.BAT*  X/
389c10c16deSRichard LoweAPPEND.BAT*   MAKEDIR.BAT*  SOLARIS/
390*a29e56d9SToomas Soome# umount /mnt
391*a29e56d9SToomas Soome# lofiadm -d /export/s28/MDB_s28x_wos/latest/boot.3
392*a29e56d9SToomas Soome.Ed
393*a29e56d9SToomas Soome.It Sy Example 3 No Making a Sy UFS No Filesystem on a File
394*a29e56d9SToomas SoomeMaking a
395*a29e56d9SToomas Soome.Sy UFS
396*a29e56d9SToomas Soomefilesystem on a file can be useful, particularly if a test
397c10c16deSRichard Lowesuite requires a scratch filesystem. It can be painful (or annoying) to have to
398c10c16deSRichard Lowerepartition a disk just for the test suite, but you do not have to. You can
399*a29e56d9SToomas Soome.Sy newfs
400*a29e56d9SToomas Soomea file with
401*a29e56d9SToomas Soome.Sy lofi .
402*a29e56d9SToomas Soome.Pp
403c10c16deSRichard LoweCreate the file:
404*a29e56d9SToomas Soome.Bd -literal
405*a29e56d9SToomas Soome# mkfile 35m /export/home/test
406*a29e56d9SToomas Soome.Ed
407*a29e56d9SToomas Soome.Pp
408*a29e56d9SToomas SoomeAttach it to a block device. You also get the character device that
409*a29e56d9SToomas Soome.Sy newfs
410*a29e56d9SToomas Soomerequires, so
411*a29e56d9SToomas Soome.Sy newfs
412*a29e56d9SToomas Soomethat:
413*a29e56d9SToomas Soome.Bd -literal
414*a29e56d9SToomas Soome# lofiadm -a /export/home/test
415c10c16deSRichard Lowe/dev/lofi/1
416*a29e56d9SToomas Soome# newfs /dev/rlofi/1
417*a29e56d9SToomas Soomenewfs: construct a new file system /dev/rlofi/1: (y/n)? y
418c10c16deSRichard Lowe/dev/rlofi/1:   71638 sectors in 119 cylinders of 1 tracks, 602 sectors
419c10c16deSRichard Lowe        35.0MB in 8 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
420c10c16deSRichard Lowesuper-block backups (for fsck -F ufs -o b=#) at:
421c10c16deSRichard Lowe 32, 9664, 19296, 28928, 38560, 48192, 57824, 67456,
422*a29e56d9SToomas Soome.Ed
423*a29e56d9SToomas Soome.Pp
424*a29e56d9SToomas SoomeNote that
425*a29e56d9SToomas Soome.Sy ufs
426*a29e56d9SToomas Soomemight not be able to use the entire file. Mount and use the filesystem:
427*a29e56d9SToomas Soome.Bd -literal
428*a29e56d9SToomas Soome# mount /dev/lofi/1 /mnt
429*a29e56d9SToomas Soome# df -k /mnt
430c10c16deSRichard LoweFilesystem            kbytes    used   avail capacity  Mounted on
431c10c16deSRichard Lowe/dev/lofi/1            33455       9   30101     1%    /mnt
432*a29e56d9SToomas Soome# ls /mnt
433c10c16deSRichard Lowe\&./           ../          lost+found/
434*a29e56d9SToomas Soome# umount /mnt
435*a29e56d9SToomas Soome# lofiadm -d /dev/lofi/1
436*a29e56d9SToomas Soome.Ed
437*a29e56d9SToomas Soome.It Sy Example 4 No Creating a PC (FAT) File System on a Unix File
438*a29e56d9SToomas SoomeThe following series of commands creates a
439*a29e56d9SToomas Soome.Sy FAT
440*a29e56d9SToomas Soomefile system on a Unix file. The file is associated with a block device created by
441*a29e56d9SToomas Soome.Nm
442*a29e56d9SToomas Soome.
443*a29e56d9SToomas Soome.Bd -literal
444*a29e56d9SToomas Soome# mkfile 10M /export/test/testfs
445*a29e56d9SToomas Soome# lofiadm -a /export/test testfs
446c10c16deSRichard Lowe/dev/lofi/1
447*a29e56d9SToomas Soome.Ed
448*a29e56d9SToomas Soome.Pp
449*a29e56d9SToomas SoomeNote use of
450*a29e56d9SToomas Soome.Sy rlofi ,
451*a29e56d9SToomas Soomenot
452*a29e56d9SToomas Soome.Sy lofi ,
453*a29e56d9SToomas Soomein following command.
454*a29e56d9SToomas Soome.Bd -literal
455*a29e56d9SToomas Soome# mkfs -F pcfs -o nofdisk,size=20480 /dev/rlofi/1
456*a29e56d9SToomas SoomeConstruct a new FAT file system on /dev/rlofi/1: (y/n)? y
457*a29e56d9SToomas Soome# mount -F pcfs /dev/lofi/1 /mnt
458*a29e56d9SToomas Soome# cd /mnt
459*a29e56d9SToomas Soome# df -k .
460c10c16deSRichard LoweFilesystem            kbytes    used   avail capacity  Mounted on
461c10c16deSRichard Lowe/dev/lofi/1            10142       0   10142     0%    /mnt
462*a29e56d9SToomas Soome.Ed
463*a29e56d9SToomas Soome.It Sy Example 5 No Compressing an Existing CD-ROM Image
464c10c16deSRichard LoweThe following example illustrates compressing an existing CD-ROM image
465*a29e56d9SToomas Soome.Pf ( Sy solaris.iso Ns ),
466*a29e56d9SToomas Soomeverifying that the image is compressed, and then uncompressing it.
467*a29e56d9SToomas Soome.Bd -literal
468*a29e56d9SToomas Soome# lofiadm -C gzip /export/home/solaris.iso
469*a29e56d9SToomas Soome.Ed
470*a29e56d9SToomas Soome.Pp
471*a29e56d9SToomas SoomeUse
472*a29e56d9SToomas Soome.Nm
473*a29e56d9SToomas Soometo attach a block device to it:
474*a29e56d9SToomas Soome.Bd -literal
475*a29e56d9SToomas Soome# lofiadm -a /export/home/solaris.iso
476c10c16deSRichard Lowe  /dev/lofi/1
477*a29e56d9SToomas Soome.Ed
478*a29e56d9SToomas Soome.Pp
479c10c16deSRichard LoweCheck if the mapped image is compressed:
480*a29e56d9SToomas Soome.Bd -literal
481*a29e56d9SToomas Soome# lofiadm
482c10c16deSRichard LoweBlock Device      File                            Options
483c10c16deSRichard Lowe/dev/lofi/1       /export/home/solaris.iso        Compressed(gzip)
484c10c16deSRichard Lowe/dev/lofi/2       /export/home/regular.iso        -
485*a29e56d9SToomas Soome.Ed
486*a29e56d9SToomas Soome.Pp
487c10c16deSRichard LoweUnmap the compressed image and uncompress it:
488*a29e56d9SToomas Soome.Bd -literal
489*a29e56d9SToomas Soome# lofiadm -d /dev/lofi/1
490*a29e56d9SToomas Soome# lofiadm -U /export/home/solaris.iso
491*a29e56d9SToomas Soome.Ed
492*a29e56d9SToomas Soome.It Sy Example 6 No Creating an Encrypted UFS File System on a File
493c10c16deSRichard LoweThis example is similar to the example of making a UFS filesystem on a file,
494c10c16deSRichard Loweabove.
495*a29e56d9SToomas Soome.Pp
496c10c16deSRichard LoweCreate the file:
497*a29e56d9SToomas Soome.Bd -literal
498*a29e56d9SToomas Soome# mkfile 35m /export/home/test
499*a29e56d9SToomas Soome.Ed
500*a29e56d9SToomas Soome.Pp
501c10c16deSRichard LoweAttach the file to a block device and specify that the file image is encrypted.
502c10c16deSRichard LoweAs a result of this command, you obtain the character device, which is
503*a29e56d9SToomas Soomesubsequently used by
504*a29e56d9SToomas Soome.Sy newfs :
505*a29e56d9SToomas Soome.Bd -literal
506*a29e56d9SToomas Soome# lofiadm -c aes-256-cbc -a /export/home/secrets
507*a29e56d9SToomas SoomeEnter passphrase: My-M0th3r;l0v3s_m3+4lw4ys!           (not echoed)
508*a29e56d9SToomas SoomeRe-enter passphrase: My-M0th3r;l0v3s_m3+4lw4ys!        (not echoed)
509c10c16deSRichard Lowe/dev/lofi/1
510c10c16deSRichard Lowe
511*a29e56d9SToomas Soome# newfs /dev/rlofi/1
512*a29e56d9SToomas Soomenewfs: construct a new file system /dev/rlofi/1: (y/n)? y
513c10c16deSRichard Lowe/dev/rlofi/1:   71638 sectors in 119 cylinders of 1 tracks, 602 sectors
514c10c16deSRichard Lowe       35.0MB in 8 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
515c10c16deSRichard Lowesuper-block backups (for fsck -F ufs -o b=#) at:
516c10c16deSRichard Lowe32, 9664, 19296, 28928, 38560, 48192, 57824, 67456,
517*a29e56d9SToomas Soome.Ed
518*a29e56d9SToomas Soome.Pp
519c10c16deSRichard LoweThe mapped file system shows that encryption is enabled:
520*a29e56d9SToomas Soome.Bd -literal
521*a29e56d9SToomas Soome# lofiadm
522c10c16deSRichard LoweBlock Device    File                     Options
523c10c16deSRichard Lowe/dev/lofi/1     /export/home/secrets     Encrypted
524*a29e56d9SToomas Soome.Ed
525*a29e56d9SToomas Soome.Pp
526c10c16deSRichard LoweMount and use the filesystem:
527*a29e56d9SToomas Soome.Bd -literal
528*a29e56d9SToomas Soome# mount /dev/lofi/1 /mnt
529*a29e56d9SToomas Soome# cp moms_secret_*_recipe /mnt
530*a29e56d9SToomas Soome# ls /mnt
531c10c16deSRichard Lowe\&./         moms_secret_cookie_recipe    moms_secret_soup_recipe
532c10c16deSRichard Lowe\&../        moms_secret_fudge_recipe     moms_secret_stuffing_recipe
533c10c16deSRichard Lowelost+found/  moms_secret_meatloaf_recipe  moms_secret_waffle_recipe
534*a29e56d9SToomas Soome# umount /mnt
535*a29e56d9SToomas Soome# lofiadm -d /dev/lofi/1
536*a29e56d9SToomas Soome.Ed
537*a29e56d9SToomas Soome.Pp
538c10c16deSRichard LoweSubsequent attempts to map the filesystem with the wrong key or the wrong
539c10c16deSRichard Loweencryption algorithm will fail:
540*a29e56d9SToomas Soome.Bd -literal
541*a29e56d9SToomas Soome# lofiadm -c blowfish-cbc -a /export/home/secrets\fR
542*a29e56d9SToomas SoomeEnter passphrase: mommy                                (not echoed)
543*a29e56d9SToomas SoomeRe-enter passphrase: mommy                             (not echoed)
544c10c16deSRichard Lowelofiadm: could not map file /root/lofi: Invalid argument
545*a29e56d9SToomas Soome# lofiadm
546c10c16deSRichard LoweBlock Device    File                    Options
547c10c16deSRichard Lowe#
548*a29e56d9SToomas Soome.Ed
549*a29e56d9SToomas Soome.Pp
550c10c16deSRichard LoweAttempts to map the filesystem without encryption will succeed, however
551c10c16deSRichard Loweattempts to mount and use the filesystem will fail:
552*a29e56d9SToomas Soome.Bd -literal
553*a29e56d9SToomas Soome# lofiadm -a /export/home/secrets
554c10c16deSRichard Lowe/dev/lofi/1
555*a29e56d9SToomas Soome# lofiadm
556c10c16deSRichard LoweBlock Device    File                     Options
557c10c16deSRichard Lowe/dev/lofi/1     /export/home/secrets     -
558*a29e56d9SToomas Soome# mount /dev/lofi/1 /mnt
559c10c16deSRichard Lowemount: /dev/lofi/1 is not this fstype
560c10c16deSRichard Lowe#
561*a29e56d9SToomas Soome.Ed
562*a29e56d9SToomas Soome.El
563*a29e56d9SToomas Soome.Sh SEE ALSO
564*a29e56d9SToomas Soome.Xr fdisk 1M ,
565*a29e56d9SToomas Soome.Xr format 1M ,
566*a29e56d9SToomas Soome.Xr fsck 1M ,
567*a29e56d9SToomas Soome.Xr mount 1M ,
568*a29e56d9SToomas Soome.Xr mount_ufs 1M ,
569*a29e56d9SToomas Soome.Xr newfs 1M ,
570*a29e56d9SToomas Soome.Xr attributes 5 ,
571*a29e56d9SToomas Soome.Xr lofi 7D ,
572*a29e56d9SToomas Soome.Xr lofs 7FS
573*a29e56d9SToomas Soome.Sh NOTES
574c10c16deSRichard LoweJust as you would not directly access a disk device that has mounted file
575c10c16deSRichard Lowesystems, you should not access a file associated with a block device except
576*a29e56d9SToomas Soomethrough the
577*a29e56d9SToomas Soome.Sy lofi
578*a29e56d9SToomas Soomefile driver. It might also be appropriate to ensure that
579c10c16deSRichard Lowethe file has appropriate permissions to prevent such access.
580*a29e56d9SToomas Soome.Pp
581*a29e56d9SToomas SoomeThe abilities of
582*a29e56d9SToomas Soome.Nm
583*a29e56d9SToomas Soome, and who can use them, are controlled by the
584*a29e56d9SToomas Soomepermissions of
585*a29e56d9SToomas Soome.Pa /dev/lofictl .
586*a29e56d9SToomas SoomeRead-access allows query operations, such as
587c10c16deSRichard Lowelisting all the associations. Write-access is required to do any state-changing
588*a29e56d9SToomas Soomeoperations, like adding an association. As shipped,
589*a29e56d9SToomas Soome.Pa /dev/lofictl
590*a29e56d9SToomas Soomeis owned by
591*a29e56d9SToomas Soome.Sy root ,
592*a29e56d9SToomas Soomein group
593*a29e56d9SToomas Soome.Sy sys ,
594*a29e56d9SToomas Soomeand mode
595*a29e56d9SToomas Soome.Sy 0644 ,
596*a29e56d9SToomas Soomeso all users can do query operations but only root can change anything.
597*a29e56d9SToomas SoomeThe administrator can give users write-access, allowing them to add or
598*a29e56d9SToomas Soomedelete associations, but that is very likely a security hole and should
599*a29e56d9SToomas Soomeprobably only be given to a trusted group.
600*a29e56d9SToomas Soome.Pp
601c10c16deSRichard LoweWhen mounting a filesystem image, take care to use appropriate mount options.
602*a29e56d9SToomas SoomeIn particular, the
603*a29e56d9SToomas Soome.Sy nosuid
604*a29e56d9SToomas Soomemount option might be appropriate for
605*a29e56d9SToomas Soome.Sy UFS
606c10c16deSRichard Loweimages whose origin is unknown. Also, some options might not be useful or
607*a29e56d9SToomas Soomeappropriate, like
608*a29e56d9SToomas Soome.Sy logging
609*a29e56d9SToomas Soomeor
610*a29e56d9SToomas Soome.Sy forcedirectio
611*a29e56d9SToomas Soomefor
612*a29e56d9SToomas Soome.Sy UFS .
613*a29e56d9SToomas SoomeFor compatibility purposes, a raw device is also exported along with the block
614*a29e56d9SToomas Soomedevice. For example,
615*a29e56d9SToomas Soome.Xr newfs 1M
616*a29e56d9SToomas Soomerequires one.
617*a29e56d9SToomas Soome.Pp
618*a29e56d9SToomas SoomeThe output of
619*a29e56d9SToomas Soome.Nm
620*a29e56d9SToomas Soome(without arguments) might change in future releases.
621