Solaris调整文件系统参考

总述

UFS是Solaris缺省的基于磁盘的文件系统。管理基于磁盘的文件系统时,大多数情况下管理的是 UFS 文件系统。
本文档描述了Oracle Solaris 10操作系统下UFS文件系统常见的配置操作。

配置硬盘设备

  1. 当前磁盘状态
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# iostat -E
sd0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: VMware, Product: VMware Virtual S Revision: 1.0 Serial No:
Size: 137.44GB <137438952960 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 4 Predictive Failure Analysis: 0
sd1 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: VMware, Product: VMware Virtual S Revision: 1.0 Serial No:
Size: 274.88GB <274877906432 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 4 Predictive Failure Analysis: 0
sd2 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: NECVMWar Product: VMware IDE CDR10 Revision: 1.00 Serial No:
Size: 2.25GB <2254110720 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 12 Predictive Failure Analysis: 0

# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t0d0 <VMware,-VMware Virtual -1.0 cyl 16706 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@0,0
1. c1t1d0 <VMware,-VMware Virtual -1.0 cyl 33416 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@1,0
  1. 添加一块10G大小的物理磁盘

  2. 在线识别新设备

1
# devfsadm
  1. 查看新添加的磁盘
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# iostat -E
sd0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: VMware, Product: VMware Virtual S Revision: 1.0 Serial No:
Size: 137.44GB <137438952960 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 4 Predictive Failure Analysis: 0
sd1 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: VMware, Product: VMware Virtual S Revision: 1.0 Serial No:
Size: 274.88GB <274877906432 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 8 Predictive Failure Analysis: 0
sd2 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: NECVMWar Product: VMware IDE CDR10 Revision: 1.00 Serial No:
Size: 2.25GB <2254110720 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 12 Predictive Failure Analysis: 0
sd3 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: VMware, Product: VMware Virtual S Revision: 1.0 Serial No:
Size: 10.74GB <10737417728 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 8 Predictive Failure Analysis: 0




# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t0d0 <VMware,-VMware Virtual -1.0 cyl 16706 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@0,0
1. c1t1d0 <VMware,-VMware Virtual -1.0 cyl 33416 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@1,0
2. c1t2d0 <VMware,-VMware Virtual -1.0 cyl 1303 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@2,0

# ls -l
...节选...
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0p0 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:q
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0p1 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:r
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0p2 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:s
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0p3 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:t
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0p4 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:u
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s0 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:a
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s1 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:b
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s10 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:k
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s11 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:l
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s12 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:m
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s13 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:n
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s14 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:o
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s15 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:p
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s2 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:c
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s3 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:d
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s4 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:e
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s5 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:f
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s6 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:g
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s7 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:h
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s8 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:i
lrwxrwxrwx 1 root root 46 Jan 12 16:15 c1t2d0s9 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@2,0:j
...节选...
  1. 格式化新磁盘
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t0d0 <VMware,-VMware Virtual -1.0 cyl 16706 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@0,0
1. c1t1d0 <VMware,-VMware Virtual -1.0 cyl 33416 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@1,0
2. c1t2d0 <VMware,-VMware Virtual -1.0 cyl 1303 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@2,0
Specify disk (enter its number): 2
selecting c1t2d0
[disk formatted]
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
fdisk - run the fdisk program
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
  1. 低级格式化硬盘
1
2
3
4
5
6
format> fdisk
No fdisk table exists. The default partition for the disk is:
a 100% "SOLARIS System" partition
Type "y" to accept the default partition, otherwise type "n" to edit the
partition table.
y
  1. 显示硬盘分区
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
format> p
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
!<cmd> - execute <cmd>, then return
quit

partition> print
Current partition table (original):
Total disk cylinders available: 1302 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 - 1301 9.97GB (1302/0/0) 20916630
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
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
8 boot wu 0 - 0 7.84MB (1/0/0) 16065
9 unassigned wm 0 0 (0/0/0) 0
  1. 分配分区容量
1
2
3
4
5
6
7
partition> 0
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0
Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]:
Enter partition size[0b, 0c, 0e, 0.00mb, 0.00gb]: 9.97gb
  1. 显示分区信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
partition> p
Current partition table (unnamed):
Total disk cylinders available: 1302 + 2 (reserved cylinders)

Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 - 1301 9.97GB (1302/0/0) 20916630
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 - 1301 9.97GB (1302/0/0) 20916630
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
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
8 boot wu 0 - 0 7.84MB (1/0/0) 16065
9 unassigned wm 0 0 (0/0/0) 0

  1. 标记磁盘
1
2
partition> label
Ready to label disk, continue? y
  1. 保存分区信息
1
2
3
format> save
Saving new disk and partition definitions
Enter file name["./format.dat"]:

配置文件系统

  1. 新建文件系统
1
2
3
4
5
6
7
8
9
# newfs /dev/dsk/c1t2d0s0
newfs: construct a new file system /dev/rdsk/c1t2d0s0: (y/n)? y
Warning: 3690 sector(s) in last cylinder unallocated
/dev/rdsk/c1t2d0s0: 20916630 sectors in 3405 cylinders of 48 tracks, 128 sectors
10213.2MB in 213 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
19957152, 20055584, 20154016, 20252448, 20350880, 20449312, 20547744,
20646176, 20744608, 20843040
  1. 创建挂载点目录
1
# mkdir /chenrong_10g
  1. 挂载分区(临时)
1
# mount /dev/dsk/c1t2d0s0 /chenrong_10g
  1. 查看文件系统
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# df -h
Filesystem size used avail capacity Mounted on
rpool/ROOT/s10x_u11wos_24a
125G 19G 94G 17% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 7.9G 380K 7.9G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
sharefs 0K 0K 0K 0% /etc/dfs/sharetab
/usr/lib/libc/libc_hwcap1.so.1
114G 19G 94G 17% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 7.9G 40K 7.9G 1% /tmp
swap 7.9G 32K 7.9G 1% /var/run
rpool/export 125G 32K 94G 1% /export
rpool/export/home 125G 1.8M 94G 1% /export/home
rpool 125G 42K 94G 1% /rpool
/vol/dev/dsk/c0t0d0/sol_10_113_x86
2.1G 2.1G 0K 100% /cdrom/sol_10_113_x86
/dev/dsk/c1t2d0s0 9.8G 10.0M 9.7G 1% /chenrong_10g
  1. 编辑配置文件,使挂载点永久生效
1
2
3
4
5
6
7
8
9
10
11
12
13
# cat /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/zvol/dsk/rpool/swap - - swap - no -
/devices - /devices devfs - no -
sharefs - /etc/dfs/sharetab sharefs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
/dev/dsk/c1t2d0s0 /dev/rdsk/c1t2d0s0 /chenrong_10g ufs 2 yes -
  1. 重启系统,挂载点能正常使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Connection established.
Escape character is '^@]'.

Last login: Mon Jan 12 16:34:10 2015 from 192.168.137.105
Oracle Corporation SunOS 5.10 Generic Patch January 2005

# df -h
Filesystem size used avail capacity Mounted on
rpool/ROOT/s10x_u11wos_24a
125G 19G 94G 17% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 7.9G 388K 7.9G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
sharefs 0K 0K 0K 0% /etc/dfs/sharetab
/usr/lib/libc/libc_hwcap1.so.1
114G 19G 94G 17% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 7.9G 40K 7.9G 1% /tmp
swap 7.9G 32K 7.9G 1% /var/run
/dev/dsk/c1t2d0s0 9.8G 10.0M 9.7G 1% /chenrong_10g
rpool/export 125G 32K 94G 1% /export
rpool/export/home 125G 1.8M 94G 1% /export/home
rpool 125G 42K 94G 1% /rpool
/vol/dev/dsk/c0t0d0/sol_10_113_x86
2.1G 2.1G 0K 100% /cdrom/sol_10_113_x86
# cd /chenrong_10g
# ls
lost+found

增补资料

/etc/vfstab文件中fsck pass一栏下的数字1和2区别?
fsck pass Fsck检测次数,用于决定是否需要检测文件系统,当该域是”-“号时不检测文件系统,当该域的值大于1时,则检查文件系统;等于0时,则检查非ufs文件系统,而不检查ufs文件系统,当fsck作用多个ufs文件系统,而fsck pass值大于1,并且使用了-op选择项时,fsck 自动以最高的效率并行检测不同盘上的文件系统,当fsck pass值为1时,则顺序检测文件系统,否则fsck pass值无效。

在普通情况下,pass Fsck >;=1 则检查对应的文件系统,所以此时1、2、3……没区别。
在使用了-o p选择项时(如命令fsck -o p /export/home),如果该文件系统跨了多个盘,pass Fsck >;1则并行检测不同盘上的文件系统,pass Fsck =1则顺序检测不同盘上的文件系统。此时2、3、4……没区别。