|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Unix FAQ Menu |
Question;We have just fitted a new disk to one of our Solaris (sparc) machines. Can you explain how we put it to use? Answer;I hope you've sorted out your SCSI termination and addressing. This FAQ isn't about hardware issues. You should have done a probe-scsi-all from the boot prompt before rebooting the machine with boot -r. This answer assumes your new disk showed up on the probe and is visible to the O/S. If you haven't already done so, you need to identify the device file
related to you new disk, have a look at Introduction
to Solaris Disks & Filesystems. If you think your new disk may have
data, read the section Fsck - checking
for Data Decide what you want to doFormulate a clear plan as to how you are going to use your new disk. If you are using a volume manager then you should go away and read the documentation for it. If you simply want to create one or more filesystems, swap, or raw partitions, then read on.. You need to decide whether you are going to use the whole disk for a single purpose or split it up into multiple areas ('Partitions'). Some of the different uses you may be considering are;
Planning your partition table.Now you need to find out how much space you really have on that disk - the salesman's waffle may start to look a little suspicious right about now. Run prtvtoc <raw_device>s2 to dump out the disk's label and existing partition information, for example;sun (ksh) # prtvtoc /dev/rdsk/c0t1d0s2
* /dev/rdsk/c0t1d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 237 sectors/track
* 20 tracks/cylinder
* 4740 sectors/cylinder
* 7501 cylinders
* 7499 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
1 3 01 0 237000 236999
2 5 01 0 35545260 35545259
5 4 00 237000 4266000 4502999
6 4 00 4503000 1422000 5924999
7 4 00 5925000 29620260 35545259
You're only really interested in 3 numbers at the moment; bytes/sector,
sectors/cylinder, & accessible cylinders. At this point you should calculate
the size of a cylinder and the total space in MB. The calculations are;
cyl_size = (sectors_per_cylinders * bytes_per_sector) / 1024000 total_space = cyl_size * accessible_cylinders In our example these numbers come out to 2.37MB and 17773MB. Creating your partition tableIf you want to use the entire disk for a single purpose you don't actaully need to create any partitions - you can simply use partition #2. You are now ready to run format to create your new partition table. After selecting your NEW disk, type 'p' to get to the partition menu, and 'p' again to display the current partition table. 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 All Sun supplied disks come with a pre-defined partition table. This
you can safely ignore as you are repartitioning the entire disk. If wish
you may like to remove any existing partitions by assigning them a start
and cylinder count of zero, tag should be 'unassigned'. This is not strictly
neccessary but it does make things neater. I suggest you assign sequentially starting from partition 0. For a filesystem the partition tag is 'usr', for swap use 'swap' and for a raw partition use 'unassigned'. Record the partition number on your paper allocation table.
partition> 5 Part Tag Flag Cylinders Size Blocks 5 unassigned wm 0 0 (0/0/0) 0 Enter partition id tag[unassigned]: usr Enter partition permission flags[wm]: Enter new starting cyl[0]: 0 Enter partition size[0b, 0c, 0.00mb, 0.00gb]: 300c And continue on until all your partitions are defined. CAUTION: Format will not prevent or warn
you if you create overlapping partitions ! Before writing the new partition table to disk use the 'p' command to
double check that none of your partitions overlap - use the 'Cylinder'
column to check this. N.B. Partition #2 represents the entire disk, so
it'll overlap all your partitions. Write the partition table ("label") to disk with the label command and quit format. What you do now depends on what use you are putting you partitions to.
With raw partitions there is nothing left to do. For swap partitions skip
on to Swap Partitions, just carry on reading if you
are creating filesystems as newfs is what you need. Creating a new filesystem - newfsFor all the partitions you just created that you intend to use for filesystems, you now need to create a filesystem on them. If you're a nervous about this (you ought to be), you might like to use the -N option to newfs. This is basically a dummy run - nothing gets written to disk, you simply see what it would do. Creating a filesystem is as easy as this...
sun (ksh) # newfs /dev/rdsk/c0t1d0s5
/dev/rdsk/c0t1d0s5: 1422000 sectors in 300 cylinders
of 20 tracks, 237 sectors
694.3MB in 19 cyl groups (16 c/g, 37.03MB/g, 17792 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 76112, 152192, 228272, 304352, 380432, 456512, 532592,
608672, 684752, 760832, 836912, 912992, 989072, 1065152,
1141232, 1217312, 1293392, 1369472,
So easy it's scary! No confirmations, no "ALL DATA ON HARD DRIVE
WILL BE DELETED !" warnings. Just hit return and off it goes... Newfs may take some considerable time to complete on a large partition
- just leave it alone. Take a look at the disc activity light if you need
some proof it's actually working. Tweaking the Parameters of newfsnewfs is simply a wrapper around mkfs(1m). The wrapper came into being because the option list on mkfs is large and somewhat daunting. There are however a few parameters that you may want to think about. In alphabetical order;
Mounting the new filesystemFollowing the letter of the law now you should fsck your new filesystem prior to mounting it - feel free. What you really want to do however is mount it so that you check it out. You can actually mount a filesystem on ANY directory, though it ought to be an empty one. There is an empty directory just for this purpose - /mnt;
sun# mount /dev/dsk/c0t1d0s5 /mnt
sun# df -k /mnt
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c0t1d0s5 2100583 10 2100573 0% /mnt
sun# ls -l /mnt
total 62
drwxrwxrwx 4 root root 512 Jan 2 1999 lost+found
sun# umount /mnt
Here we are using /mnt as a mount point. More about
these in The Filesystem explained
- Mount Points When you are content umount the filesystem with 'umount /mnt'. Now you need to make things permanent - /etc/vfstab. Swap Partitions - a.k.a. Swap DeviceSolaris uses multiple swap partitions in parallel and shifting some of the paging load off the main system disk can make a big difference. By convention swap partitions should be placed on partition #1. This is however only a convention - nothing relies on it.
Once you have a partition free and available, you activate it by using
the 'swap -a' command.
sun (ksh) # swap -a /dev/dsk/c0t1d0s1
sun (ksh) #
In classic Unix style swap remains silent if all is well. You can confirm
your swap partition is now live with swap -l;
sun (ksh)# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c0t3d0s1 32,25 8 205624 165408
/dev/dsk/c0t1d0s1 32,9 8 236992 236992
You now need to add it to vfstab.
/etc/vfstabWe are going to make our new filesystem available under a new directory called /data. This doesn't exist yet so we create it with 'mkdir /data'. After editing /etc/vfstab the new entry looks like this;/dev/dsk/c0t1d0s5 /dev/rdsk/c0t1d0s5 /data ufs 3 yes - The seven fields of vfstab are;
After saving it, you should be able to do a 'mount -a' and have your new filesystem mounted under /data.. You'll likely see some warnings about other filesystems already being mounted - these can be safely ignored. Fsck pass number The fsck pass number seems to be the source of some confusion
Adherence to these points will enable your system to complete a full
filesystem check in the minimum possible time. On a large fileserver it
can make the difference between the server being down for a couple of
hours or the whole day.
Final point: Don't forget to add your new filesystem(s) to whatever backup schedule your site uses..... FeedbackI 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...
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||