以 PDF 格式下載這本書 (9842 KB)
lofiadm(1M)Name | Synopsis | Description | Options | Operands | Examples | Environment Variables | Exit Status | Attributes | See Also | Notes Name
Synopsis/usr/sbin/lofiadm -a file [device] /usr/sbin/lofiadm -c crypto_algorithm -a file [device] /usr/sbin/lofiadm -c crypto_algorithm -k raw_key_file -a file [device] /usr/sbin/lofiadm -c crypto_algorithm -T token_key -a file [device]
/usr/sbin/lofiadm -c crypto_algorithm -T token_key
-k wrapped_key_file -a file [device]
/usr/sbin/lofiadm -c crypto_algorithm -e -a file [device] /usr/sbin/lofiadm -C algorithm [-s segment_size] file /usr/sbin/lofiadm -d file | device /usr/sbin/lofiadm -U file /usr/sbin/lofiadm [ file | device] Descriptionlofiadm administers lofi, the loopback file driver. lofi allows a file to be associated with a block device. That file can then be accessed through the block device. This is useful when the file contains an image of some filesystem (such as a floppy or CD-ROM image), because the block device can then be used with the normal system utilities for mounting, checking or repairing filesystems. See fsck ### UNMATCHED MARKUP: manvolnum ### and mount ### UNMATCHED MARKUP: manvolnum ### . Use lofiadm to add a file as a loopback device, remove such an association, or print information about the current associations. Encryption and compression options are mutually exclusive on the command line. Further, an encrypted file cannot be compressed later, nor can a compressed file be encrypted later. The lofi driver is not available and will not work inside a zone. Options
The following options are supported: The following options are used when the file is encrypted: Operands
The following operands are supported: ExamplesExample 1 Mounting an Existing CD-ROM ImageYou should ensure that Solaris understands the image before creating the CD. lofi allows you to mount the image and see if it works. This example mounts an existing CD-ROM image (sparc.iso), of the Red Hat 6.0 CD which was downloaded from the Internet. It was created with the mkisofs utility from the Internet. Use lofiadm to attach a block device to it:
lofiadm picks the device and prints the device name to the standard output. You can run lofiadm again by issuing the following command:
Or, you can give it one name and ask for the other, by issuing the following command:
Use the mount command to mount the image:
Check to ensure that Solaris understands the image:
Solaris can mount the CD-ROM image, and understand the filenames. The image was created properly, and you can now create the CD-ROM with confidence. As a final step, unmount and detach the images:
Example 2 Mounting a Floppy ImageThis is similar to the first example. Using lofi to help you mount files that contain floppy images is helpful if a floppy disk contains a file that you need, but the machine which you are on does not have a floppy drive. It is also helpful if you do not want to take the time to use the dd command to copy the image to a floppy. This is an example of getting to MDB floppy for Solaris on an x86 platform:
Example 3 Making a UFS Filesystem on a FileMaking a UFS filesystem on a file can be useful, particularly if a test suite requires a scratch filesystem. It can be painful (or annoying) to have to repartition a disk just for the test suite, but you do not have to. You can newfs a file with lofi Create the file:
Attach it to a block device. You also get the character device that newfs requires, so newfs that:
Note that ufs might not be able to use the entire file. Mount and use the filesystem:
Example 4 Creating a PC (FAT) File System on a Unix FileThe following series of commands creates a FAT file system on a Unix file. The file is associated with a block device created by lofiadm.
Example 5 Compressing an Existing CD-ROM ImageThe following example illustrates compressing an existing CD-ROM image (solaris.iso), verifying that the image is compressed, and then uncompressing it.
Use lofiadm to attach a block device to it:
Check if the mapped image is compressed:
Unmap the compressed image and uncompress it:
Example 6 Creating an Encrypted UFS File System on a FileThis example is similar to the example of making a UFS filesystem on a file, above. Create the file:
Attach the file to a block device and specify that the file image is encrypted. As a result of this command, you obtain the character device, which is subsequently used by newfs:
The mapped file system shows that encryption is enabled:
Mount and use the filesystem:
Subsequent attempts to map the filesystem with the wrong key or the wrong encryption algorithm will fail:
Attempts to map the filesystem without encryption will succeed, however attempts to mount and use the filesystem will fail:
Environment VariablesSee environ(5) for descriptions of the following environment variables that affect the execution of lofiadm: LC_CTYPE, LC_MESSAGES and NLSPATH. Exit StatusAttributesSee attributes(5) for descriptions of the following attributes:
See Alsofsck ### UNMATCHED MARKUP: manvolnum ### , mount ### UNMATCHED MARKUP: manvolnum ### , mount_ufs ### UNMATCHED MARKUP: manvolnum ### , newfs ### UNMATCHED MARKUP: manvolnum ### , attributes(5), lofi(7D), lofs(7FS) NotesJust as you would not directly access a disk device that has mounted file systems, you should not access a file associated with a block device except through the lofi file driver. It might also be appropriate to ensure that the file has appropriate permissions to prevent such access. The abilities of lofiadm, and who can use them, are controlled by the permissions of /dev/lofictl. Read-access allows query operations, such as listing all the associations. Write-access is required to do any state-changing operations, like adding an association. As shipped, /dev/lofictl is owned by root, in group sys, and mode 0644, so all users can do query operations but only root can change anything. The administrator can give users write-access, allowing them to add or delete associations, but that is very likely a security hole and should probably only be given to a trusted group. When mounting a filesystem image, take care to use appropriate mount options. In particular, the nosuid mount option might be appropriate for UFS images whose origin is unknown. Also, some options might not be useful or appropriate, like logging or forcedirectio for UFS. For compatibility purposes, a raw device is also exported along with the block device. For example, newfs ### UNMATCHED MARKUP: manvolnum ### requires one. The output of lofiadm (without arguments) might change in future releases. Name | Synopsis | Description | Options | Operands | Examples | Environment Variables | Exit Status | Attributes | See Also | Notes |
||||||||||||||||||||||||||||