lofiadm (loopback file driver)
(mainly from manpage of lofiadm)
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
/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
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
...
Example 3: Making a UFS Filesystem on a File
Making a UFS filesystm on a file can be useful, particularly if a test suite requires a scratch filesystem. It can be painful (or annoying) to have to re-partition a disk just for the test suite, but you don't 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