JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 1M: System Administration Commands     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

Introduction

System Administration Commands - Part 1

6to4relay(1M)

acct(1M)

acctadm(1M)

acctcms(1M)

acctcon1(1M)

acctcon(1M)

acctcon2(1M)

acctdisk(1M)

acctdusg(1M)

acctmerg(1M)

accton(1M)

acctprc1(1M)

acctprc(1M)

acctprc2(1M)

acctsh(1M)

acctwtmp(1M)

acpihpd(1M)

adbgen(1M)

add_allocatable(1M)

addbadsec(1M)

add_drv(1M)

aimanifest(1M)

arp(1M)

asradm(1M)

asr-notify(1M)

atohexlabel(1M)

audit(1M)

auditconfig(1M)

auditd(1M)

auditrecord(1M)

auditreduce(1M)

auditstat(1M)

audit_warn(1M)

automount(1M)

automountd(1M)

autopush(1M)

bart(1M)

beadm(1M)

boot(1M)

bootadm(1M)

bootconfchk(1M)

bootparamd(1M)

busstat(1M)

captoinfo(1M)

catman(1M)

cfgadm(1M)

cfgadm_ac(1M)

cfgadm_cardbus(1M)

cfgadm_fp(1M)

cfgadm_ib(1M)

cfgadm_pci(1M)

cfgadm_sata(1M)

cfgadm_sbd(1M)

cfgadm_scsi(1M)

cfgadm_sdcard(1M)

cfgadm_shp(1M)

cfgadm_sysctrl(1M)

cfgadm_usb(1M)

chargefee(1M)

chat(1M)

check-hostname(1M)

check-permissions(1M)

chk_encodings(1M)

chroot(1M)

cimworkshop(1M)

ckpacct(1M)

clear_locks(1M)

clinfo(1M)

closewtmp(1M)

clri(1M)

comsat(1M)

configCCR(1M)

consadm(1m)

console-reset(1M)

coreadm(1M)

cpustat(1M)

croinfo(1M)

cron(1M)

cryptoadm(1M)

datadm(1M)

dcopy(1M)

dcs(1M)

dd(1M)

ddu(1M)

ddu-text(1M)

devchassisd(1M)

devfsadm(1M)

devfsadmd(1M)

device_allocate(1M)

device_remap(1M)

devinfo(1M)

devlinks(1M)

devnm(1M)

devprop(1M)

df(1M)

dfmounts(1M)

dfmounts_nfs(1M)

dfshares(1M)

dfshares_nfs(1M)

df_ufs(1M)

dhcpagent(1M)

dhcpconfig(1M)

dhcpmgr(1M)

dhtadm(1M)

dig(1M)

directoryserver(1M)

diskinfo(1M)

disks(1M)

diskscan(1M)

dispadmin(1M)

distro_const(1M)

dladm(1M)

dlmgmtd(1M)

dlstat(1M)

dmesg(1M)

dminfo(1M)

dns-sd(1M)

dnssec-dsfromkey(1M)

dnssec-keyfromlabel(1M)

dnssec-keygen(1M)

dnssec-makekeyset(1M)

dnssec-signkey(1M)

dnssec-signzone(1M)

dodisk(1M)

domainname(1M)

drd(1M)

drvconfig(1M)

dsbitmap(1M)

dscfg(1M)

dscfgadm(1M)

dscfglockd(1M)

dsstat(1M)

dsvclockd(1M)

dtrace(1M)

dumpadm(1M)

editmap(1M)

edquota(1M)

eeprom(1M)

efdaemon(1M)

embedded_su(1M)

emCCR(1M)

emocmrsp(1M)

etrn(1M)

fbconfig(1M)

fbconf_xorg(1M)

fcadm(1M)

fcinfo(1M)

fdetach(1M)

fdisk(1M)

ff(1M)

ff_ufs(1M)

fingerd(1M)

fiocompress(1M)

flowadm(1M)

flowstat(1M)

fmadm(1M)

fmd(1M)

fmdump(1M)

fmstat(1M)

fmthard(1M)

format(1M)

fruadm(1M)

fsck(1M)

fsck_pcfs(1M)

fsck_udfs(1M)

fsck_ufs(1M)

fsdb(1M)

fsdb_udfs(1M)

fsdb_ufs(1M)

fsflush(1M)

fsirand(1M)

fssnap(1M)

fssnap_ufs(1M)

fsstat(1M)

fstyp(1M)

fuser(1M)

fwflash(1M)

fwtmp(1M)

getdevpolicy(1M)

getent(1M)

gettable(1M)

getty(1M)

gkadmin(1M)

groupadd(1M)

groupdel(1M)

groupmod(1M)

growfs(1M)

grpck(1M)

gsscred(1M)

gssd(1M)

hald(1M)

hal-device(1M)

hal-fdi-validate(1M)

hal-find(1M)

hal-find-by-capability(1M)

hal-find-by-property(1M)

hal-get-property(1M)

hal-set-property(1M)

halt(1M)

hextoalabel(1M)

host(1M)

hostconfig(1M)

hotplug(1M)

hotplugd(1M)

htable(1M)

ickey(1M)

id(1M)

idmap(1M)

idmapd(1M)

idsconfig(1M)

ifconfig(1M)

if_mpadm(1M)

ifparse(1M)

iiadm(1M)

iicpbmp(1M)

iicpshd(1M)

ikeadm(1M)

ikecert(1M)

ilbadm(1M)

ilbd(1M)

ilomconfig(1M)

imqadmin(1M)

imqbrokerd(1M)

imqcmd(1M)

imqdbmgr(1M)

imqkeytool(1M)

imqobjmgr(1M)

imqusermgr(1M)

in.chargend(1M)

in.comsat(1M)

in.daytimed(1M)

in.dhcpd(1M)

in.discardd(1M)

in.echod(1M)

inetadm(1M)

inetconv(1M)

inetd(1M)

in.fingerd(1M)

infocmp(1M)

in.iked(1M)

init(1M)

init.sma(1M)

init.wbem(1M)

inityp2l(1M)

in.lpd(1M)

in.mpathd(1M)

in.named(1M)

in.ndpd(1M)

in.rarpd(1M)

in.rdisc(1M)

in.rexecd(1M)

in.ripngd(1M)

in.rlogind(1M)

in.routed(1M)

in.rshd(1M)

in.rwhod(1M)

install(1M)

installadm(1M)

installboot(1M)

installf(1M)

installgrub(1M)

in.stdiscover(1M)

in.stlisten(1M)

in.talkd(1M)

in.telnetd(1M)

in.tftpd(1M)

in.timed(1M)

intrd(1M)

intrstat(1M)

in.uucpd(1M)

iostat(1M)

ipaddrsel(1M)

ipadm(1M)

ipf(1M)

ipfs(1M)

ipfstat(1M)

ipmgmtd(1M)

ipmon(1M)

ipmpstat(1M)

ipnat(1M)

ippool(1M)

ipqosconf(1M)

ipsecalgs(1M)

ipsecconf(1M)

ipseckey(1M)

iscsiadm(1M)

isns(1M)

isnsadm(1M)

itadm(1M)

itu(1M)

js2ai(1M)

k5srvutil(1M)

kadb(1M)

kadmin(1M)

kadmind(1M)

kadmin.local(1M)

kcfd(1M)

kclient(1M)

kdb5_ldap_util(1M)

kdb5_util(1M)

kdcmgr(1M)

kernel(1M)

keyserv(1M)

killall(1M)

kmem_task(1M)

kmscfg(1M)

kprop(1M)

kpropd(1M)

kproplog(1M)

krb5kdc(1M)

ksslcfg(1M)

kstat(1M)

ktkt_warnd(1M)

labeld(1M)

labelit(1M)

labelit_hsfs(1M)

labelit_udfs(1M)

labelit_ufs(1M)

lastlogin(1M)

latencytop(1M)

ldapaddent(1M)

ldap_cachemgr(1M)

ldapclient(1M)

ldmad(1M)

link(1M)

llc2_loop(1M)

lldpadm(1M)

lldpd(1M)

lms(1M)

locator(1M)

lockd(1M)

lockfs(1M)

lockstat(1M)

lofiadm(1M)

logadm(1M)

logins(1M)

lshal(1M)

System Administration Commands - Part 2

System Administration Commands - Part 3

lofiadm

- administer files available as block devices through lofi

Synopsis

/usr/sbin/lofiadm -a | -r file [device]
/usr/sbin/lofiadm -c crypto_algorithm -a file | -r [device]
/usr/sbin/lofiadm -c crypto_algorithm -k raw_key_file
     -a | -r file [device]
/usr/sbin/lofiadm -c crypto_algorithm -T token_key -a | -r file [device]
/usr/sbin/lofiadm -c crypto_algorithm -T token_key
     -k wrapped_key_file -a | -r 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]
/usr/sbin/lofiadm -r device]

Description

lofiadm 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 CD-ROM image), because the block device can then be used with the normal system utilities for mounting, checking or repairing file systems. See fsck(1M) and mount(1M).

Use lofiadm to add a file as a loopback device, remove such an association, or display information about the current associations.

Two types of loopback devices can be created: a normal read-write loopback device and a removable loopback device. They differ in the following ways.

Firstly, a file cannot be dissociated from a normal loopback device during its lifetime. By contrast, a file can be dissociated from a removable loopback device, which leaves it as an empty loopback device. Following disassociation, a different file can be associated with it. Note that eject(1) should be used to dissociate a file from a removable device.

Secondly, there is one-to-one mapping between a normal loopback device and its associated file. By contrast, a single file can be associated with multiple removable loopback devices at the same time.

Thirdly, a normal loopback device is writable. A removable loopback device is read-only.

The number of potential lofi devices is limited by the zone.max-lofi rctl, which can be set by means of zonecfg(1M) in the global zone. See resource_controls(5) for a description of zone.max-lofi.

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.

In the global zone, lofiadm can be used on both the global zone devices and all devices owned by other non-global zones on the system.

Options

The following options are supported:

-a | -r file [device]

Add file as a normal loopback device, when -a is specified or a removable loopback device, when -r is specified.

If device is not specified, a non-existing device is picked.

If device is specified, lofiadm attempts to assign it to file. If -a is specified, device must not exist or lofiadm will fail. If -r is specified, lofiadm will fail if device exists and is not an empty removable loopback device.

-C {gzip | gzip-N | lzma}

Compress the file with the specified compression algorithm.

The gzip compression algorithm uses the same compression as the open-source gzip command. You can specify the gzip level by using the value gzip-N where N is 6 (fast) or 9 (best compression ratio). Currently, gzip, without a number, is equivalent to gzip-6 (which is also the default for the gzip command).

lzma stands for the LZMA (Lempel-Ziv-Markov) compression algorithm.

Note that you cannot write to a compressed file, nor can you mount a compressed file read/write.

Note that removal by file will fail if multiple devices is currently associated with it. Use removal by device in this case.

-d file | device

Remove an association by file or device name, if the associated block device is not busy, and deallocates the block device.

-s segment_size

The segment size to use to divide the file being compressed. segment_size can be an integer multiple of 512.

-U file

Uncompress a compressed file.

The following options are used when the file is encrypted:

-c crypto_algorithm

Select the encryption algorithm. The algorithm must be specified when encryption is enabled because the algorithm is not stored in the disk image.

If none of -e, -k, or -T is specified, lofiadm prompts for a passphrase, with a minimum length of eight characters, to be entered . The passphrase is used to derive a symmetric encryption key using PKCS#5 PBKD2.

-k raw_key_file | wrapped_key_file

Path to raw or wrapped symmetric encryption key. If a PKCS#11 object is also given with the -T option, then the key is wrapped by that object. If -T is not specified, the key is used raw.

-T token_key

The key in a PKCS#11 token to use for the encryption or for unwrapping the key file.

If -k is also specified, -T identifies the unwrapping key, which must be an RSA private key.

-e

Generate an ephemeral symmetric encryption key. Note that you cannot use -e together with -r.

-r [device]

Create an empty removable loopback device. A file can be associated with that device at a later time.

If device is not specified, a non-existing device is selected.

If device is specified, lofiadm attempts to select it. device must not exist or lofiadm will fail.

Operands

The following operands are supported:

crypto_algorithm

One of: aes-128-cbc, aes-192-cbc, aes-256-cbc, des3-cbc, blowfish-cbc.

device

Display the file name associated with the block device device.

Without arguments, print a list of the current associations. Filenames must be valid absolute pathnames.

When a file is added, it is opened for reading or writing by root. Any restrictions apply (such as restricted root access over NFS). The file is held open until the association is removed. It is not actually accessed until the block device is used, so it will never be written to if the block device is only opened read-only.

Note that the filename might appear as a question mark (?) if it is not possible to resolve the path in the current context (for example, if it is an NFS path in a non-global zone). Or, the filename might appear as a dash (-) if the device is an empty removable loopback device.

file

Display all block device(s) associated with file.

raw_key_file

Path to a file of the appropriate length, in bits, to use as a raw symmetric encryption key.

token_key

PKCS#11 token object in the format:

token_name:manufacturer_id:serial_number:key_label

All but the key label are optional and can be empty. For example, to specify a token object with only its key label MylofiKey, use:

-T :::MylofiKey
wrapped_key_file

Path to file containing a symmetric encryption key wrapped by the RSA private key specified by -T.

Examples

Example 1 Mounting an Existing CD-ROM Image

You 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 -a /home/mike_s/RH6.0/sparc.iso
/dev/lofi/1

lofiadm picks the device and prints the device name to the standard output. You can run lofiadm again by issuing the following command:

# lofiadm
Block Device     File                           Options
/dev/lofi/1      /home/mike_s/RH6.0/sparc.iso   -

Or, you can give it one name and ask for the other, by issuing the following command:

# lofiadm /dev/lofi/1
/home/mike_s/RH6.0/sparc.iso

Use the mount command to mount the image:

# mount -F hsfs -o ro /dev/lofi/1 /mnt

Check to ensure that Solaris understands the image:

# df -k /mnt
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/lofi/1           512418  512418       0   100%    /mnt 
# ls /mnt
./            RedHat/       doc/          ls-lR         rr_moved/ 
../           TRANS.TBL     dosutils/     ls-lR.gz      sbin@ 
.buildlog     bin@          etc@          misc/         tmp/ 
COPYING       boot/         images/       mnt/          usr@ 
README        boot.cat*     kernels/      modules/ 
RPM-PGP-KEY   dev@          lib@          proc/

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:

# umount /mnt
# lofiadm -d /dev/lofi/1
# lofiadm
Block Device             File             Options

Example 2 Making a UFS Filesystem on a File

Making 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:

# mkfile 35m /export/home/test

Attach it to a block device. You also get the character device that newfs requires, so newfs that:

# lofiadm -a /export/home/test
/dev/lofi/1
# newfs /dev/rlofi/1
newfs: construct a new file system /dev/rlofi/1: (y/n)? y
/dev/rlofi/1:   71638 sectors in 119 cylinders of 1 tracks, 602 sectors
        35.0MB in 8 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 9664, 19296, 28928, 38560, 48192, 57824, 67456,

Note that ufs might not be able to use the entire file. Mount and use the filesystem:

# mount /dev/lofi/1 /mnt
# df -k /mnt
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/lofi/1            33455       9   30101     1%    /mnt
# ls /mnt
./           ../          lost+found/
# umount /mnt
# lofiadm -d /dev/lofi/1

Example 3 Creating a PC (FAT) File System on a Unix File

The following series of commands creates a FAT file system on a Unix file. The file is associated with a block device created by lofiadm.

# mkfile 10M /export/test/testfs
# lofiadm -a /export/test/testfs
/dev/lofi/1
Note use of rlofi, not lofi, in following command.
# mkfs -F pcfs -o nofdisk,size=20480 /dev/rlofi/1
Construct a new FAT file system on /dev/rlofi/1: (y/n)? y
# mount -F pcfs /dev/lofi/1 /mnt
# cd /mnt
# df -k .
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/lofi/1            10142       0   10142     0%    /mnt

Example 4 Compressing an Existing CD-ROM Image

The following example illustrates compressing an existing CD-ROM image (solaris.iso), verifying that the image is compressed, and then uncompressing it.

# lofiadm -C gzip /export/home/solaris.iso

Use lofiadm to attach a block device to it:

# lofiadm -a /export/home/solaris.iso
  /dev/lofi/1

Check if the mapped image is compressed:

# lofiadm
Block Device      File                            Options
/dev/lofi/1       /export/home/solaris.iso        Compressed(gzip)
/dev/lofi/2       /export/home/regular.iso        -

Unmap the compressed image and uncompress it:

# lofiadm -d /dev/lofi/1
# lofiadm -U /export/home/solaris.iso

Example 5 Creating an Encrypted UFS File System on a File

This example is similar to the example of making a UFS filesystem on a file, above.

Create the file:

# mkfile 35m /export/home/test

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:

# lofiadm -c aes-256-cbc -a /export/home/secrets
Enter passphrase: My-M0th3r;l0v3s_m3+4lw4ys!           (not echoed)
Re-enter passphrase: My-M0th3r;l0v3s_m3+4lw4ys!        (not echoed)
/dev/lofi/1

# newfs /dev/rlofi/1
newfs: construct a new file system /dev/rlofi/1: (y/n)? y
/dev/rlofi/1:   71638 sectors in 119 cylinders of 1 tracks, 602 sectors
       35.0MB in 8 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 9664, 19296, 28928, 38560, 48192, 57824, 67456,

The mapped file system shows that encryption is enabled:

# lofiadm
Block Device    File                     Options
/dev/lofi/1     /export/home/secrets     Encrypted

Mount and use the filesystem:

# mount /dev/lofi/1 /mnt
# cp moms_secret_*_recipe /mnt
# ls /mnt
./           moms_secret_cookie_recipe    moms_secret_soup_recipe
../          moms_secret_fudge_recipe     moms_secret_stuffing_recipe
lost+found/  moms_secret_meatloaf_recipe  moms_secret_waffle_recipe
# umount /mnt
# lofiadm -d /dev/lofi/1

Subsequent attempts to map the filesystem with the wrong key or the wrong encryption algorithm will fail:

# lofiadm -c blowfish-cbc -a /export/home/secrets
Enter passphrase: mommy                                (not echoed)
Re-enter passphrase: mommy                             (not echoed)
lofiadm: could not map file /root/lofi: Invalid argument
# lofiadm
Block Device    File                    Options
#

Attempts to map the filesystem without encryption will succeed, however attempts to mount and use the filesystem will fail:

# lofiadm -a /export/home/secrets
/dev/lofi/1
# lofiadm
Block Device    File                     Options
/dev/lofi/1     /export/home/secrets     -
# mount /dev/lofi/1 /mnt
mount: /dev/lofi/1 is not this fstype
#

Example 6 Manipulating a Removable Loopback Device

The following example illustrates how to create an empty removable loopback device, associate a file with it, and then dissociate the file from the device.

Use lofiadm to create an empty removable loopback device:

# lofiadm -r
/dev/lofi/1

Verify that the device has been created:

# lofiadm
Block Device      File                       Options
/dev/lofi/1       -                          Removable,Readonly

Use lofiadm to associate a file with the device:

# lofiadm -r /export/home/solaris.iso /dev/lofi/1
/dev/lofi/1

Verify that the association has succeeded:

# lofiadm
Block Device      File                            Options
/dev/lofi/1       /export/home/solaris.iso        Removable,Readonly

Use eject to dissociate the file from the device:

# eject /dev/lofi/1

Verify that the dissociation succeeded:

# lofiadm
Block Device      File                            Options
/dev/lofi/1       -                               Removable,Readonly

Environment Variables

See environ(5) for descriptions of the following environment variables that affect the execution of lofiadm: LC_CTYPE, LC_MESSAGES and NLSPATH.

Exit Status

The following exit values are returned:

0

Successful completion.

>0

An error occurred.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/core-os

See Also

eject(1), fsck(1M), mount(1M), mount_ufs(1M), newfs(1M), zonecfg(1M), attributes(5), resource_controls(5), lofi(7D), lofs(7FS)

Notes

Just 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(1M) requires one.

The output of lofiadm (without arguments) might change in future releases.