<chapter id="medformat-83002"><title>Managing Removable Media (Tasks)</title><highlights><para>This chapter describes how to manage removable media from the command
line in the Solaris OS.</para><para>For information on the procedures associated with managing removable
media, see <olink targetptr="medformat-1" remap="internal">Managing Removable Media (Task Map)</olink>.
For background information on removable media, see <olink targetptr="medintro-55492" remap="internal">Chapter&nbsp;1, Managing Removable Media (Overview)</olink>.</para>
</highlights><sect1 id="medformat-1"><title>Managing Removable Media (Task Map)</title><para>The following task map describes the tasks for managing removable media.</para><informaltable frame="all"><tgroup cols="3" colsep="1" rowsep="1"><colspec colname="colspec0" colwidth="110*"/><colspec colname="col2" colwidth="167*"/><colspec colname="colspec1" colwidth="119*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry rowsep="1"><para>1. Load media.</para>
</entry><entry rowsep="1"><para>Insert the diskette into the drive and type the <command>volcheck</command> command.</para>
</entry><entry rowsep="1"><para><olink targetptr="medformat-53705" remap="internal">How to Load Removable Media</olink></para>
</entry>
</row><row rowsep="0"><entry rowsep="1"><para>2. (Optional) Format the diskette.</para>
</entry><entry rowsep="1"><para>Format diskette.</para>
</entry><entry rowsep="1"><para><olink targetptr="medintro-51" remap="internal">How to Format a Diskette (rmformat)</olink></para>
</entry>
</row><row><entry rowsep="1"><para>3. (Optional) Add a UFS or PCFS file system.</para>
</entry><entry rowsep="1"><para>Add a UFS or PCFS file system to use the media for transferring files.</para>
</entry><entry rowsep="1"><para><olink targetptr="medintro-57" remap="internal">How to Create a File System on Removable
Media</olink></para>
</entry>
</row><row><entry>
</entry><entry><para>Add a UFS or UDFS file system to a DVD-RAM device.</para>
</entry><entry><para><olink targetptr="gczgu" remap="internal">How to Create a File System on a DVD-RAM</olink></para>
</entry>
</row><row><entry><para>4. (Optional) Check the media.</para>
</entry><entry><para>Verify the integrity of the file system on the media.</para>
</entry><entry><para><olink targetptr="medintro-73" remap="internal">How to Check a File System on Removable
Media</olink></para>
</entry>
</row><row><entry><para>5. (Optional) Repair bad blocks on the media.</para>
</entry><entry><para>Repair any bad blocks on the media, if necessary.</para>
</entry><entry><para><olink targetptr="medintro-78" remap="internal">How to Repair Bad Blocks on Removable
Media</olink></para>
</entry>
</row><row><entry><para>6. (Optional) Apply read or write and password protection.</para>
</entry><entry><para>Apply read or write protection or password protection on the media,
if necessary.</para>
</entry><entry><para><olink targetptr="medintro-85" remap="internal">How to Enable or Disable Write Protection
on Removable Media</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="medformat-80"><title>Formatting Diskettes</title><para>You can use the <command>rmformat</command> command to format and protect
rewritable diskettes.  File
systems are mounted automatically. So, you might have to unmount media before
you can format it, if the media contains an existing file system.</para><para>The <command>rmformat</command> command has three formatting options:</para><itemizedlist><listitem><para><command>quick</command> &ndash; This option formats diskettes
without certification or with limited certification of certain tracks on the
media.</para>
</listitem><listitem><para><command>long</command> &ndash; This option completely formats
diskettes. For some devices, the use of this option might include the certification
of the whole media by the drive.</para>
</listitem><listitem><para><command>force</command> &ndash; This option formats completely
without user confirmation. For diskettes with a password-protection mechanism,
this option clears the password before formatting. This feature is useful
when a password is forgotten. On diskettes without password protection, this
option forces a long format.</para>
</listitem>
</itemizedlist><sect2 id="medformat-82"><title>Removable Media Hardware Considerations</title><para>Keep the following restrictions in mind when working with diskettes:</para><itemizedlist><listitem><para>SPARC and x86 UFS formats are different. SPARC uses little-endian
bit coding, x86 uses big-endian. Media formatted for UFS is restricted to
the hardware platform on which they were formatted. So, a diskette formatted
for UFS on a SPARC based platform cannot be used for UFS on an x86 platform.
Likewise, a diskette formatted for UFS on an x86 platform cannot be used
on a SPARC platform. </para>
</listitem><listitem><para>A complete format for <trademark>SunOS</trademark> file systems
consists of the basic &ldquo;bit&rdquo; formatting in addition the structure
to support a SunOS file system. A complete format for a DOS file system consists
of the basic &ldquo;bit&rdquo; formatting in addition the structure to support
either an MS-DOS or an NEC-DOS file system. The procedures required to prepare
a media for each type of file system are different. Therefore, before you
format a diskette, consider which procedure to follow. For more information,
see <olink targetptr="medformat-1" remap="internal">Managing Removable Media (Task Map)</olink>.</para>
</listitem>
</itemizedlist><sect3 id="medformat-37303"><title>Diskette Hardware Considerations</title><para>Keep the following in mind when formatting diskettes:</para><itemizedlist><listitem><para>For information on diskette names, see <olink targetptr="medaccess-37633" remap="internal">Table&nbsp;3&ndash;1</olink>.</para>
</listitem><listitem><para>Diskettes that are not named (that is, they have no &ldquo;label&rdquo;)
are assigned the default name of <literal>floppy</literal>.</para>
</listitem>
</itemizedlist><para>A Solaris system can format the following diskette types:</para><itemizedlist><listitem><para>UFS</para>
</listitem><listitem><para>MS-DOS or NEC-DOS (PCFS)</para>
</listitem><listitem><para>UDFS</para>
</listitem>
</itemizedlist><para>On a Solaris system (either SPARC or x86), you can format diskettes
with the following densities.</para><informaltable frame="topbot"><tgroup cols="3" colsep="0" rowsep="0"><colspec colname="column1" colwidth="132*"/><colspec colname="column2" colwidth="176*"/><colspec colname="column3" colwidth="88*"/><thead><row rowsep="1"><entry><para>Diskette Size</para>
</entry><entry><para>Diskette Density</para>
</entry><entry><para>Capacity</para>
</entry>
</row>
</thead><tbody><row><entry><para>3.5&rdquo;</para>
</entry><entry><para>High density (HD)</para>
</entry><entry><para>1.44 Mbytes</para>
</entry>
</row><row><entry><para>3.5&rdquo;</para>
</entry><entry><para>Double density (DD)</para>
</entry><entry><para>720 Kbytes</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable><para>By default, the diskette drive formats a diskette to a like density.
This default means that a 1.44 Mbyte drive attempts to format a diskette for
1.44 Mbytes, regardless of whether the diskette is, in fact, a 1.44 Mbyte
diskette, unless you instruct it otherwise. In other words, a diskette can
be formatted to its capacity or lower, and a drive can format to its capacity
or lower.</para>
</sect3>
</sect2><task id="medformat-53705"><title>How to Load Removable Media</title><tasksummary><para>For information about removable media hardware considerations, see <olink targetptr="medformat-82" remap="internal">Removable Media Hardware Considerations</olink>.</para>
</tasksummary><procedure><step id="medformat-step-33"><para>Insert the media.</para>
</step><step id="medformat-step-32"><para>Ensure that the media is formatted.   </para><para>If
you aren't sure, insert the media and check the status messages in the system
console window, as described in <olink targetptr="medformat-step-34" remap="internal">Step&nbsp;3</olink>.
If you need to format the media, go to <olink targetptr="medintro-51" remap="internal">How
to Format a Diskette (rmformat)</olink>.</para>
</step><step performance="optional" id="medformat-step-34"><para>Notify volume management
if you are using a legacy, non-USB diskette device.</para><screen>$ <userinput>volcheck -v</userinput></screen><para>Two status messages are possible:</para><variablelist><varlistentry><term><literal>media was found</literal></term><listitem><para>Volume management detected the media and will attempt to mount
it in the directory described in <olink targetptr="medaccess-37633" remap="internal">Table&nbsp;3&ndash;1</olink>.</para><para>If the media is formatted properly, no error messages appear in the
console.</para><para>If the media is not formatted, the &ldquo;<literal>media was found</literal>&rdquo;
message is still displayed. However, error messages similar to the following
appear in the system console window:</para><para><literal>fd0: unformatted diskette or no diskette in the drive</literal></para><para><literal>fd0: read failed (40 1 0)</literal></para><para><literal>fd0: bad format</literal></para><para>You must format the media before volume management can mount it.  For
more information, see <olink targetptr="medformat-83002" remap="internal">Chapter&nbsp;2, Managing
Removable Media (Tasks)</olink>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>no media was found</literal></term><listitem><para>Volume management did not detect the media. Ensure that the
media is inserted properly, and run <command>volcheck</command> again. If
unsuccessful, check the media, which could be damaged. You can also try to
mount the media manually.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step id="medformat-step-81"><para>Verify that the media
was mounted by listing its contents.</para><para>For example, do the following
for a diskette:</para><screen>$ ls /media/floppy
lost+found myfiles</screen>
</step>
</procedure>
</task><task id="medintro-51"><title>How to Format a Diskette (<command>rmformat</command>)</title><tasksummary><para>You can use the <command>rmformat</command> command to format a diskette.
By default, this command creates two partitions on the media: partition 0
and partition 2 (the whole media).</para>
</tasksummary><procedure><step id="medintro-step-53"><para>Verify that removable media service is running.
If so, you can use the shorter nickname for the device name.</para><screen># <userinput>svcs hal dbus rmvolmgr</userinput>
STATE          STIME    FMRI
online         Apr_09   svc:/system/dbus:default
online         Apr_09   svc:/system/hal:default
online         Apr_09   svc:/system/filesystem/rmvolmgr:default</screen><para>For information on restarting removable media services, see <olink targetptr="medaccess-12244" remap="internal">How to Disable or Enable Removable Media Services</olink>.
For information on identifying media device names, see <olink targetptr="medaccess-3" remap="internal">Using Removable Media Names</olink>.</para>
</step><step id="medintro-step-54"><para>Format the diskette.</para><screen>$ <userinput>rmformat -F [ quick | long | force ]</userinput> <replaceable>device-name</replaceable></screen><para>See <olink targetptr="medformat-80" remap="internal">Formatting Diskettes</olink> for
more information on <command>rmformat</command> formatting options.</para><para>If
the <command>rmformat</command> output indicates bad blocks, see <olink targetptr="medintro-78" remap="internal">How to Repair Bad Blocks on Removable Media</olink>.</para>
</step><step id="medintro-step-55"><para>(Optional) Label the diskette with an 8-character
label.</para><screen>$ <userinput>rmformat -b</userinput> <replaceable>label</replaceable> <replaceable>device-name</replaceable></screen><para>For information on creating a DOS label, see <olink targetdoc="refman1m" targetptr="mkfs-pcfs-1m" remap="external"><citerefentry><refentrytitle>mkfs_pcfs</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>.</para>
</step>
</procedure><example id="fncpq"><title>Formatting a Diskette</title><para>This example shows how to format a diskette.</para><screen>$ <userinput>rmformat -F quick /dev/rdiskette</userinput>
Formatting will erase all the data on disk.
Do you want to continue? (y/n) <userinput>y</userinput>
.........................................................................</screen>
</example>
</task><task id="medintro-57"><title>How to Create a File System on Removable Media</title><procedure><step performance="optional" id="medintro-step-59"><para>Format the diskette.</para><screen>$ <userinput>rmformat -F quick</userinput> <replaceable>device-name</replaceable></screen>
</step><step id="medintro-step-60"><para>(Optional) Create an alternate Solaris partition
table.</para><screen>$ <userinput>rmformat -s</userinput> <replaceable>slice-file</replaceable> <replaceable>device-name</replaceable></screen><para>A sample slice file appears similar to the following:</para><screen>slices: 0 = 0, 30MB, "wm", "home" : 
              1 = 30MB, 51MB : 
              2 = 0, 94MB, "wm", "backup" : 
              6 = 81MB, 13MB</screen>
</step><step id="medintro-step-61"><para>Become superuser.</para>
</step><step id="medintro-step-62"><para>Determine the appropriate file system type
and select one of the following:</para><itemizedlist><listitem><para>Create a UFS file system. For example:</para><screen># newfs /dev/rdiskette0</screen>
</listitem><listitem><para>Create a PCFS file system. For example:</para><screen># <userinput>mkfs -F pcfs /dev/rdsk/c0t4d0s2:c</userinput></screen>
</listitem><listitem><para>Create a UDFS file system. For example:</para><screen># <userinput>mkfs -F udfs /dev/rdsk/c0t1d0s1</userinput></screen>
</listitem>
</itemizedlist>
</step>
</procedure><example id="fncpp"><title>Formatting a Diskette for a UFS File System</title><para>The following example shows how to format a diskette and create a UFS
file system on the diskette.</para><screen>$ <userinput>rmformat -F quick /dev/rdiskette</userinput>
Formatting will erase all the data on disk.
Do you want to continue? (y/n)<userinput>y</userinput>
$ <userinput>su</userinput>
# <userinput>/usr/sbin/newfs /dev/rdiskette</userinput>
newfs: construct a new file system /dev/rdiskette: (y/n)? <userinput>y</userinput>
/dev/rdiskette: 2880 sectors in 80 cylinders of 2 tracks, 18 sectors
        1.4MB in 5 cyl groups (16 c/g, 0.28MB/g, 128 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 640, 1184, 1792, 2336,</screen>
</example><example id="fncpz"><title>Formatting a Diskette for a PCFS File System</title><para>This example shows how to create a PCFS file system with an alternate <literal>fdisk</literal> partition. In these examples, <command>vold</command> is not
running.</para><screen>$ <userinput>rmformat -F quick /dev/rdsk/c0t4d0s2:c</userinput>
Formatting will erase all the data on disk.
Do you want to continue? (y/n) <userinput>y</userinput>
$ <userinput>su</userinput>
# <userinput>fdisk /dev/rdsk/c0t4d0s2:c</userinput> 
# <userinput>mkfs -F pcfs /dev/rdsk/c0t4d0s2:c</userinput>
Construct a new FAT file system on /dev/rdsk/c0t4d0s2:c: (y/n)? <userinput>y</userinput>
#</screen><para>This example shows how to create a PCFS file system without an <literal>fdisk</literal> partition.</para><screen>$ <userinput>rmformat -F quick /dev/rdiskette</userinput>
Formatting will erase all the data on disk.
Do you want to continue? (y/n) <userinput>y</userinput>
$ <userinput>su</userinput>
# <userinput>mkfs -F pcfs -o nofdisk,size=2 /dev/rdiskette</userinput>
Construct a new FAT file system on /dev/rdiskette: (y/n)? <userinput>y</userinput>
#</screen>
</example>
</task><task id="gczgu"><title>How to Create a File System on a DVD-RAM</title><tasksummary><para>Use this procedure to create a file system on a DVD-RAM.</para>
</tasksummary><procedure><step><para>Become superuser.</para>
</step><step><para>Create a file system on the DVD-RAM device.</para><itemizedlist><listitem><para>Create a UFS file system. For example:</para><screen># <userinput>newfs /dev/rdsk/c0t0d0s2</userinput></screen>
</listitem><listitem><para>Create a UDFS file system. For example:</para><screen># <userinput>mkfs -F udfs /dev/rdsk/c0t0d0s2</userinput></screen>
</listitem>
</itemizedlist>
</step><step><para>Mount the file system.</para><itemizedlist><listitem><para>Mount a UFS file system. For example:</para><screen># <userinput>mount -F ufs /dev/dsk/c0t0d0s2 /mnt</userinput></screen>
</listitem><listitem><para>Mount a UDFS file system. For example:</para><screen># <userinput>mount -F udfs /dev/dsk/c0t0d0s2 /mnt</userinput></screen>
</listitem>
</itemizedlist>
</step><step><para>Verify that you can read or write to the file system.</para>
</step><step><para>When finished, eject the DVD-RAM.</para>
</step>
</procedure>
</task><task id="medintro-73"><title>How to Check a File System on Removable Media</title><procedure><step id="medintro-step-75"><para>Become superuser.</para>
</step><step id="medformat-step-75"><para>Identify the file system type and select
one of the following:</para><itemizedlist><listitem><para>Check a UFS file system.</para><screen># <userinput>fsck -F ufs</userinput> <replaceable>device-name</replaceable></screen>
</listitem><listitem><para>Check a UDFS file system.</para><screen># <userinput>fsck -F udfs</userinput> <replaceable>device-name</replaceable></screen>
</listitem><listitem><para>Check a PCFS file system.</para><screen># <userinput>fsck -F pcfs</userinput> <replaceable>device-name</replaceable></screen>
</listitem>
</itemizedlist>
</step>
</procedure><example id="fncqa"><title>Checking a PCFS File System on Removable Media</title><para>The following example shows how check the consistency of a PCFS file
system on media. In this example, <command>vold</command> is not running.</para><screen># <userinput>fsck -F pcfs /dev/rdsk/c0t4d0s2</userinput>
** /dev/rdsk/c0t4d0s2
** Scanning file system meta-data
** Correcting any meta-data discrepancies
1457664 bytes.
0 bytes in bad sectors.
0 bytes in 0 directories.
0 bytes in 0 files.
1457664 bytes free.
512 bytes per allocation unit.
2847 total allocation units.
2847 available allocation units.
# </screen>
</example>
</task><task id="medintro-78"><title>How to Repair Bad Blocks on Removable Media</title><tasksummary><para>You can only use the <command>rmformat</command> command to verify,
analyze, and repair bad sectors that are found during verification if the
drive supports bad block management. Most diskettes and USB memory sticks
do not support bad block management.</para><para>If the drive supports bad block management, a best effort is made to
rectify the bad block. If the bad block cannot be rectified despite the best
effort mechanism, a message indicates the failure to repair the media.</para>
</tasksummary><procedure><step id="medintro-step-80"><para>Repair bad blocks on removable media.</para><screen>$ <userinput>rmformat -c</userinput> <replaceable>block-numbers</replaceable> <replaceable>device-name</replaceable></screen><para>Supply the block number in decimal, octal, or hexadecimal format from
a previous <command>rmformat</command> session.</para>
</step><step id="medintro-step-81"><para>Verify the media.</para><screen>$ <userinput>rmformat -V read</userinput> <replaceable>device-name</replaceable></screen>
</step>
</procedure>
</task><sect2 id="medintro-82"><title>Applying Read or Write Protection and Password
Protection to Removable Media</title><para>You can apply read protection or write protection, and set a password,
on removable media that support this feature.</para>
</sect2><task id="medintro-85"><title>How to Enable or Disable Write Protection on
Removable Media</title><procedure><step id="medintro-step-85"><para>Determine whether you want to enable or
disable write protection and select one of the following:</para><itemizedlist><listitem><para>Enable write protection.</para><screen>$ <userinput>rmformat -w enable</userinput> <replaceable>device-name</replaceable></screen>
</listitem><listitem><para>Disable write protection.</para><screen>$ <userinput>rmformat -w disable</userinput> <replaceable>device-name</replaceable></screen>
</listitem>
</itemizedlist>
</step><step id="medintro-step-88"><para>Verify whether the media's write protection
is enabled or disabled.</para><screen>$ <userinput>rmformat -p</userinput> <replaceable>device-name</replaceable></screen>
</step>
</procedure>
</task><task id="medintro-81"><title>How to Enable or Disable Read or Write Protection
and Set a Password on Removable Media</title><tasksummary><para>You can apply a password with a maximum of 32 characters for removable
media that support this feature. </para><para>You will receive a warning message if you attempt to apply a password
on media that does not support this feature.</para>
</tasksummary><procedure><step id="medintro-step-91"><para>Determine whether you want to enable or
disable read protection or write protection and set a password. Select one
of the following:</para><itemizedlist><listitem><para>Enable read protection or write protection.</para><screen>$ <userinput>rmformat -W enable</userinput> <replaceable>device-name</replaceable>
Please enter password (32 chars maximum): <replaceable>xxx</replaceable>
Please reenter password:</screen><screen>$ <userinput>rmformat -R enable</userinput> <replaceable>device-name</replaceable>
Please enter password (32 chars maximum): <replaceable>xxx</replaceable>
Please reenter password:</screen>
</listitem><listitem><para>Disable read protection or write protection and remove the
password.</para><screen>$ <userinput>rmformat -W disable</userinput> <replaceable>device-name</replaceable>
Please enter password (32 chars maximum): <replaceable>xxx</replaceable></screen><screen>$ <userinput>rmformat -R disable</userinput> <replaceable>device-name</replaceable>
Please enter password (32 chars maximum): <replaceable>xxx</replaceable></screen>
</listitem>
</itemizedlist>
</step><step id="medintro-step-94"><para>Verify whether the media's read protection
or write protection is enabled or disabled.</para><screen>$ <userinput>rmformat -p</userinput> <replaceable>device-name</replaceable></screen>
</step>
</procedure><example id="fncpy"><title>Enabling or Disabling Read or Write Protection and Password Protection</title><para>This example shows how to enable write protection and set a password
on a diskette.</para><screen>$ <userinput>rmformat -W enable /dev/rdiskette</userinput>
Please enter password (32 chars maximum): <replaceable>xxx</replaceable>
Please reenter password: <replaceable>xxx</replaceable></screen><para>This example shows to disable read protection and remove the password
on a diskette.</para><screen>$ <userinput>rmformat -R disable /dev/rdiskette</userinput>
Please enter password (32 chars maximum): <replaceable>xxx</replaceable>
Please reenter password: <replaceable>xxx</replaceable></screen>
</example>
</task>
</sect1>
</chapter>