5. 用edvtoc命令增加slice
系统自动增加了s0到sf共16个 slice,如果我们继续增加只能通过编辑vtoc文件。
1)prtvtoc –f /tmp/vtoc /dev/c0b0t0d0s0
这样获得当前硬盘的VTOC信息文件。
2)然后在文件的末尾增加如下16、17两行:
15 0xf 0x201 12514635 16065
16 0x4 0x200 12530700 300
17 0x4 0x200 12531000 400
有一个原则,最后一个slice的结束sector不能超出整个fdisk分区的范围,如果超出,将产生不可预料的严重错误,甚至有导致整个系统瘫痪的可能。
3)edvtoc –f /tmp/aaa /dev/c0b0t0d0s0
通过修改后的vtoc文件/tmp/aaa更新硬盘的VTOC信息。
4)然后重新启动系统,系统将自动给新增加的两个slice创建两个设备文件/dev/[r]dsk/c0b0t0d0s11和/dev/[r]dsk/c0b0t0d0s12。这样我们就可以通过这两个设备文件对slice进行操作了。
2.3 增加硬盘
将硬盘正确的连接到主机系统上,并且连接硬盘的适配器(或者通道或者卡)的驱动程序已经正确安装,则操作系统在启动的时候能够正确的检测到硬盘,并由VTOC驱动程序创建了21个与slice对应的设备文件/dev/[r]dsk/cXbXtXdXp0-4和/dev/[r]dsk/cXbXtXdXs0-f,只有发现系统正确的检测到了硬盘时我们才能够通过命令diskadd增加硬盘,否则无法进行。举个例子,在我们的学习环境中,磁盘阵列柜是通过SCSI Ultra29160卡连接到主机上的,如果在UnixWare7.1.x操作系统中没有正确的安装此SCSI卡的驱动程序,将无法进行增加硬盘,因为系统根本无法在启动时自动检测到该磁盘阵列柜并为其创建设备文件,所以不可能正确的执行命令diskadd。
2.3.1 第一个例子
增加磁盘阵列柜第一个逻辑分区/dev/[r]dsk/c2b0t5d0,这个例子详细列出整个过程,目的是让大家有一个较为详细的了解。
1 # diskadd c2b0t5d0
2 UX:diskadd: INFO: You have invoked the System V disk management (s5dm) diskadd .
3 The purpose of this utility is to set up additional disk drives.
4 This utility can destroy the existing data on the disk.
5 Do you wish to continue?
6 (Type y for yes or n for no followed by ENTER):
注释:
1)第1行是增加硬盘的命令,它是建立在系统启动时检测到该硬盘并正确的创立了/dev/[r]dsk/目录下的设备文件的基础之上的。
2)第2行的提示可以看出,当我们省略了参数-F时,缺省调用s5dm交互界面。
3)第4行有一个该操作可能破坏硬盘上存在数据的提示。
4)第5、6两行询问你是否继续,如果可以回答y,如果不想继续则回答n。
7 y
8 The recommended default partitioning for your disk is:
0. a 100% "UNIX System" partition.
9 To select this, please type "y". To partition your disk
10 differently, type "n" and the "fdisk" program will let you
11 select other partitions. y
12 Surface analysis of your disk is recommended
13 but not required.
注释:
1)第7行就是我们的回答”y”,是由我们手动输入的。
2)第8到11行提示我们是用缺省的将该逻辑分区100%的划分为UNIX分区还是手动用fdisk自己进行分区,我们在11行回答的是”y”。
14 Do you wish to skip surface analysis? (y/n) y
15 You will now be queried on the setup of your disk.After you
16 have determined which slices will be created, you will be
17 queried to designate the sizes of the various slices.
18 How many slices/filesystems do you want created on the disk (1 - 13)? 2
注释:创建两个slices。
19 Please enter the absolute pathname (e.g., /home3) for
20 slice/filesystem 1 (1 - 32 chars)? /home/s1
注释:输入文件系统的挂接点目录/home/s1。
21 Enter the filesystem type for this slice (vxfs,ufs,s5,sfs),
22 type 'na' if no filesystem is needed, or press
23 to use the default (vxfs):
注释:使用缺省的文件系统类型vxfs,如果使用其它的文件系统可以手动输入后确认。
24 Specify the block size from the the following list
25 (1024, 2048, 4096, 8192), or press to use the first one:
注释:指定slice的块(block)大小,此处缺省。
26 Should /home/s1 be automatically mounted during a reboot?
27 Type "no" to override auto-mount or press to enable the option: no
注释:询问是否在系统启动时自动mount该文件系统。
28 Please enter the absolute pathname (e.g., /home3) for
29 slice/filesystem 2 (1 - 32 chars)? /home/s2
30 Enter the filesystem type for this slice (vxfs,ufs,s5,sfs),
31 type 'na' if no filesystem is needed, or press
32 to use the default (vxfs):
33 Specify the block size from the the following list
34 (1024, 2048, 4096, 8192), or press to use the first one:
35 Should /home/s2 be automatically mounted during a reboot?
36 Type "no" to override auto-mount or press to enable the option: no
注释:28-36行定义第二个slice,步骤和内容和第一个slice相同。
37 You will now specify the size in cylinders of each slice.
38 (One cylinder is approximately 2 megabytes of disk space.)
39 There are now 17542 cylinders available on your disk.
40 The filesystem type you have chosen is limited to 541064 cylinders.
41 How many cylinders would you like for /home/s1 (0 - 17542)?
42 Press for 0 cylinders: 1000
43 There are now 16542 cylinders available on your disk.
44 The filesystem type you have chosen is limited to 541064 cylinders.
45 How many cylinders would you like for /home/s2 (0 - 16542)?
46 Press for 0 cylinders: 1000
47 Notice: The selections you have made will leave 15542 cylinders unused.
48 You have specified the following disk configuration:
49 A /home/s1 filesystem with 1000 cylinders (1938.0 MB)
50 A /home/s2 filesystem with 1000 cylinders (1938.0 MB)
51 Is this allocation acceptable to you (y/n)? y
52 UX:sh (sh): ERROR: disk3: Not found
53 UX:sh (sh): ERROR: disk5: Not found
54 UX:sh (sh): ERROR: disk6: Not found
注释:第37行到54行对上面定义的两个slice分配空间,以cylinder为单位进行,在第38行有提示说一个cylinder大约接近2MB的空间,在41行提示整个逻辑分区的空间是17542个cylinder。第49、50行说明了上面我们分配的两个slice的大小,并在51行询问是否接受以上定义,我们回答”y”。
55 Filesystems will now be created on the needed slices
56 Creating the /home/s1 filesystem on /dev/rdsk/c2b0t5d0s1
57 Allocated approximately 496093 inodes for this file system. Specify a
58 new value or press to use the default:
59 Creating the /home/s2 filesystem on /dev/rdsk/c2b0t5d0s2
60 Allocated approximately 496093 inodes for this file system. Specify a
61 new value or press to use the default:
62 UX:diskadd: INFO: Diskadd for Disk Drive 2 DONE at Tue Feb 24 13:44:02 CST 2004
63 #
注释:第55到62行创建slice成功,并有说明s1是/dev/rdsk/c2b0t5d0s1,s2是/dev/rdsk/c2b0t5d0s2,这样我们就完成了添加硬盘的工作,并在该逻辑分区上创建了两个子分区。
下面我们用命令prtvtoc将该分区的vtoc表给输出到文件/tmp/aaa,该文件内包含了该分区的子分区(slice)的相关信息。
64 # prtvtoc -f /tmp/aaa /dev/rdsk/c2b0t5d0s0
注释:
1)-f /tmp/aaa
使vtoc表输出到文件/tmp/aaa,该文件可以随意定义。
2)参数/dev/rdsk/c2b0t5d0s0
必须是目录/dev/rdsk,该参数也可以是/dev/rdsk/c2b0t5d0p0。
65 # cat /tmp/aaa
66 #SLICE TAG FLAGS START SIZE
67 0 0x5 0x201 63 69628104
68 1 0x4 0x200 3969 3969000
69 2 0x4 0x200 3972969 3969000
70 3 0x0 0x0 0 0
71 4 0x0 0x0 0 0
72 5 0x0 0x0 0 0
73 6 0x0 0x0 0 0
74 7 0x1 0x201 63 34
75 8 0xd 0x201 97 3872
76 9 0x0 0x0 0 0
77 10 0x0 0x0 0 0
78 11 0x0 0x0 0 0
79 12 0x0 0x0 0 0
80 13 0x0 0x0 0 0
81 14 0x0 0x0 0 0
82 15 0x0 0x0 0 0
注释:我们可以看到/dev/[r]dsk/c2b0t5d0s1和/dev/[r]dsk/c2b0t5d0s2对应的两个slice,第2和3行。也可以看到该活动UNIX系统分区的大小。关于该表的具体介绍请参考《prtvtoc命令介绍一节》。
83 # mount
84 /home/s1 on /dev/dsk/c2b0t5d0s1 read/write/log/setuid/mincache =closesync/noquot4
85 /home/s2 on /dev/dsk/c2b0t5d0s2 read/write/log/setuid/mincache =closesync/noquot4
86 #
a) Total disk size is 17543 cylinders (33998.1 MB)
Cylinders Approx
87 Partition Status Type Start End Length % MB
88 ====== ====== ======= ===== === ====== === ======
1 Active UNIX System 0 17542 17543 100 33998.1
89 SELECT ONE OF THE FOLLOWING:
0. Overwrite system master boot code
1. Create a partition
2. Change Active (Boot from) partition
3. Delete a partition
4. Exit (Update disk configuration and exit)
5. Cancel (Exit without updating disk configuration)
90 Enter Selection: 4
这样,我们就成功的将磁盘阵列的第一个逻辑分区增加到系统中,并且给该分区增加了两个slice子分区。
2.3.2 第二个例子
增加磁盘阵列柜第二个逻辑分区/dev/rdsk/c2b0t5d1。准备将该逻辑分区分成2个fdisk分区,并将该逻辑分区的活动fdiskUNIX系统分区(第一个fdisk分区)再分成三个子分区(slice)。
1. 用diskadd –F s5dm c2b0t5d1命令。
2. 在第一个例子的第11行处输入“n” ,进入fdisk程序对该逻辑分区进行分区。
3. 分成两个fdisk分区,整个过程如下所示:
# fdisk /dev/rdsk/c2b0t5d1s0
The recommended default partitioning for your disk is:
a 100% "UNIX System" partition.
To select this, please type "y". To partition your disk
differently, type "n" and the "fdisk" program will let you
select other partitions.y
Cylinders Approx
Partition Status Type Start End Length % MB
====== ====== ========== ===== === ====== === ======
1 Active UNIX System 0 15299 15300 45 15300.0
2 UNIX System 15300 33998 18699 55 18699.0
4. diskadd调用fdisk将硬盘分区完成以后调用disksetup –I /dev/rdsk/c2b0t5d1s0命令对该硬盘进行子分区(slice)。这个过程与第一个例子类似,我们可以证明划分子分区只是针对了active分区,通过下面的操作可以看出来。
1 You will now specify the size in cylinders of each slice.
2 (One megabyte of disk space is approximately 1 cylinders.)
3 There are now 15299 cylinders available on your disk.
4 The filesystem type you have chosen is limited to 1048576 cylinders.
5 How many cylinders would you like for /home/s21 (0 - 15299)?
第5行中的0-15299说明该UNIX系统分区的空间是15300个cylinder长度,这与用fdisk命令所划分的第1分区(当前活动的UNIX系统分区)的长度完全一样。从而印证了我们关于slice只能对硬盘的当前活动UNIX系统分区继续进行子分区的观点。
2.2.3 第三个例子
这个例子就是一个系统主机的本地IDE硬盘的第二个分区的使用情况。
我们这个例子的环境是一个IDE硬盘被分成两个fdisk分区,其中分区1安装了UnixWare7.1.x操作系统,是当前的活动的UNIX系统分区,容量为3702.4MB,472个cylinder,第二个分区是UNIX系统分区,容量为2470.9MB,315个cylinder。
我们无法象OpenServer一样将第二个分区在进行细分成很多子分区,然后使用它们,只能利用mkfs命令将第二个fdisk分区作为一个整体进行使用,不能够在继续划分子分区。
Cylinders Approx
Partition Status Type Start End Length % MB
===== ====== =========== ===== === ====== === ======
1 Active UNIX System 0 471 472 60 3702.4
2 UNIX System 472 786 315 40 2470.9
1. mkfs –F vxfs /dev/rdsk/c0b0t0d0p2 5060475
1)-F vxfs是指明要创建的文件系统。
2)/dev/rdsk/c0b0t0d0p2是第二个分区对应的设备文件。
3)5060475是以512字节进行计算的sector数量。
4)这个命令的作用就是将第二个分区创建成一个vxfs类型的文件系统。
2. mount –F vxfs /dev/dsk/c0b0t0d0p2 /home/p2
这个命令将第二个分区mount到目录/home/p2上,我们可以象一般的文件系统一样进行使用。
2.4 删除硬盘
2.4.1 diskrm命令
diskrm [-F dm_type] [disk_number]
diskrm命令的参数与diskadd完全相同,代表的意思也完全一样,它的作用就是将/etc/vfstab文件中的相应记录删除。
2.4.2 一个例子
我们这个例子是删除我们学习环境的磁盘阵列的第二个逻辑分区/dev/[r]dsk/c2b0t5d1。
我们先来看一下在没有执行命令diskrm前的/etc/vfstab的内容,我们看到第14到16行都是磁盘阵列第二逻辑分区的子分区的信息。
1 # vi /etc/vfstab
2 /dev/root /dev/rroot / vxfs 1 no mincache=closesync SYS_RANGE_MAX
3 /dev/stand /dev/rstand /stand bfs 1 no - SYS_RANGE_MAX
4 /proc - /proc proc - no -
5 /processorfs - /system/processor profs - yes -
6 /dev/fd - /dev/fd fdfs - no -
7 /dev/dsk/f0t /dev/rdsk/f0t /install s5 - no -
8 /dev/dsk/f1t /dev/rdsk/f1t /install s5 - no -
9 /dev/dsk/f0 /dev/rdsk/f0 /install s5 - no -
10 /dev/dsk/f1 /dev/rdsk/f1 /install s5 - no -
11 /tmp - /tmp memfs - yes swapmax=10485760,rootmode=1777
12 /var/tmp - /var/tmp memfs - yes swapmax=41943040,rootmode=1777
13 /dev/_tcp - /dev/_tcp specfs - yes dev=tcp
14 /dev/dsk/c2b0t5d1s1 /dev/rdsk/c2b0t5d1s1 /home/s21 vxfs 1 no mincache=closesync SYS_RANGE_MAX
15 /dev/dsk/c2b0t5d1s2 /dev/rdsk/c2b0t5d1s2 /home/s22 vxfs 1 no mincache=closesync SYS_RANGE_MAX
16 /dev/dsk/c2b0t5d1s3 /dev/rdsk/c2b0t5d1s3 /home/s23 vxfs 1 no mincache=closesync SYS_RANGE_MAX
17 /dev/dsk/c2b0t5d2s1 /dev/rdsk/c2b0t5d2s1 /home/31 vxfs 1 no mincache=closesync SYS_RANGE_MAX
18 /dev/dsk/c2b0t5d2s2 /dev/rdsk/c2b0t5d2s2 /home/32 vxfs 1 no mincache=closesync SYS_RANGE_MAX
19 /dev/root /dev/rroot / vxfs 1 no mincache=closesync SYS_RANGE_MAX
20 /dev/stand /dev/rstand /stand bfs 1 no - SYS_RANGE_MAX
21 /proc - /proc proc - no -
22 /processorfs - /system/processor profs - yes -
23 /dev/fd - /dev/fd fdfs - no -
24 /dev/dsk/f0t /dev/rdsk/f0t /install s5 - no -
25 /dev/dsk/f1t /dev/rdsk/f1t /install s5 - no -
26 /dev/dsk/f0 /dev/rdsk/f0 /install s5 - no -
27 /dev/dsk/f1 /dev/rdsk/f1 /install s5 - no -
28 /tmp - /tmp memfs - yes swapmax=10485760,rootmode=1777
29 /var/tmp - /var/tmp memfs - yes swapmax=41943040,rootmode=1777
30 /dev/_tcp - /dev/_tcp specfs - yes dev=tcp
31 /dev/dsk/c2b0t5d1s1 /dev/rdsk/c2b0t5d1s1 /home/s21 vxfs 1 no mincache=closesync SYS_RANGE_MAX
32 /dev/dsk/c2b0t5d1s2 /dev/rdsk/c2b0t5d1s2 /home/s22 vxfs 1 no mincache=closesync SYS_RANGE_MAX
33 /dev/dsk/c2b0t5d1s3 /dev/rdsk/c2b0t5d1s3 /home/s23 vxfs 1 no mincache=closesync SYS_RANGE_MAX
34 /dev/dsk/c2b0t5d2s1 /dev/rdsk/c2b0t5d2s1 /home/31 vxfs 1 no mincache=closesync SYS_RANGE_MAX
35 /dev/dsk/c2b0t5d2s2 /dev/rdsk/c2b0t5d2s2 /home/32 vxfs 1 no mincache=closesync SYS_RANGE_MAX
36 @
37 "/etc/vfstab" 21 lines, 1483 characters
我们执行命令diskrm c2b0t5d1后,在/etc/vfsvtab文件中看不到上面14到16行所显示的内容,说明删除成功。在执行该命令的过程中显示内容如下所示:
1 # diskrm c2b0t5d1
2 UX:diskrm: INFO: You have invoked the System V disk management (s5dm) diskrm ut.
3 The purpose of this utility is to remove entries from the /etc/vfstab file.
4 Do you wish to continue?
5 (Type y for yes or n for no followed by ENTER):
6 y
7 UX:diskrm: INFO:
8 Do you want to delete the following entry?
9 /dev/dsk/c2b0t5d1s1 /dev/rdsk/c2b0t5d1s1 /home/s21 vxfs 1 X
10 (Type y for yes or n for no and press ):
11 y
12 UX:diskrm: INFO:
13 Do you want to delete the following entry?
14 /dev/dsk/c2b0t5d1s2 /dev/rdsk/c2b0t5d1s2 /home/s22 vxfs 1 X
15 (Type y for yes or n for no and press ):
16 y
17 UX:diskrm: INFO:
18 Do you want to delete the following entry?
19 /dev/dsk/c2b0t5d1s3 /dev/rdsk/c2b0t5d1s3 /home/s23 vxfs 1 X
20 (Type y for yes or n for no and press ):
21 y
22 UX:diskrm: INFO: saving /etc/vfstab to /etc/Ovfstab
23 UX:diskrm: INFO: creating a new /etc/vfstab
24 UX:diskrm: INFO: Diskrm for disk c2b0t5d1 DONE at Thu Feb 26 14:07:46 CST 2004
25 #