Andy's Unix FAQ

An Introduction to Solaris Disks & filesystems
In this FAQ: Solaris format / scanning for disks, Labels, Partitioning, Fsck: checking for data, Mounting_a_filesystem, DOS_comparison, Lost or corrupted vfstab, "Partition" or "Slice".
Related FAQs: Configuring a new disk: creating partitions, creating filesystems (newfs), Cylinders.


Unix FAQ Menu
Contents
Basic commands
Cron
Creating CDs
Device Files
DHCP server (Solaris)
Filesystem explained
Fsck
grub/lilo vanished!
Linux applications?
Linux databases?
Linux distributions
Serial Console
Solaris devices
Solaris disks - Intro
Solaris disks - Adding
Solaris x86 install
SQL/Shell script
Syslog/Monitoring
Time Synchronisation.
Virtual Memory
Web Multi-Language
Web Server Errors
Humour
Unix a Prank



 

Excellent This page has received an average rating of 92% from 13 readers

Question

Subject: Disks Configuration
Question -
Hello,
I just received a Solaris box that is up and running. I'd like to know how can I know if all the disks are "up and running".

  1. Could you tell me how to chek that?
  2. How can I check the # of disks that I have on that box?
  3. If there is one of those that is not mounted, how can I mounted?
Thanks
Diego

Answer.

All the disks (filesystems and swap areas) that Solaris already knows about are listed in the file /etc/vfstab. Under Linux and other Unix variants this file is /etc/fstab. vfstab/fstab is covered in the companion faq Installing a new disk under Solaris - /etc/vfstab

The commands you will need to use are format(8), fsck(8) and mount(8).

This FAQ assumes you are familar with the concepts and terms outlined in The Unix filesystem explained

If you are familar with DOS/Windows, then the following table comparing the various commands may assist you in understanding Unix procedures;

Unix Command Nearest DOS equivalent
Notes
format(1m) FDISK partitions and labels disk
newfs(1m) FORMAT creates a filesystem
fsck(8) CHKDSK checks a filesystem
mount(1m) no equivalent associates a filesystem with a directory / mountpoint

Not in this FAQ

This FAQ does not go into detail about Volume Managers and RAID systems. Much of what is here is applicable however.

Many RAID systems provide their own tools that replace the functionality provided by format(8). These tools should always be used instead of format when appropriate. Some hardware RAID systems (E.g EMC) make several physical disks appear as one to the operating system.

Format

The primary use of format(1M) is to "label" and partition disks. When you run format it will scan all active SCSI buses for fixed drives, E.g;

# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c0t1d0 <SEAGATE-ST118273N-6244 cyl 7499 alt 2 hd 20 sec 237>
/iommu@0,10000000/sbus@0,10001000/espdma@4,8400000/esp@4,8800000/sd@1,0
1. c0t3d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>
/iommu@0,10000000/sbus@0,10001000/espdma@4,8400000/esp@4,8800000/sd@3,0
Specify disk (enter its number): ^D

[ Type Control-D to exit format.]

Format normally displays 2 lines for each disk. The first line contains the device name (under /dev/dsk, /dev/rdsk) and the "disk label". The second line is the devpath to the device - of limited interest.

If the dreaded word Unknown appears instead of nicely formated label, it most likely means that the disk is unlabelled. If you bought it through Sun's sales channels call and complain - this is exactly why you pay Sun's extortionate prices for disks. If you bought it elsewhere - you're on your own.
At least until I get round to writing an FAQ on the subject

[ For details on how to use format to create partitions see Creating Partitions ]

Disk label
The disk label is an electronic record, written at the start of the disk that provides the operating system basic information about that disk - manufacturer, geometry and other drive characteristics. A disk must be labeled before it can be accessed by the operating system.

If the disk is on a hardware RAID system much of this information is 'faked'.

The label is a propriety format so a disk from a different operating system needs to be relabeled prior to use. If the first line from format includes the word "unknown" then that disk has not yet been labelled. All disks supplied by Sun are pre-labeled. Under Solaris the disk label also includes the partitioning information of the disk.

You should NOT attempt to label a disk unless you are extremely familiar with the process. Getting this wrong can cause catastrophic system failure and data loss.

Partitioning
[ For details on how to create or modify partitions see Creating Partitions ]

Partitioning is where a physical disk is split into several logical areas usually for different filesystems. Under Solaris(sparc) one disk can contain up to 7 partitions, each of which may contain a filesystem. When you select a disk in format you will note (after selecting 'p' for partitioning, and 'p' again for print) that partitions are numbered 0-7.
You should not change partition #2. This by convention is used to represent the whole disk and several utilities rely on it. A typical partition table is shown below;

partition> p
Current partition table (original):
Total disk cylinders available: 2036 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm       0 -  101       50.20MB    (102/0/0)   102816
  1       swap    wu     102 -  305      100.41MB    (204/0/0)   205632
  2     backup    wm       0 - 2035     1002.09MB    (2036/0/0) 2052288
  3        usr    wm     306 - 1829      750.09MB    (1524/0/0) 1536192
  4        var    wm    1830 - 2033      100.41MB    (204/0/0)   205632
  5 unassigned    wm       0               0         (0/0/0)          0
  6 unassigned    wm       0               0         (0/0/0)          0
  7 unassigned    wm       0               0         (0/0/0)          0

A partition is also known as a "slice" - the slice is the number after the "s" character in a full disk device specification. For example a vfstab entry looks like this;
    /dev/dsk/c0t3d0s4 /dev/rdsk/c0t3d0s4 /var ufs 1 no -

If you do re-partition a disk you should note that it is quite possible to create overlapping partitions. In general this is a very BAD idea, and will likely cause file system corruption and data loss at some point in the future.
Note that by convention partition/slice #2 is the whole disk, thus any other partition on the disk will overlap that. This also explains why you can only have 7 filesystems and not 8 as one might expect.

Fsck - checking filesystems
[ If you're looking for details about fsck, you probably really need The Ins and Outs of Fsck. ]

Fsck is used to check the integrity of filesystems. You can also use it to find out whether your partitions have existing filesystems / data. It is not used to check the functions of disks - under Solaris use Format for that.

When you run fsck normally it will check all the various filesystem structures, and try to correct problems it finds. The output of a normal fsck on a clean filesystem looks like this;

sun# fsck /opt
** /dev/rdsk/c0t1d0s6
** Last Mounted on /opt
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
2746 files, 169956 used, 498467 free (1051 frags, 62177 blocks, 0.1% fragmentation)

If you run fsck on a partition that does not have a filesystem, it will fail quickly and cleanly.
Note:  The following example uses the '-n' option - "No Write". If you simply want to see what fsck says about a partition/filesystem and not take any risks use this option. Fsck will then just tell you what it sees and not make any modifications;

sun# fsck -n /dev/rdsk/c0t0d0s1
** /dev/rdsk/c0t1d0s1 (NO WRITE)
BAD SUPER BLOCK: MAGIC NUMBER WRONG
USE AN ALTERNATE SUPER-BLOCK TO SUPPLY NEEDED INFORMATION;
eg. fsck [-F ufs] -o b=# [special ...]
where # is the alternate super block. SEE fsck_ufs(1M).

If you get this error on a partition you are sure has a filesystem, then be aware that it is corrupted. You may be able to retrieve most of the filesystem by using alternate block numbers - see Using Alternate Super blocks for more details.

Important: Fsck should normally only be run on unmounted filesystems. If fsck runs and makes modifications to a live filesystem there will be dire effects - most likely the system will crash.

For more information about fsck, see the companion FAQ - The Ins and Outs of Fsck.

Filesystems - "How to mount a disk"
Assuming you identify one or more disks that have no mounted partitions, you should check that these do not contain filesystems using fsck - see above. Assuming they don't you will likely need to create a file system on that partition. This is done with the newfs(8) command. For more details about creating filesystems see my companion FAQ - Adding a disk to Solaris, & newfs

If you want to test mount a filesystem, perhaps to check that sizes etc are as you expect;
      # mount /dev/dsk/c0t1d0s2 /mnt
      # df /mnt
      .....
      # umount /mnt

There is nothing special about "/mnt" it's just an empty directory. You can create a new mountpoint simply with "mkdir ..." More about mountpoints.

[ See Installing a new disk for more details about newfs and mount ]

Tips and Tricks

Lost or corrupted vfstab / fstab ?: Losing /etc/vfstab can be a catastrophe on any system and you only find out about it when you reboot and none of your filesystems are mounted. Have hope ! all is not lost. Under Solaris running fsck on an unmounted filesystem will report the last mountpoint on which that filesystem was mounted;

# fsck -n /dev/rdsk/c0t1d0s7
** /dev/rdsk/c0t1d0s7 
** Last Mounted on /data
** Phase 1 - Check Blocks and Sizes
....

Whilst not a complete solution (you won't get the mount options) this trick may help you get your system to a point where you can at least restore vfstab from backup.

Partition
or
Slice
Basically two words meaning the same thing. I use the term Partition throughout because that's what I, and I believe most people are more familar with.
Sun's documentation uses the term Slice for reasons best known to themselves.
The two terms are completely interchangable.


For more information on the topics and commands touched on in this page see
Installing a new disk under Solaris


Feedback

I hope you found this FAQ to be of some use. It would be most helpful if you could rate it below. All fields are optional...
Please do not use this form to seek free technical assistance - Try AllExperts...

Excellent Your Email:
Good Comments or Suggestions
Useful
Slightly useful
Not useful
        

 



Home Thai Guide   Great Circle Calculator WorldClock AMS Services Contact us