Preparing the Disk to Receive Filesystems

Team-Fly    

Solaris™ Operating Environment Boot Camp
By David Rhodes, Dominic Butler
Table of Contents
Chapter 6.  The Filesystem and Its Contents


Solaris provides a menu-based utility (format) that allows you to format, label, and define the slices on a disk. When you run format you are provided with a list of all the disks Solaris can see, numbered from zero upwards, and you are prompted to select the one you wish to work with. As with most commands involving disk and filesystem management, format can only be run by the root user:

 hydrogen# format Searching for disks...done AVAILABLE DISK SELECTIONS: 0. c0t2d0 <Micropolis 2217-15 cyl 2105 alt 3 hd 15 sec 109> /iommu@0,10000000/sbus@0,10001000/espdma@4,8400000/ esp@4,8800000/sd@2,0 Specify disk (enter its number): 

Obviously, we don't have much choice here as our system only has a single hard disk. We can see that its address is c0t2d0 (controller 0, target 2, device 0). If your system only has one disk, then the actions you can perform on it within format are somewhat limited since your operating system will be running from that disk and filesystems will be mounted from it. Once you have entered the number of the disk you wish to work with (in our case 0), format presents the following menu:

 FORMAT MENU:         disk       - select a disk         type       - select (define) a disk type         partition  - select (define) a partition table         current    - describe the current disk         format     - format and analyze the disk         repair     - repair a defective sector         label      - write label to the disk         analyze    - surface analysis         defect     - defect list management         backup     - search for backup labels         verify     - read and display labels         save       - save new disk/partition definitions         inquiry    - show vendor, product and revision         volname    - set 8-character volume name         !<cmd>     - execute <cmd>, then return         quit format> 

Table 6.3 provides a brief overview of each of the commands available at the "format>" prompt.

Table 6.3. Format Menu Options

Format Command

Description

disk

This option allows you to select another disk in the same way you did when you first ran format.

type

This allows you to select a disk type from a list of types that your system knows about. The list of available disk types is held in the file /etc/format.dat.

partition

Typing this brings up the Partition Menu. Any changes you wish to make to the layout or partitions on the disk will be done here, so we will look at this in more detail later.

current

This reminds you which disk is currently selected.

format

This option will cause the current disk to be completely reformatted, so this should be selected with caution. Formatting a disk can take well over an hour and it is not a procedure that can safely be aborted once it has begun.

repair

This option will attempt to repair defects on the disk. If selected, you are prompted to enter the absolute block number of the defect you wish to repair. The block numbers of the defects can be obtained from the defect command menu. This can often fix problems that would normally require a disk to be returned to the manufacturer.

label

This command writes the current disk label back to the disk. If you change any partitions on the disk, you need to use the label command to save them.

analyze

This command takes you to the analyze submenu. This provides a number of options for checking the disk for errors. Some options are safe to run on a disk that is in use and others will corrupt the data, so they can only be used on spare disks. These are clearly marked so you don't accidentally destroy all the data on your system disk.

defect

This command takes you to a submenu that allows you to find out any defects that exist on the disk. It can find out what defects were there when the disk was made and what defects have occurred since.

backup

This command will cause format to search for any backup disk labels. If one is found, it will be used to overwrite (or recreate) the primary disk label. It is, therefore, useful if you mess up the primary disk label and want to revert to the previous one.

verify

This will display the contents of the current primary label. This command is there so you can double-check that you are happy with it before storing it back to the disk.

save

This will save your new partition definitions.

inquiry

This will display the disk manufacturer, product code, and revision level of the currently selected disk.

volname

This allows you to set a volume name for the disk. It can be up to eight characters in length and is stored within the disk label.

!<cmd>

You may run operating system commands without leaving format by entering an exclamation point (!) followed by the command you wish to run.

quit

Self-explanatory, really! Don't type this if you want to stay in the format utility.

The format utility works in the same way as the shell in that it displays a prompt and waits for commands (which match the menu options) to be entered. You do not need to type the whole command; you just need to type enough of it to let format know which one you wish to run. If the menu has disappeared off the screen, you can get format to redisplay it by entering a question mark (?).

Although format can perform a large number of low-level disk activities, it is likely to be most often used to change the disk partition map. When you enter the partition command into the format main menu you are presented with the Partition Menu:

 PARTITION MENU:         0      - change `0' partition         1      - change `1' partition         2      - change `2' partition         3      - change `3' partition         4      - change `4' partition         5      - change `5' partition         6      - change `6' partition         7      - change `7' partition         select - select a predefined table         modify - modify a predefined partition table         name   - name the current table         print  - display the current table         label  - write partition map and label to the disk         !<cmd> - execute <cmd>, then return         quit partition> 

If we want to make any changes to the partition table, we can enter the number of the partition we wish to change and we will be prompted for the new attributes. However, before doing this it is probably best to use the print command to see the attributes of the current partition table:

 partition> print Current partition table (original): Total disk cylinders available: 2105 + 3 (reserved cylinders) Part     Tag  Flag   Cylinders    Size         Blocks 0       root  wm     0 -   62   50.30MB  (63/0/0)    103005 1        var  wm    63 -  143   64.67MB  (81/0/0)    132435 2     backup  wm     0 - 2104    1.64GB  (2105/0/0) 3441675 3       swap  wu   144 -  243   79.83MB  (100/0/0)   163500 4 alternates  wm  1975 - 2100  100.59MB  (126/0/0)   206010 5 unassigned  wm   244 -  294   40.72MB  (51/0/0)     83385 6        usr  wm   295 - 1297  800.73MB  (1003/0/0) 1639905 7       home  wm  1298 - 1974  540.48MB  (677/0/0)  1106895 partition> 

If we wanted to change the attributes of a partition, we would simply enter the partition number and we would then be prompted to enter each of the new values for that partition. If we entered "4" at the partition prompt we would get the following dialogue:

 partition> 4 Part     Tag  Flag   Cylinders    Size          Blocks 4 alternates  wm  1975 - 2100  100.59MB  (126/0/0)   206010 Enter partition id tag[alternates]: Enter partition permission flags[wm]: Enter new starting cyl[1975]: Enter partition size[206010b, 126c, 100.59mb, 0.10gb]: partition> 

The process is made fairly easy because for each value we are prompted for, the previous value is shown in square brackets. When it comes to entering the partition size we can choose how we want to specify it. We can enter it in blocks, cylinders, megabytes, or gigabytes. With each question we are asked, if we hit <return> the value will not be changed. If you do make any changes to the partition table, the change will not be written back to the disk unless you use the label command.

Hopefully, you will agree that setting up and changing partition values is made simple through the format utility. A number of things can make this process a bit more difficult, though. For instance, if the partition you want to change has a filesystem containing data on it, you will not be able to make the change while the filesystem is available to users (mounted) so you will first need to take it offline (unmount it). You will now be able to make the change, but once that partition has been changed you will need to recreate the filesystem before you can use it again. This also has the consequence that all the data on the filesystem will have been lost, so you will need to restore it from the backup you made before changing the partition. Oh, and that's another thing. Always back up a filesystem before trying to make changes to the partition it was created on.

You can find that it may cause a few headaches trying to increase the size of a partition when there is no unallocated space on the disk, or when the unallocated space is not adjacent to the partition you wish to increase. This can mean manipulation of other partitions, which in turn means we might need to back up, recreate, and restore more filesystems than just the one we actually want to change.


    Team-Fly    
    Top
     



    Solaris Operating Environment Boot Camp
    Solaris Operating Environment Boot Camp
    ISBN: 0130342874
    EAN: 2147483647
    Year: 2002
    Pages: 301

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net