免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1201 | 回复: 0
打印 上一主题 下一主题

管理solaris10文件系统I [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-01-19 14:04 |只看该作者 |正序浏览
管理solaris10文件系统I

一、
Accessing a Diskette, CD-ROM, or DVD Without Volume Management (vold)
   
    When Volume Management (vold) is not running, only the root user can mount and access a diskette or CD-ROM. Follow these steps:
Insert the media device.
Become the root user.
Create a mount point, if necessary.
Determine the
file system
type.
Mount the device by using the mount options listed in the following sections.
Work with files on the media device.
Unmount the media device.
Eject the media device.
Exit the root session.
To mount a file system that resides on a CD-ROM when the Volume Management (vold) services are stopped, as the root user, perform the command:
# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
In this example, the file system type is hsfs, the file system resides on disk slice /dev/dsk/c0t6d0s0, and the mount point /cdrom is a preexisting directory in the Solaris OS.
To mount a file system that resides on a diskette when the Volume Management (vold) services are stopped, as the root user, perform the command:
# mkdir /pcfs
# mount -F pcfs /dev/diskette /pcfs
In this example, the file system type is pcfs. This file system resides on the /dev/diskette device, and the mount point used is /pcfs.
二、
Restricting Access to Mounted Diskettes, CD-ROMs, or DVDs
   To restrict regular users from accessing diskettes or CD-ROMs on the
system
, you can, as the root user, terminate the Volume Management (vold) service.
To stop Volume Management (vold) from running on a system temporarily, as the root user, perform the command:
# /etc/init.d/volmgt stop
To restart the Volume Management (vold) service, as the root user, perform the command:
# /etc/init.d/volmgt start
If a
CD-ROM
fails to eject from the drive, as the root user, attempt to stop Volume Management (vold). If this is unsuccessful, kill the vold daemon.
# /etc/init.d/volmgt stop
or as a last resort:
# pkill -9 vold
Push the button on the system to eject the CD-ROM. The CD-ROM tray ejects. Remove the CD-ROM, and leave the tray out. Then restart the Volume Management (vold) service.
# /etc/init.d/volmgt start
Wait a few seconds, and then push the CD-ROM tray back into the drive.
三、Create a new file system
A
file system
is a collection of files and directories that make up a structured set of information. The
Solaris OS
supports three different types of file
systems
:

    Disk-based file systems
    Distributed file systems
    Pseudo file systems

Disk-based file systems are found on hard disks,
CD-ROMs
, diskettes, and DVDs. The following are examples of disk-based file systems:

    ufs - The UNIX file system in the Solaris OS is based on the Berkeley fast file system. Enhancements in the
    Solaris 10 OS
    allow the ufs file system to grow to multiple terabytes in size.
    hsfs - The High Sierra file system is a special-purpose file system developed for use on CD-ROM media.
    pcfs - The PC file system is a UNIX implementation of the disk
    operating system
    (DOS) file allocation table (FAT32) file system. The pcfs file system allows the Solaris OS to access PC-DOS formatted file systems. Users can use
    UNIX commands
    for direct read and write access to PC-DOS files.
    udfs - The Universal Disk Format file system is used for
    optical storage
    targeted at DVD and CD-ROM media. The UDF file system allows universal data exchange and supports read and write operations.

Distributed file systems provide
network access
to file system resources.

    NFS - The network file system allows users to share files among many types of systems on the network. The NFS file system makes part of a file system on one system appear as though it were part of the local directory tree.

Pseudo file systems are memory based. These file systems provide for better
system performance
, in addition to providing access to kernel information and facilities. Pseudo file systems include:

    tmpfs - The temporary file system stores files in memory, which avoids the overhead of writing to a disk-based file system. The tmpfs file system is created and destroyed every time the system is rebooted.
    swapfs - The swap file system is used by the kernel to manage swap space on disks.
    fdfs - The file descriptor file system provides explicit names for opening files by using file descriptors (for example, /dev/fd/0, /dev/fd/1, /dev/fd/2) in the /dev/fd directory.
    procfs - The process file system contains a list of active processes in the /proc directory. The processes are listed by process number. Information in this directory is used by commands, such as the ps command.
    mntfs - The mount file system provides read-only information from the kernel about locally mounted file systems.
    objfs - The kernel object file system. This file system is used by the kernel to store details relating to the modules currently loaded by the kernel. The object file system is used for the /system/object directory.
    devfs - The device file system is used to manage the namespace of all devices on the system. This file system is used for the /devices directory.
    ctfs - The contract file system. This is used by the Solaris Zones feature and is associated with the /system/contract directory.

This section describes the ufs file system in the Solaris OS.
The user views the ufs file system differently than the operating system does in the Solaris OS. To a user, a file system appears as a collection of files and directories used to store and organize data for access by the system and its users. To the operating system, a file system is a collection of control structures and data blocks that occupy the space defined by a partition, which allow for
data storage
and management.
The Solaris OS stores data in a logical file hierarchy often consisting of several file systems. This file hierarchy is referred to as the Solaris OS directory hierarchy.
The image shows the Solaris OS hierarchy beginning with the / (root) directory.

Note: The image The image is not a complete representation of a Solaris OS directory hierarchy.
A ufs file system is created on a disk slice before it is used in the Solaris OS. Creating a ufs file system on a disk slice enables the Solaris OS to store UNIX directories and files.
The Explore shows how the ufs file systems are located on various disk slices.
The Solaris OS ufs file system contains the following basic support structures.
Disk Label (VTOC)
The disk label (VTOC) contains the partition table for the disk. The VTOC resides in sectors one and two of the first cylinder in the Solaris OS fdisk partition (sector 0 contains the pboot). Only the disk slice containing sectors 1 and 2 contains a VTOC.
Boot Block
The bootstrap program (bootblk) resides in approximately 30 sectors in the first cylinder of the Solaris OS fdisk partition. Only the / (root) file system has an active boot block.
The bootblk program accesses the fdisk partition information and displays a menu of partitions on the
boot disk
. The user can select the partition to boot from or the bootblk program will time out and select the Solaris OS partition.
The bootblk is located within the Solaris OS at /usr/platform/i86pc/lib/fs/ufs/bootblk. The bootblk program finds and executes the secondary boot program.
Secondary Boot Program
The bootblk accesses the /boot UFS file system and loads and executes /boot/solaris/boot.bin. The boot.bin command executes in the protected mode in memory above 1 Mbyte. The boot.bin command builds some portion of the device tree. It sets some default properties for known nodes, root, for example. Then, it launches the 16-bit /boot/solaris/bootconf.exe in lowmem. The purpose of the bootconf.exe command is to probe devices using realmode drivers and pass detected nodes to boot.bin.
Primary Superblock
The superblock resides in the 16 disk sectors (Sectors 16-31) in the UFS file system. The superblock is a table of information that describes the file system, including the following:

    The number of data blocks
    The number of cylinder groups
    The size of a data block and fragment
    A description of the hardware, derived from the label
    The name of the mount point
    File system state flag: clean, stable, active, logging, or unknown

Backup Superblocks
When the file system is created, each cylinder group replicates the superblock beginning at Sector 32. This replication protects the
critical data
in the superblock against catastrophic loss.
Cylinder Groups
Each file system is divided into cylinder groups with a minimum default size of 16 cylinders per group. Cylinder groups improve disk access.
The file system constantly optimizes disk performance by attempting to place a file’s data into a single cylinder group, which reduces the distance a head has to travel to access the file’s data. The file system stores large files across several cylinder groups, if needed.
Cylinder Group Blocks
The cylinder group block is a table in each cylinder group that describes the cylinder group, including:

    The number of inodes
    The number of data blocks in the cylinder group
    The number of directories
    Free blocks, free inodes, and free fragments in the cylinder group
    The free block map
    The used inode map

The image shows a series of cylinder groups in a ufs file system within a Solaris OS fdisk partition.

The ufs Inode
An inode contains the following information about a file:

    The type of file and the access modes
    The user identification (UID) and group identification (GID) numbers of the file’s owner and group
    The size of the file
    The link count
    The time the file was last accessed and modified and the inode changed
    The total number of data blocks used by or allocated to the file
    Two types of pointers: direct pointers and indirect pointers

The Demo shows some of the information contained in an inode.
Note: To view some of the information contained in a file or directory inode, use the ls -l command. To view the inode number assigned to the file or directory, use the ls -i command.
Direct Pointers
Inside the inode there are 12 direct pointers, which contain addresses for the file’s first 12 data blocks. The 12 direct pointers can each reference 8-Kbyte data blocks for a file that is up to 96 Kbytes.
Indirect Pointers
The three types of indirect pointers within an inode are:

    Single indirect pointer - Refers to a file system block that contains pointers to data blocks. This file system block contains 2048 additional addresses of 8-Kbyte data blocks, which can point to an additional 16 Mbytes of data.
    Double indirect pointer - Refers to a file system block that contains single indirect pointers. Each indirect pointer refers to a file system block that contains the data block pointers. Double indirect pointers point to an additional 32 Gbytes of data.
  • Triple indirect pointer - Can reference up to an additional 64 Tbytes of data. However, the maximum size of a ufs file system is limited to 1 Tbyte due to the maximum address space of 32-bits for the device drivers.

Data Blocks
The remaining space allocated to the ufs file system holds data blocks. Data blocks are allocated, by default, in 8-Kbyte logical block sizes. The blocks are further divided into 1-Kbyte fragments. For a regular file, the data blocks contain the contents of the file. For a directory, the data blocks contain entries that associate the inode numbers and the file names of the files and directories contained in that directory.
Within a file system, those blocks that are currently not being used as files, directories, indirect address blocks, or storage blocks are marked as free in the cylinder group map. This map also keeps track of fragments to prevent disk performance from degrading.
Fragmentation
Fragmentation is the method used by the ufs file system to allocate disk space efficiently. Files less than 96 Kbytes in size are stored using fragmentation.
By default, data blocks can be divided into eight fragments of 1024 bytes each. Fragments store files and pieces of files smaller than 8192 bytes. For files larger than 96 Kbytes, fragments are never allocated and full blocks are exclusively used.
The Demo shows a fragment in a data block.
If a file contained in a fragment grows and requires more space, it is allocated one or more additional fragments in the same data block.
The Demo shows the contents of two different files stored in fragments in the same data block.
For example, if File1 requires more space than is currently available in the shared data block, the entire contents of that expanding file are moved by the ufs file system into a free data block. This requirement by the ufs file system assures that all of a file’s fragments are contained in a whole data block. The ufs file system does not allow fragments of the same file to be stored in two different data blocks.
To use the disk to store directories or files, a file system must be created on every disk partition. As the root user, you can construct a ufs file system on a disk slice by using the newfs command.
The newfs command is an easy-to-use front-end to the mkfs command, which you use to create file systems. The newfs command is located in the /usr/sbin directory.
Caution: Creating a new file system is destructive. The mkfs and newfs commands overwrites data that resides on the selected disk slice.
To create a ufs file system, by using the newfs command, perform the following steps:
  • As the root user, create a file system on a slice of a newly partitioned disk by entering the command: # newfs /dev/rdsk/c1t3d0s7
  • The newfs command asks for confirmation before continuing. Verify that the correct disk slice on the correct disk is selected. To proceed, type y, to terminate the process, type n. newfs: construct a new file system /dev/rdsk/c1t3d0s7: (y/n)? y
    The newfs command displays information about the new file system being created.
    /dev/rdsk/c1t3d0s7: 6295022 sectors in 1753 cylinders of 27 tracks,
    133 sectors 3073.7MB in 110 cyl groups (16 c/g, 28.05MB/g, 3392 i/g)
    super-block backups (for fsck -F ufs -o b=#) at:
    32, 57632, 115232, 172832, 230432, 288032, 345632, 403232, 460832,
    518432, 5746208, 5803808, 5861408, 5919008, 5976608, 6034208, 6091808,
    6149408, 6207008, 6264608,
    #
    The first line printed by the newfs command describes the basic disk geometry. The second line describes the ufs file system created in this slice. The third and remaining lines list the beginning sector locations of the backup superblocks.
    The newfs -i command is used to specify the density of the number of bytes per inode in the file system. To create more inodes, a smaller number should be given.
    Note: This process also creates a lost+found directory for the ufs file system, which is a directory that is used by the file system check and repair (fsck) utility.
  • Repeat Steps 1 and 2 for every disk slice on any newly partitioned disk that needs to contain a file system.The newfs command reserves between 1 and 10 percent of the file system space (depending on the size of the file system) for maintenance. This free space, referred to as minfree, specifies the amount of space on the slice that is reserved or held back from regular users. You can use the newfs -m %free command to preset the percentage of free space when you create a new file system. # fstyp -v /dev/dsk/c0t1d0s6 |head
    (output omitted for brevity)
    minfree 10%     maxbpg  2048    optim   time
    # newfs -m 2 /dev/dsk/c0t1d0s6
    newfs: construct a new file system /dev/rdsk/c0t1d0s6: (y/n)? y
    (output omitted for brevity)
    # fstyp -v /dev/dsk/c0t1d0s6 |head
    (output omitted for brevity
    minfree 2%      maxbpg  2048    optim   time
    To show the value of minfree on a file system, use the fstyp command.
    The following command shows the minfree value for the file system on the c1t3d0s7 device.
    # fstyp -v /dev/rdsk/c1t3d0s7 | head
    ufs
    magic   11954   format  dynamic time    Fri Oct 22 10:09:11 2004
    sblkno  16      cblkno  24      iblkno  32      dblkno  456
    sbsize  5120    cgsize  5120    cgoffset 72     cgmask  0xffffffe0
    ncg     110     size    3147511 blocks  3099093
    bsize   8192    shift   13      mask    0xffffe000
    fsize   1024    shift   10      mask    0xfffffc00
    frag    8       shift   3       fsbtodb 1
    minfree 2%      maxbpg  2048    optim   time
    maxcontig 128   rotdelay 0ms    rps     120
    To change the minimum percentage value of free space on an existing file system, you can use the tunefs -m %free command.
    The following command changes the minimum percentage of free space on the /dev/rdsk/c1t3d0s7 device to one percent.
    # tunefs -m 1 /dev/rdsk/c1t3d0s7
    minimum percentage of free space changes from 10% to 1%


    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/36549/showart_467841.html
  •   

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP