13. Hard Drives
All hard drives have 8 partitions, that you can adjust in size. Each partition is
called a slice. For slice (partition) 0 the true name would be /dev/dsk/c0t3d0s0 (the last
part (s0) is the name of the slice). Lets break down this name (or address):
Breakdown
of device (hard drive) names |
/dev |
/dsk |
/c0 |
t3 |
d0 |
s0 |
Devices directory |
Hard disk |
(c=controller) usually c0 (SCSI port) |
(t=target) in this case target disk 3 |
(d=disk) usually 0 unless you have 2 or more hard drives per target |
(s=slice) or partition, between 0-7 |
*Note: some devices (targets) have two disks in them
Every time you have a device you will have two entries: one in /dev/dsk/ and one in
/dev/rdsk. The following explains the nuances between them:
Differences
between dsk, and rdsk devices |
/dev/dsk/ (device special device) |
/dev/rdsk/ (character special
device) |
Use this to move a large block of data using these
commands:
|
Use this to move small bits of data at a time (one
character at a time) using these commands:
|
If you are interested in the content, use this one |
If you are interested in the structure use this one |
To see which devices numbers are being used, use the ls /dev/dsk or ls
/dev/rdsk command.
For partitioning, use the following commands:
- format (this will take you to a menu (format>)) you dont need to format
the disk, just partition it
- fmthard (you will type this at the format> prompt)
- prtvtoc
- In the format menu type partition, then modify all partitions at once.
Some notes about partitioning: Partition (or slice) 2 goes from beginning to end of
disk, this partition tells you how big the drive is (do not use partition 2), this is used
for scripts, and to check drive size. The free hog partition will take up any
free space and put it in this slice. Dont pay attention to flag and tag field. Doing
all free hog in modify will make all partitions 0 (zero). Partitioning does
not effect data but will make it harder to find. Make backups before partitioning, restore
backups, then reboot.
- prtvtoc this command will print the table of volume table of contents prtvtoc
[device name] i.e. prtvtoc /dev/rdsk/c0t1d0s2 will show the partition
information for the named disk.
- prtvtoc /dev/rdsk/c0t1d0s2> /tmp/vtoc will save the info to a file called
/tmp/vtoc
- fmthard 5 [file to put info in] [device name] - will do the
same as above (i.e. fmthard 5 /tmp/vtoc /dev/rdsk/c0t1d0s2) the 5 tells
fmthard command that you will name a file. The fmthard command (with 5) will take
the information from prtvtoc and will create a partition table form that. install boot
/usr/platfomr/sun4u/lib/fs/usf/bootblk /dev/rdsk/c0t1d0s0 will give you a bootable
disk on slice 0
- df k reports number of free disk blocks, and shows mount points and
all statistics.
- newfs [device to create a new file system to] creates a new file
system on a partition (i.e. newfs /dev/rdsk/c0t1d0s0) it will create all info
needed on partition
For optimization of your hard drive you need to know the following:
- Which partitions (file system, swap)
- Size of each partition (df k (shows hard disk space) , dv sk [filename]
(shows how big the sub directory is)
- Location put the busiest partitions in the middle
To optimize the hard disk, you need to do the following:
- Which file system is in use now (df k)
- How busy is the hard drive (iostat d10)
- Choose new partition sizes
- Backup all file systems (ufsdump)
- Boot from the DC (so it doesnt use root)
- Repartition (format)
- Create file system for each partition (newfs)
- Mount the disk
- Restore the disk
- Edit vfstab on the hard drive
- Reboot
There are cylinder groups (or regions) on a file system (disk)
The super block contains the following information:
- Total number of files
- Total amount of used space
- Location of cylinder groups
- The cylinder block is on each cylinder block and contains same information as super
block, except that it only contains cylinder information
- Cylinders are broken down in to Inodes and data groups. Inodes hold all system
information for files (i.e. who a file belongs to, permissions, etc) EVERY
FILE GETS AN INODE.
- Data groups hold actual data in files
To monitor your resources do the following:
- iostat> /var/adm/iolog (the /var/adm/iolog can be any file name that you want
your logs stored in)
- rcp [filename1] [filename2] to copy from one place to another or to
copy from one server to another, do rcp [ filename to copy] [hostname:path
of where to copy].
- Then do ps ef | nawk {print $2,$5} $2 and $5 are telling the system
to print the 2nd and 5th column of the ps command. This will give you some optimization
numbers on your system.
Here is a sample set of partitions (you dont want 100% of your disk allocated)
- s0 - usually root or boot information
- s1 swap used as RAM s2 super block (DONT TOUCH!)
- s4 - /var (things that grow in size, i.e. logs and print queues)
- s5 option software, /opt
- s6 operating system (usr, UNIX System Resources)
- s7 home directories
Partitions allow you to decide how much space you give to each thing (dividing up
space)
Reasons to partition: Divide up and reserve space. Set properties (make read only, make
quotas of how space a user can use). Special (s) in permission in the x (execute) field
makes whoever is the owner the permissions of that users, and can be done in group also (nosuid
doesnt allow you to do this)
Some good sizes for partitions (with Solaris)
- Boot 32 megs
- Swap 2 times your ram (the system will crash if you run out
of swap space!) (swap s - shows swap space)
- Var 64 megs all mailboxs go here and log files
- Optional software (/opt) dependent on how much extra software you have
- OS 256 350 megs (ver 2.6 takes 396 megs)
Go to Chapter 12
Go to Index
Go to Chapter 14