IV.  Practical howto


IV.3  Disks, partitions and slices under Solaris

Disk addressing conventions

All devices in Unix, in particular in Solaris, are accessed through special files. In Solaris all actual special files are placed below /devices directory. For convenience /dev directory contains symbolic links to these device special files. Disk entries, i.e. symbolic links to disk device special files are placed in /dev/dsk and /dev/rdsk, depending on whether they refer to block devices or raw devices. In this context, by disks we mean hard disks, CD-ROMs, ZIP drives and the like (see disks man page for the exact technical definition). Disk entries have the following syntax:


cC [ tT ] dD ( sS | pP )


where C, T, D, S, and P are non-negative decimal numbers. Actually, a disk entry is a complete address of a slice or a partition, and consists of two parts: logical device address formed by c, t, d, and slice s or partition p address on that device.

First note that a pair c, d form an IDE device address, and a triple c, t, d form a SCSI device address. Note also that presented addressing convention does not allow to access logical volumes within extended partitions. Some utilities like mount or mkfs make use of disk-entry:volume addressing convention, where disk-entry specifies either the entire disk (...p0) or a partition (...pP); volume is either a number 1 through 24 or equally a letter c through z.

Under Solaris 9 it is recommended to use the /dev/dsk/c0d0p0:1, /dev/dsk/c0d0p0:2, /dev/dsk/c0d0p0:3, and so forth notation, where the number after the colon indicates the first, second, third, and so forth FAT (FAT-16 or FAT-32) volume. The pcfs driver automatically numbers any FAT volume it sees on the disk. This notation also works for primary FAT fdisk partitions. This addressing schema corresponds to DOS addressing using drive letters.

To understand how it works, consider the following example.


Table IV.3.1: Example partitioning and Solaris addresses.
  1. Primary - FAT-16 p0:1 p1:1
  2. Primary - FAT-16 p0:2 p2:1
  3. Primary - NTFS - -
  4. Extended
 
  4.1. FAT-16 p0:3 p3:1
 
  4.2. FAT-16 p0:4 p3:2

Note: The above example was prepared and tested only under Solaris 9 and may not apply to earlier versions.


Slices and VTOC

Every Solaris partition is divided into smaller chunks called slices. They resemble x86 fdisk partitions of hard disk drive. Up to 16 slices may be defined per a Solaris partition. Since there are only 21 device special files per a disk, this imposes certain limitation. Only slices within the first Solaris partition can be addresses by s0 through s15. Note however that there are still up to 4 Solaris partitions per a disk allowed.

Some slices are reserved or have special meaning. Slice 2 is a backup slice representing entire Solaris partition. Slice 8 is a boot slice representing the first cylinder of the Solaris partition, containing partition boot block pboot, Solaris disk label, VTOC and boot manager program bootblk. Slices 2 and 8 can are unmountable. Slice 9 is an alternates slice that uses 2 cylinders. Slices 2, 8 and 9 are reserved and should not be redefined. Slice 0 is usually a root slice containing the root file system. The following tags may be assigned to slices: swap, usr, stand, var and home (see fmthard man page).

There are 4 possible states of a slice. They are determined by two flags specified when the slice is defined. One determines if the slice is mountable, the other if it is read-only.

Slices can be defined using fmthard or interactive format utility. format always shows 0 through 9 slices, including undefined ones. To define a slice we need to specify its number, tag, flag, starting sector relative to Solaris partition and its size.

All the information about slices is kept in a Volume Table Of Contents, shortly VTOC. Together with Solaris disk label VTOC occupies the second and third sector of a boot slice - the first cylinder of a Solaris partition. It can be printed out with prtvtoc utility. It is recommended to print and save all VTOCs after the system is setup to have them handy in the case of emergency.

Creating and mounting additional UFS file systems

When we add some new hard disk partition to Solaris it is recommended to use the native Solaris UFS file system. Though we lose compatibility with other operating systems our machine is running, we benefit reliability and performance.

First thing is to create Solaris partition. If it would be the second Solaris partition on our drive, we will need to apply some trick described in details later. Assume that we have two IDE drives on the same primary channel: master c0d0 where Solaris is installed, and slave c0d1. Run fdisk program to create Solaris partition:


fdisk /dev/rdsk/c0d1/p0


This task is relatively easy since the above command runs fdisk in the interactive mode. It allows to delete partitions that we no longer need. Next step is to create slices on the new Solaris partition. Run program format, which also offers the interactive mode. We will probably see something like this:

AVAILABLE DISK SELECTIONS:
       0. c0d0 
          /pci@0,0/pci-ide@4,1/ide@0/cmdk@0,0
       1. c0d1 
          /pci@0,0/pci-ide@4,1/ide@1/cmdk@0,0
Specify disk (enter its number): 

Solaris automatically recognized its own partition on c0d1 and you do not need to remember which one it was. After selecting 1 a menu with format options shows up. partition sub-menu is responsible for slice management. format shows only 0 through 9 slices though 16 are allowed. Keep in mind that slices 2, 8,9 are reserved, and the 0-th slice should begin at sector 3. Command label should be invoked before quiting partition.

When the new Solaris partition is already sliced, type:


newfs /dev/rdsk/c0d1s0


to construct UFS file system on the 0-th slice. You need to construct file system on every slice you defined. Last step to perform is mounting:


mount /dev/rdsk/cod1s0 /export/home1


This will mount 0-th slice on /export/home1 (/export/home1 must exist prior mounting). To have new slices mounted at boot time add them to /etc/vfstab (read vfstab man page).

Two Solaris partitions on the same drive

When we decide to remove one of the operating systems or just free one of the partitions and dedicate it for Solaris we can get into troubles if that free space is on the same hard disk drive where Solaris is installed. The problem is the second Solaris partition can not be addressed using usual Solaris addressing schema.

Solaris partition can not be resized, besides, the hole and the Solaris partition need not to be placed side by side. One workaround is to backup all the data, repartition and restore data. We can even copy file systems as a whole, but a spare hard disk drive is necessary.

The simple solution makes use of the fact that besides Solaris slices we can mount 3 partitions. Consider the following partitioning:

  1. p1 - primary partition where Solaris is installed,
  2. p2 - primary partition with other operating system,
  3. empty space,

on the drive c0t0d0. We begin with creating a new Solaris partition within an empty space, which will become p3:


fdisk /dev/rdsk/c0t0d0p0


fmthard and newfs use slices as addresses, therefore to modify VTOC on p3 we need to hide p1 first. Reboot into DOS and run your favorite disk editor capable of modifying MBRs e.g. Ranish PM to change the identifier of p1, so that Solaris would not recognize it. For safety make a backup of the MBR before. Now, reboot Solaris from its installation CD, stop the installation after the Open Windows session is started, and open a terminal window. At the moment p3 is the first Solaris partition on c0t0d0, so run format and create exactly one slice 0 in p3, so that it starts in 0-th sector and fills entire p3, much like slice 2. New UFS file system is created with:


newfs /dev/rdsk/c0t0d0s0


New file system is ready to mount. Restore the identifier of p1 back to 0x82, reboot Solaris as usual, and mount p3:


mount /dev/dsk/c0t0d0p3


p3 acts like a single slice and that is the trick. The interesting question arises: where is the VTOC of p3 now?

Mounting FAT partitions

When along Solaris there is an alternative operating system, it is convenient to have FAT volume for data exchange. While FAT-16 is supported by almost all x86 platforms, FAT-32 is not even supported by all MS operating systems e.g. NT 4.0. There are two FAT-16 and two FAT-32 variants - one for smaller disks and the other for large disks of capacity greater than 32GB. In Solaris terminology all those file systems are called pcfs (FAT-32 is supported starting from Solaris 7). Consider the following example of partitioning:


  1. Primary - NTFS
Windows NT
 
  2. Primary - UFS
Solaris
active  
  3. Primary - Linux ext2fs
Linux
 
  4. Extended
 
  4.1. FAT-16
 
  4.2. Linux swap
 
  4.3. Linux ext2fs
 
  4.4. NTFS
 
  4.5. NTFS

To access FAT-16 partition under Solaris it must be mounted. Type as root:


mount -F pcfs /dev/dsk/c0t0d0p0:1 /mnt


and FAT partition content will be available below /mnt directory. The above command is valid for SCSI hard disks. For IDE drives drop t0.

File system mounting, as in the example above, requires superuser intervention and the file system will be unmounted after system reboot. To mount FAT partition permanently in directory /share, create this directory first, and add the following line to /etc/vfstab file:

/dev/dsk/c0t0d0p0:1	-	/share	pcfs	-	yes	-

Remember to end this line with a line feed character (break the line typing Return). This will mount FAT partition automatically during boot up. The same commands apply to both FAT-16 and FAT-32. Read mount_pcfs and vfstab man pages for more details.

There were problems reported with mounting FAT file systems within extended partition under Solaris 8. Tests, with Solaris 8 02/02, revealed that only two FAT volumes within an extended partition can be mounted, provided that they both are the very first volumes on that extended partition.

Under Solaris 9 the problem is fixed. See addressing conventions.