The "format" Utility in the Solaris Operating SystemGreg (shoe) Schuweiler, November, 2004 To many, a hard disk is a "black box" and is thought of as a
small device that somehow stores data, programs and/or an operating
system. Nothing is wrong with this approach, of course, as long as
that is all you care about. But as a system administrator, one of
your primary concerns should be the protection of the data. Another
concern way up there in the high-priority range should be the
efficient movement of data between memory and the physical disk. In
this article I would like to investigate one of the basic utilities
that is available to us in the Solaris OS:
The
Along with Another word of warning: The non-destructive commands should be just that, but it is up to you to decide whether to run them on your system or not. The destructive commands will destroy data on a disk; run these commands only if you are sure you know what you are doing. Here are the commands I use throughout this article: Disk Label: Defect List: Partition Table: As you read through this article, keep in mind the following:
I hope you have a system with an attached disk that you can play with, as I
would like this to be an interactive article. First pick the disk you
are going to use with r_gps@holstein: format Searching for disks...done AVAILABLE DISK SELECTIONS: 0.c0t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> boot /pci@1f,4000/scsi@3/sd@0,0 1.c0t1d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> home /pci@1f,4000/scsi@3/sd@1,0 2.c2t1d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> trashme /pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0 Specify disk (enter its number): You can type 'quit' to exit or back up one menu or <Cntrl-D>, which
will exit the « Warning: echo "adios data" | dd of=/dev/dsk/c2t1d0s2 bs=1 count=512 » So now the
r_gps@holstein: format
Searching for disks...done
c2t1d0: configured with capacity of 33.92GB
AVAILABLE DISK SELECTIONS:
0. c0t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> boot
/pci@1f,4000/scsi@3/sd@0,0
1. c0t1d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> home
/pci@1f,4000/scsi@3/sd@1,0
2. c2t1d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>
/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0
Specify disk (enter its number): 2
selecting c2t1d0
[disk formatted]
Disk not labeled. Label it now?
Here you would type 'y' if you wish to label the disk, which is nice since that
makes it usable for the Solaris OS. Then exit from the r_gps@holstein: prtvtoc /dev/dsk/c2t1d0s2 * /dev/dsk/c2t1d0s2 partition map * * Dimensions: * 512 bytes/sector * 107 sectors/track * 27 tracks/cylinder * 2889 sectors/cylinder * 24622 cylinders * 24620 accessible cylinders * * Flags: * 1: unmountable * 10: read-only * * First Sector Last * Partition Tag Flags Sector Count Sector Mount Directory 0 2 00 0 262899 262898 1 3 01 262899 262899 525797 2 5 01 0 71127180 71127179 6 4 00 525798 70601382 71127179 You can learn some of the same information from the r_gps@holstein: format /dev/rdsk/c2t1d0s2
At the Current partition table (original): Total disk cylinders available: 24620 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 90 128.37MB (91/0/0) 262899 1 swap wu 91 - 181 128.37MB (91/0/0) 262899 2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 0 0 (0/0/0) 0 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 0 0 (0/0/0) 0 6 usr wm 182 - 24619 33.67GB (24438/0/0) 70601382 7 unassigned wm 0 0 (0/0/0) 0 partition>
We have some of the same information as with the r_gps@holstein: dd if=/dev/dsk/c2t1d0s2 of=wart.bin bs=512 count=1 1+0 records in 1+0 records out
This gives us a binary file which we can use the r_gps@holstein: od -x wart.bin 0000000 5355 4e33 3647 2063 796c 2032 3436 3230 0000020 2061 6c74 2032 2068 6420 3237 2073 6563 0000040 2031 3037 0000 0000 0000 0000 0000 0000 0000060 0000 0000 0000 0000 0000 0000 0000 0000 * 0000200 0000 0001 0000 0000 0000 0000 0008 0002 0000220 0000 0003 0001 0005 0001 0000 0000 0000 0000240 0000 0000 0000 0004 0000 0000 0000 0000 0000260 0000 0000 0000 0000 0000 0000 600d deee 0000300 0000 0000 0000 0000 0000 0000 0000 0000 * 0000640 0000 0000 2729 602e 0000 0000 0000 0001 0000660 602c 0002 001b 006b 0000 0000 0000 0000 0000700 0004 02f3 0000 005b 0004 02f3 0000 0000 0000720 043d 508c 0000 0000 0000 0000 0000 0000 0000740 0000 0000 0000 0000 0000 0000 0000 00b6 0000760 0435 4aa6 0000 0000 0000 0000 dabe 4297 0001000
There is a lot of information in the octal dump, and a very good Sun document
covers this -- I do not wish to duplicate that information. Search for Document
ID 74087 at SunSolve. One thing to note is that
r_gps@holstein: format /dev/rdsk/c2t1d0s2
selecting /dev/rdsk/c2t1d0s2
[disk formatted]
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>
I always like to give each disk a volume name as it makes the system more
personable. This also is a great help if you have more than one system looking
at the same disk drives, which can happen in a highly available cluster. I've
seen 120 plus disks presented by a pair of RAID engines all visible by 15
systems in a VERITAS Cluster. Giving each disk a volume name helps identify
disks that have already been used. Disks without a volume name are unused. Here is one thing to note when using the format> volname Enter 8-character volume name (remember quotes)[""]:"pigsnot" Ready to label disk, continue? y format>
The
The
format> disk
AVAILABLE DISK SELECTIONS:
0. /dev/rdsk/c2t1d0s2 <SUN36G cyl 24620 alt 2 hd 27 sec 107> pigsnot
/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0
Specify disk (enter its number)[0]:
The Current Disk = c2t1d0: pigsnot <SUN36G cyl 24620 alt 2 hd 27 sec 107> /pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0
The r_gps@holstein: ls /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0* /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:a /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:a,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:b /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:b,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:c /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:c,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:d /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:d,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:e /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:e,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:f /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:f,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:g /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:g,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:h /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:h,raw The physical device name with the word "raw" is the character device, and the other is the block device. Letter 'a' is partition 0, letter 'b' is partition 1, and so forth.
The
The
The format> verify Primary label contents: Volume name = < pigsnot> ASCII name = <SUN36G cyl 24620 alt 2 hd 27 sec 107> pcyl = 24622 ncyl = 24620 acyl = 2 nhead = 27 nsect = 107 Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 90 128.37MB (91/0/0) 262899 1 swap wu 91 - 181 128.37MB (91/0/0) 262899 2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 0 0 (0/0/0) 0 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 0 0 (0/0/0) 0 6 usr wm 182 - 24619 33.67GB (24438/0/0) 70601382 7 unassigned wm 0 0 (0/0/0) 0
The
#
# New disk/partition type saved on Fri Aug 6 06:34:05 2004
#
disk_type = "SUN36G" \
: ctlr = SCSI : ncyl = 24620 : acyl = 2 : pcyl = 24622 \
: nhead = 27 : nsect = 107 : rpm = 10025
...
And finally on our list of options used for gathering information on the disk
we have the format> inq Vendor: FUJITSU Product: MAN3367M SUN36G Revision: 1502 format> One thing to take note of is the revision level. Firmware updates do come out for disk drives. This option lets you compare the revision levels that you have on your disks compared to what is available from the disk vendor. I have had vendors update drive firmware on the disks on their large RAID arrays, but they do it on the fly. I updated firmware on SCSI disks once or twice a long time ago. I don't bother anymore -- mainly because of the number of disks in today's environments and the amount of downtime that would be required. (And that old saying, "If it ain't broke, don't fix it," sometimes makes sense.) I haven't figured out how to upgrade without the downtime. Yet.
One of the nice things about the defect both dump /disks/c2t1d0-defect.dat r_gps@holstein: format -f c2t1d0.cmd /dev/rdsk/c2t1d0s2
But because of the destructive power of the
Warning: I have reproduced the
r_gps@holstein: format /dev/rdsk/c2t1d0s2
selecting /dev/rdsk/c2t1d0s2
[disk formatted]
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>
The The drives for which we used to have to do this were called IPI and SMD drives. Try a search on Google with 'ipi smd disk' drive for a bit of history and to find out where you can still purchase these types of drives if you're interested.
The An area in which I strongly disagree with Sun now starts to emerge. For instance, lately Sun and the Sun Systems Engineers (SEs) that I know have been recommending one root partition and one other partition for everything else for the system disk. Balderdash! Each slice on a disk is seen as a separate disk by the OS, so before we slice up our test disk, let's look at why I disagree with Sun on this point. You can disagree with me if you like -- better yet, write your own article!
What if The operating system sees each partition as a separate file system. That means it creates cache and buffers for each of these file systems. The extra cache and buffers will spread the I/O load out a little bit. Yes, you are limited by backup, interconnect speed, and disk controller. But in moments of heavy I/O, you are less likely to run into problems. OK, now let me step down from my soap box, and let's get on with the Partition Menu. This opens up another menu that looks like the following:
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
The easiest way I have found to work with partitioning is this: Once I am in
the Partition Menu, I just hit the 'P' key for the Current partition table (original): Total disk cylinders available: 24620 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 90 128.37MB (91/0/0) 262899 1 swap wu 91 - 181 128.37MB (91/0/0) 262899 2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 0 0 (0/0/0) 0 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 0 0 (0/0/0) 0 6 usr wm 182 - 24619 33.67GB (24438/0/0) 70601382 7 unassigned wm 0 0 (0/0/0) 0
This is the default partition table and we need to change it, recalling that we
definitely do not want overlapping partitions. The safest way to modify the
partitions is with the
When you enter
partition> modify
Select partitioning base:
0. Current partition table (original)
1. All Free Hog
Choose base (enter number) [0]?
By default you are going to modify the current partition, and this is just fine.
There really isn't much of a difference when you're done. When you select the
Current partition table, the
If I choose not to use the partition> 0 Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 90 128.37MB (91/0/0) 262899 Enter partition id tag[root]: Enter partition permission flags[wm]: Enter new starting cyl[0]: Enter partition size [262899b, 91c, 90e, 128.37mb, 0.13gb]: 256mb You can also enter a '?' at the partition id tag and the permission flag questions and get the responses that are acceptable. If I hit the 'P' key again we can see that I have a problem I need to fix. Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 181 256.74MB (182/0/0) 525798 1 swap wu 91 - 181 128.37MB (91/0/0) 262899 ...Partition 0 is overlapping partition 1. As you go through the creation of your partitions, ensure that you do not overlap any of the partitions you create. How many partitions you create and what sizes they are really depends on your site, your needs, experiences, and so on. When I finish, I have the following: Current partition table (original): Total disk cylinders available: 24620 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 181 56.74MB (182/0/0) 525798 1 swap wu 182 - 272 128.37MB (1452/0/0) 4194828 2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 3540 - 4265 1.00GB (726/0/0) 2097414 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 4266 - 4991 1.00GB (726/0/0) 2097414 6 usr wm 273 - 2087 2.50GB (1815/0/0) 5243535 7 var wm 2088 - 3539 2.00GB (1452/0/0) 4194828
We still need to write the partition table out. This is done by just typing in
You shouldn't really need to use the
The
I think I wrote more than enough about the
The
Well, wasn't that fun? Formatting and setting partitions on a couple of disks
isn't a problem -- it requires a bit of typing, but it's bearable. But what if
you've just hooked up to a large RAID array, and you need to configure 10 or
even 200 disks identically? I have a good friend who needed to do this for a
large imaging project. She used
As always, * Partition Tag Flag First Sector Sector Count 0 2 00 4194828 1048707 1 7 00 5243535 4145715 2 5 00 0 71127180 3 3 01 0 4194828 4 0 00 9389250 2097414 5 0 00 11486664 8389656 6 4 00 19876320 6292242
So the best thing would be to use the fmthard -i -n "" /dev/rdsk/c2t1d0s2 > ./mypartition.dat
The preceding command writes the disk partitions on « fmthard -s mypartition.dat -n "volumename" /dev/rdsk/cxtydzs2 »
The downside to the
Now if you have actually read the manual page for
-e Enable SCSI expert menu. Note this option is not
recommended for casual use.
Well, I don't know about you, but I just had to play with this option. When you
enter the scsi - independent SCSI mode selects cache - enable, disable or query SCSI disk cache
You even get a neat warning paragraph when you enter the
One word of warning if you intend to play in the Now the cache option gives us a menu for the disk read and write cache. Not all SCSI disks have cache, and of those that do, not all of them allow you to change their cache options. This cache is a small amount of memory that is on the disk -- it has nothing to do with the system memory. This means that each disk may be a little different and may behave a little differently when you play with these. I have found that the read cache is usually turned on, and this makes sense as nothing is lost if power goes down during a read operation. The data should still be out on the disk. Likewise, I have always found the write cache turned off. This makes sense because if you lose power, you will lose whatever is in the write cache. When I have turned it on and compared I/O loads using IOzone, improvement on the write operations ranged from very little to a marked improvement. This improvement will vary from disk model to disk model and from vendor to vendor.
Since you are in the format> label [0] SMI Label [1] EFI Label Specify Label type[0]:
I believe that SMI means Sun Microsystems. This is the default option, and you
see this option if you enter the If you select the EFI (Extensible Firmware Interface) label, you will get another partition as shown below. ascii name = <FUJITSU MAN3367M SUN36G 1502 43d671f> bytes/sector = 512 sectors = 71132958 accessible sectors = 71132925 Part Tag Flag First Sector Size Last Sector 0 root wm 34 128.35MB 262898 1 swap wu 262899 128.37MB 525797 2 unassigned wm 0 0 0 3 unassigned wm 0 0 0 4 unassigned wm 0 0 0 5 unassigned wm 0 0 0 6 usr wm 525798 33.66GB 71116540 7 unassigned wm 0 0 0 8 reserved wm 71116541 8.00MB 71132924 format> You can find a lot more information about EFI on the Extensible Firmware Interface page on the Intel web site.
So where does this leave us? I hope I have cleared up a few things that you can
do with the About the Author Greg (shoe) Schuweiler has worked in the friendly Midwest (U.S.) for the last 20 years as a consultant, an embedded software designer, Oracle DBA, and a host of other strange titles. He has had the noble profession of UNIX SA for the past eight years. He can be reached at: gshoe [at] xadd.org.
Discuss and comment on this resource in the BigAdmin Wiki
Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License. |
| |||||||