2 .\" Copyright 2016 Toomas Soome <tsoome@me.com>
3 .\" Copyright 2013 Nexenta Systems, Inc. All rights reserved.
4 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
5 .\" 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.
6 .\" 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
7 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .Nd administer files available as block devices through lofi
18 .Fl a Ar file Op Ar device
27 .Fl c Ar crypto_algorithm
29 .Fl a Ar file Op Ar device
32 .Fl c Ar crypto_algorithm
34 .Fl a Ar file Op Ar device
37 .Fl c Ar crypto_algorithm
39 .Fl k Ar wrapped_key_file
40 .Fl a Ar file Op Ar device
43 .Fl c Ar crypto_algorithm
45 .Fl a Ar file Op Ar device
48 .Op Fl s Ar segment_size
51 .Fl d Ar file Ns | Ns Ar device
55 .Op Ar file Ns | Ns device
60 the loopback file driver.
62 allows a file to be associated with a block device.
63 That file can then be accessed through the block device.
64 This is useful when the file contains an image of some filesystem (such as a
67 image), because the block device can then be used with the normal system
68 utilities for mounting, checking or repairing filesystems.
76 to add a file as a loopback device, remove such an
77 association, or print information about the current associations.
79 Encryption and compression options are mutually exclusive on the command line.
80 Further, an encrypted file cannot be compressed later, nor can a compressed
81 file be encrypted later.
85 can be used on both the global
86 zone devices and all devices owned by other non-global zones on the system.
88 If the command line flag,
90 is used while creating a loopack device,
92 will create a labeled loopback
93 device, and will generate device links in
95 directories for partitions or slices.
97 Before using these devices, users should create or verify
98 partitioning by using partition management tools such as
101 Once the device has been appropriately partitioned, the labeled
102 device can be used as normal disk to create and mount file systems and to store
106 are not permanent and not persisted by the system.
107 If power is lost or the system is rebooted, then the mappings will need to be
110 The partition table requires space from the mapped file.
112 does not support converting previously created unlabeled loopback device images
113 to labeled loopback devices.
114 If an unlabeled device is used as a labeled device, writing to it will corrupt
117 The following options are supported:
119 .It Fl a Ar file Op Ar device
126 is not specified, an available device is picked.
132 attempts to assign it to
138 The ability to specify a device is provided for use in scripts that wish to
139 reestablish a particular set of associations.
140 A device may not be specified when using a labeled lofi device.
141 .It Fl C Ar {gzip | gzip-N | lzma}
142 Compress the file with the specified compression algorithm.
146 compression algorithm uses the same compression as the open-source
151 level by using the value gzip-\fR\fIN\fR where \fIN\fR is 6 (fast) or 9
152 (best compression ratio).
155 without a number, is equivalent to
157 (which is also the default for the
162 stands for the LZMA (Lempel-Ziv-Markov) compression algorithm.
164 Note that you cannot write to a compressed file, nor can you mount a compressed
166 .It Fl d Ar file Ns | Ns Ar device
167 Remove an association by
171 name, if the associated block device is not busy, and deallocates the block
174 This option should be used with
176 option to create labeled loopback device.
177 If created in local zone, the device has to be enabled in zone configuration.
181 option is specified before the
185 will be opened read-only.
186 .It Fl s Ar segment_size
187 The segment size to use to divide the file being compressed.
189 can be an integer multiple of 512.
191 Uncompress a compressed file.
194 The following options are used when the file is encrypted:
196 .It Fl c Ar crypto_algorithm
197 Select the encryption algorithm.
198 The algorithm must be specified when encryption is enabled because the algorithm
199 is not stored in the disk image.
208 prompts for a passphrase, with a minimum length of eight characters, to be
210 The passphrase is used to derive a symmetric encryption key using PKCS#5 PBKD2.
211 .It Fl k Ar raw_key_file | Ar wrapped_key_file
212 Path to raw or wrapped symmetric encryption key.
213 If a PKCS#11 object is also given with the
215 option, then the key is wrapped by that object.
218 is not specified, the key is used raw.
219 .It Fl T Ar token_key
220 The key in a PKCS#11 token to use for the encryption or for unwrapping the key
227 identifies the unwrapping key, which must be an RSA private key.
229 Generate an ephemeral symmetric encryption key.
232 The following operands are supported:
234 .It Ar crypto_algorithm
242 Display the file name associated with the block device
245 Without arguments, print a list of the current associations.
246 Filenames must be valid absolute pathnames.
248 When a file is added, it is opened for reading or writing by root.
249 Any restrictions apply (such as restricted root access over
251 The file is held open until the association is removed.
252 It is not actually accessed until the block device is used, so it will never be
253 written to if the block device is only opened read-only.
255 Note that the filename may appear as "?" if it is not possible to resolve the
256 path in the current context (for example, if it's an NFS path in a non-global
259 Display the block device associated with
262 Path to a file of the appropriate length, in bits, to use as a raw symmetric
265 PKCS#11 token object in the format:
267 .Ar token_name Ns : Ns Ar manufacturer_id Ns : Ns Ar serial_number Ns : Ns Ar key_label
269 All but the key label are optional and can be empty.
270 For example, to specify a token object with only its key label
274 .Fl T Ar ::: Ns Ar MylofiKey
275 .It Ar wrapped_key_file
276 Path to file containing a symmetric encryption key wrapped by the RSA private
283 for descriptions of the following environment variables
284 that affect the execution of
292 The following exit values are returned:
295 Successful completion.
301 .It Sy Example 1 No Mounting an Existing CD-ROM Image
302 You should ensure that Solaris understands the image before creating the
305 allows you to mount the image and see if it works.
307 This example mounts an existing
310 .Pf ( Sy sparc.iso Ns ),
313 which was downloaded from the Internet.
314 It was created with the
316 utility from the Internet.
320 to attach a block device to it:
322 # lofiadm -a /home/mike_s/RH6.0/sparc.iso
327 picks the device and prints the device name to the standard
331 again by issuing the following command:
334 Block Device File Options
335 /dev/lofi/1 /home/mike_s/RH6.0/sparc.iso -
338 Or, you can give it one name and ask for the other, by issuing the following
341 # lofiadm /dev/lofi/1
342 /home/mike_s/RH6.0/sparc.iso
347 command to mount the image:
349 # mount -F hsfs -o ro /dev/lofi/1 /mnt
352 Check to ensure that Solaris understands the image:
355 Filesystem kbytes used avail capacity Mounted on
356 /dev/lofi/1 512418 512418 0 100% /mnt
358 \&./ RedHat/ doc/ ls-lR rr_moved/
359 \&../ TRANS.TBL dosutils/ ls-lR.gz sbin@
360 \&.buildlog bin@ etc@ misc/ tmp/
361 COPYING boot/ images/ mnt/ usr@
362 README boot.cat* kernels/ modules/
363 RPM-PGP-KEY dev@ lib@ proc/
366 Solaris can mount the CD-ROM image, and understand the filenames.
367 The image was created properly, and you can now create the
371 As a final step, unmount and detach the images:
374 # lofiadm -d /dev/lofi/1
376 Block Device File Options
378 .It Sy Example 2 No Mounting a Floppy Image
379 This is similar to the first example.
383 to help you mount files that contain floppy images is helpful
384 if a floppy disk contains a file that you need, but the machine which you are
385 on does not have a floppy drive.
386 It is also helpful if you do not want to take the time to use the
388 command to copy the image to a floppy.
390 This is an example of getting to
392 floppy for Solaris on an x86 platform:
394 # lofiadm -a /export/s28/MDB_s28x_wos/latest/boot.3
396 # mount -F pcfs /dev/lofi/1 /mnt
398 \&./ COMMENT.BAT* RC.D/ SOLARIS.MAP*
399 \&../ IDENT* REPLACE.BAT* X/
400 APPEND.BAT* MAKEDIR.BAT* SOLARIS/
402 # lofiadm -d /export/s28/MDB_s28x_wos/latest/boot.3
404 .It Sy Example 3 No Making a Sy UFS No Filesystem on a File
407 filesystem on a file can be useful, particularly if a test
408 suite requires a scratch filesystem.
409 It can be painful (or annoying) to have to repartition a disk just for the test
410 suite, but you do not have to.
418 # mkfile 35m /export/home/test
421 Attach it to a block device.
422 You also get the character device that
428 # lofiadm -a /export/home/test
431 newfs: construct a new file system /dev/rlofi/1: (y/n)? y
432 /dev/rlofi/1: 71638 sectors in 119 cylinders of 1 tracks, 602 sectors
433 35.0MB in 8 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
434 super-block backups (for fsck -F ufs -o b=#) at:
435 32, 9664, 19296, 28928, 38560, 48192, 57824, 67456,
440 might not be able to use the entire file.
441 Mount and use the filesystem:
443 # mount /dev/lofi/1 /mnt
445 Filesystem kbytes used avail capacity Mounted on
446 /dev/lofi/1 33455 9 30101 1% /mnt
450 # lofiadm -d /dev/lofi/1
452 .It Sy Example 4 No Creating a PC (FAT) File System on a Unix File
453 The following series of commands creates a
455 file system on a Unix file.
456 The file is associated with a block device created by
460 # mkfile 10M /export/test/testfs
461 # lofiadm -a /export/test testfs
469 in following command.
471 # mkfs -F pcfs -o nofdisk,size=20480 /dev/rlofi/1
472 Construct a new FAT file system on /dev/rlofi/1: (y/n)? y
473 # mount -F pcfs /dev/lofi/1 /mnt
476 Filesystem kbytes used avail capacity Mounted on
477 /dev/lofi/1 10142 0 10142 0% /mnt
479 .It Sy Example 5 No Compressing an Existing CD-ROM Image
480 The following example illustrates compressing an existing CD-ROM image
481 .Pf ( Sy solaris.iso Ns ),
482 verifying that the image is compressed, and then uncompressing it.
484 # lofiadm -C gzip /export/home/solaris.iso
489 to attach a block device to it:
491 # lofiadm -a /export/home/solaris.iso
495 Check if the mapped image is compressed:
498 Block Device File Options
499 /dev/lofi/1 /export/home/solaris.iso Compressed(gzip)
500 /dev/lofi/2 /export/home/regular.iso -
503 Unmap the compressed image and uncompress it:
505 # lofiadm -d /dev/lofi/1
506 # lofiadm -U /export/home/solaris.iso
508 .It Sy Example 6 No Creating an Encrypted UFS File System on a File
509 This example is similar to the example of making a UFS filesystem on a file,
514 # mkfile 35m /export/home/test
517 Attach the file to a block device and specify that the file image is encrypted.
518 As a result of this command, you obtain the character device, which is
522 # lofiadm -c aes-256-cbc -a /export/home/secrets
523 Enter passphrase: My-M0th3r;l0v3s_m3+4lw4ys! (not echoed)
524 Re-enter passphrase: My-M0th3r;l0v3s_m3+4lw4ys! (not echoed)
528 newfs: construct a new file system /dev/rlofi/1: (y/n)? y
529 /dev/rlofi/1: 71638 sectors in 119 cylinders of 1 tracks, 602 sectors
530 35.0MB in 8 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
531 super-block backups (for fsck -F ufs -o b=#) at:
532 32, 9664, 19296, 28928, 38560, 48192, 57824, 67456,
535 The mapped file system shows that encryption is enabled:
538 Block Device File Options
539 /dev/lofi/1 /export/home/secrets Encrypted
542 Mount and use the filesystem:
544 # mount /dev/lofi/1 /mnt
545 # cp moms_secret_*_recipe /mnt
547 \&./ moms_secret_cookie_recipe moms_secret_soup_recipe
548 \&../ moms_secret_fudge_recipe moms_secret_stuffing_recipe
549 lost+found/ moms_secret_meatloaf_recipe moms_secret_waffle_recipe
551 # lofiadm -d /dev/lofi/1
554 Subsequent attempts to map the filesystem with the wrong key or the wrong
555 encryption algorithm will fail:
557 # lofiadm -c blowfish-cbc -a /export/home/secrets\fR
558 Enter passphrase: mommy (not echoed)
559 Re-enter passphrase: mommy (not echoed)
560 lofiadm: could not map file /root/lofi: Invalid argument
562 Block Device File Options
566 Attempts to map the filesystem without encryption will succeed, however
567 attempts to mount and use the filesystem will fail:
569 # lofiadm -a /export/home/secrets
572 Block Device File Options
573 /dev/lofi/1 /export/home/secrets -
574 # mount /dev/lofi/1 /mnt
575 mount: /dev/lofi/1 is not this fstype
590 Just as you would not directly access a disk device that has mounted file
591 systems, you should not access a file associated with a block device except
595 It might also be appropriate to ensure that the file has appropriate permissions
596 to prevent such access.
600 , and who can use them, are controlled by the
603 Read-access allows query operations, such as
604 listing all the associations.
605 Write-access is required to do any state-changing operations, like adding an
615 so all users can do query operations but only root can change anything.
616 The administrator can give users write-access, allowing them to add or
617 delete associations, but that is very likely a security hole and should
618 probably only be given to a trusted group.
620 When mounting a filesystem image, take care to use appropriate mount options.
623 mount option might be appropriate for
625 images whose origin is unknown.
626 Also, some options might not be useful or appropriate, like
632 For compatibility purposes, a raw device is also exported along with the block
640 (without arguments) might change in future releases.