【正文】
接點(diǎn) 文件系統(tǒng)的狀態(tài):干凈、穩(wěn)定或激活 備份的超級(jí)塊 由于超級(jí)塊包含了許多關(guān)鍵數(shù)據(jù),因此,必須要備份。備份是在文件系統(tǒng)創(chuàng)建時(shí)產(chǎn)生的。 Solaris下以inode的方式記錄文件 Inode包含文件的下列信息: 文件類(lèi)型和訪問(wèn)模式 文件的擁有者和所在組的 文件大小 上次訪問(wèn)和更改的時(shí)間以及inode更改的時(shí)間 已用數(shù)據(jù)塊的數(shù)量 inode包含兩種指針:直接指針和間接指針 直接指針 有12個(gè),直接指向數(shù)據(jù)塊。這12個(gè)指針可以支持96K字節(jié)的文件。 間接指針 單倍間接– 單倍間接指針指向包含指針的數(shù)據(jù)塊。這樣可以支持16M字節(jié)的文件。 雙倍間接–雙倍間接指針指向包含單倍間接指針的數(shù)據(jù)塊。這樣可以支持32G字節(jié)的文件。 三倍間接–三倍間接指針指向包含雙倍間接指針的數(shù)據(jù)塊。這樣可以支持70T字節(jié)的文件。 newfs創(chuàng)建文件系統(tǒng) newfs /dev/rdsk/c0t2d0s0 newfs: construct a new file system /dev/rdsk/c0t2d0s0: (y/n)? y /dev/rdsk/c0t2d0s0: 41040 sectors in 57 cylinders of 9 tracks, 80 sectors in 4 cyl groups (16 c/g, , 2688 i/g) superblock backups (for fsck F ufs o b=) at: 32, 11632, 23232, 34832, 文件系統(tǒng)檢測(cè)工具(fsck)用于檢測(cè)文件系統(tǒng)是否出錯(cuò)。 比如,某個(gè)數(shù)據(jù)塊不能同時(shí)被兩個(gè)不同的inode占用。Fsck程序可以檢測(cè)這種錯(cuò)誤。 fsck /dev/rdsk/c0t3d0s7 ** /dev/rdsk/c0t3d0s7 ** Last Mounted on /export/home ** Phase 1 Check Blocks and Sizes ** Phase 2 Check Pathnames ** Phase 3 Check Connectivity ** Phase 4 Check Reference Counts ** Phase 5 Check Cyl groups 2 files, 9 used, 21606 free (14 frags, 2699 blocks, % fragmentation) 文件系統(tǒng)錯(cuò)誤 許多情況下,文件系統(tǒng)發(fā)生錯(cuò)誤是由于超級(jí)塊有錯(cuò)誤。發(fā)生錯(cuò)誤的原因主要是: 非正常關(guān)機(jī) 掉電 硬件錯(cuò)誤 fsck運(yùn)行的時(shí)間 系統(tǒng)每次啟動(dòng)時(shí)都會(huì)自動(dòng)運(yùn)行fsck。如果發(fā)現(xiàn)錯(cuò)誤,會(huì)嘗試自動(dòng)修復(fù),如果錯(cuò)誤非常嚴(yán)重,需要人工修復(fù)。這是進(jìn)入系統(tǒng)單用戶(hù)模式,然后打命令: fsck /dev/rdks/c0t0d0s0 df命令查看已掛接的文件系統(tǒng)使用狀況 參數(shù)k:表示以千字節(jié)格式顯示 $ df k Filesystem kbytes used avail capacity Mounted on /dev/dsk/c0t3d0s0 38111 19196 18877 51% / /dev/dsk/c0t3d0s6 565503 361529 203409 64% /usr /proc 0 0 0 0% /proc fd 0 0 0 0% /dev/fd /dev/dsk/c0t3d0s1 25159 4886 20248 20% /var /dev/dsk/c0t3d0s5 27439 20362 7050 75% /opt swap 45980 12 45968 1% /tmp du命令顯示某個(gè)目錄下文件的占用磁盤(pán)空間的情況: du [a] [s] [k] [directory] 參數(shù): k 以千字節(jié)方式顯示(默認(rèn)是以塊方式顯示,一個(gè)塊為512字節(jié)) s 只以簡(jiǎn)略的方式顯示 a 顯示制定目錄下所有文件和目錄占用的磁盤(pán)塊數(shù)量 第十四章 文件系統(tǒng)掛接掛接就是將分離的文件系統(tǒng)附加到文件系統(tǒng)分成結(jié)構(gòu)中。文件系統(tǒng)要附加到某個(gè)掛接點(diǎn),也就是目錄。 掛接和卸載文件系統(tǒng)發(fā)生在系統(tǒng)啟動(dòng)和關(guān)閉時(shí)。 系統(tǒng)啟動(dòng)時(shí),將讀取/etc/vfstab文件。這個(gè)文件記錄系統(tǒng)要掛接的文件系統(tǒng)。因此/etc/vfstab文件中的文件系統(tǒng)將自動(dòng)掛接。也可以從命令行方式下人工掛接文件系統(tǒng)。 不加參數(shù)的mount顯示系統(tǒng)目前已經(jīng)掛接的文件系統(tǒng)。 mount / on /dev/dsk/c0t3d0s0 read/write/setuid/largefiles/logging on Mon Nov 18 17:58:19 1998 /usr on /dev/dsk/c0t3d0s6 read/write/setuid/largefiles/logging on Mon Nov 18 17:58:19 1998 /proc on /proc read/write/setuid on Mon Nov 18 17:58:19 1998 /dev/fd on fd read/write/setuid on Mon Nov 18 17:58:19 1998 /var on /dev/dsk/c0t3d0s1 nolargefiles/read/write/setuid on Mon Nov 18 17:58:19 1998 /opt on /dev/dsk/c0t3d0s5 setuid/read/write/largefiles on Mon Nov 18 17:58:20 1998 /tmp on swap read/write on Mon Nov 18 17:58:20 1998 /pns on dbserver:/export/pse soft/nosuid/remote on Mon Nov 18 19:04:36 1998 nolargefiles參數(shù)將使文件系統(tǒng)中所有新建的文件小于2G字節(jié)。 mount o nolargefiles /dev/dsk/c0t3d0s7 /export/home 使用這個(gè)參數(shù)可能出現(xiàn)錯(cuò)誤,原因是由于文件系統(tǒng)包含了大于2G的文件 要掛接在/etc/vfstab中已有的某個(gè)文件系統(tǒng)時(shí),只需要用命令 mount /export/home /etc/vfstab文件格式 device device mount FS fsck mount mount to mount to fsck point type pass at boot ops /dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr ufs 1 yes /proc /proc proc no fd /dev/fd fd no swap /tmp tmpfs yes /dev/dsk/c0t3d0s0 /dev/rdsk/c0t3d0s0 / ufs 1 no /dev/dsk/c0t3d0s6 /dev/rdsk/c0t3d0s6 /usr ufs 1 no /dev/dsk/c0t3d0s3 /dev/rdsk/c0t3d0s3 /export ufs 5 yes /dev/dsk/c0t3d0s7 /dev/rdsk/c0t3d0s7 /export/home ufs 5 yes /dev/dsk/c0t3d0s5 /dev/rdsk/c0t3d0s5 /opt ufs 8 yes /dev/dsk/c0t3d0s1 swap no umount卸載文件系統(tǒng) umount /dev/dsk/c0t3d0s7 或 umount /export/home 如果文件系統(tǒng)中某個(gè)文件正在使用,則不能卸載這個(gè)文件系統(tǒng)。 總結(jié):如何增加一個(gè)新的硬盤(pán) 1. Set up hardware, including setting switches and attaching cables. Follow the instructions included with the new disk. 2. Reboot the system using the mand boot r. This mand will restart the system using the reconfigure (r) option. 3. Partition the disk. 4. Create the new file systems as required. 5. Edit the /etc/vfstab file as required. 6. Reboot the system. 光驅(qū)、軟驅(qū)的使用 Solaris有個(gè)服務(wù)進(jìn)程管理光驅(qū)和軟驅(qū),當(dāng)光盤(pán)或軟盤(pán)放入機(jī)器中,系統(tǒng)會(huì)自動(dòng)的掛接上,掛接的目錄是: Media Location CDROM /cdrom/cdrom_name Diskette /floppy/floppy_name 如: cd /cdrom/cdrom0 管理進(jìn)程叫卷管理服務(wù)器,其腳本位于/etc/。 第十五章 網(wǎng)絡(luò)文件系統(tǒng)NFS即網(wǎng)絡(luò)文件系統(tǒng),是UNIX系統(tǒng)直接用以共享文件的協(xié)議。 NFS服務(wù)器:提供網(wǎng)絡(luò)共享資源的系統(tǒng) NFS客戶(hù):使用網(wǎng)絡(luò)共享資源的系統(tǒng) 當(dāng)客戶(hù)端發(fā)出一個(gè)NFS請(qǐng)求時(shí),掛接進(jìn)程聯(lián)系掛接守護(hù)進(jìn)程(/usr/lib/nfs/mountd)。本地掛接進(jìn)程將掛接信息寫(xiě)到/etc/mnttab文件中。一旦客戶(hù)完成NFS掛接請(qǐng)求,服務(wù)器中的/etc/rmtab文件中會(huì)寫(xiě)入掛接信息。當(dāng)客戶(hù)卸載了NFS共享資源后,這些信息就會(huì)從文件中刪除。 NFS 服務(wù)器守護(hù)進(jìn)程 當(dāng)客戶(hù)試圖訪問(wèn)遠(yuǎn)程共享資源時(shí),NFS服務(wù)器的守護(hù)進(jìn)程(/usr/lib/nfs/nfsd)響應(yīng)請(qǐng)求并返回?cái)?shù)據(jù)。服務(wù)器守護(hù)進(jìn)程由/etc/。如果/etc/dfs/dfstab文件中有共享?xiàng)l目,這些共享目錄會(huì)在守護(hù)進(jìn)程啟動(dòng)時(shí)自動(dòng)共享。 客戶(hù)端NFS 守護(hù)進(jìn)程 客戶(hù)端有兩個(gè)守護(hù)進(jìn)程,/usr/lib/nfs/statd和/usr/lib/nfs/lockd。這些進(jìn)程在系統(tǒng)進(jìn)入運(yùn)行級(jí)別2時(shí)自動(dòng)運(yùn)行。 more /etc/dfs/dfstab Place share(M) mands here for automatic execution on entering init state 3. Issue the mand 39。/etc/39。 to run the NFS daemon processes and the share mands, after adding the very first entry to this file. share [F fstype] [ o options] [d ] [resource] , share F nfs o rw=engineering d home dirs /export/home2 share命令 share [ F FSType ] [ o options ] [ d description ] pathname 參數(shù) F FSType 指定文件系統(tǒng)的類(lèi)型。如果/etc/dfs/fstypes文件中缺省的遠(yuǎn)程文件類(lèi)型是NFS,則不需要指定 o options 控制客戶(hù)端訪問(wèn)NFS共享資源的權(quán)限 d description 共享資源的描述 pathname 要共享的資源 unshare命令 unshare [ F nfs ] pathname dfshares命令 用以查看服務(wù)器的共享資源 dfshares RESOURCE SERVER ACCESS TRANSPORT venus:/usr/share/man venus dfshares mars RESOURCE SERVER ACCESS TRANSPORT mars:/export mars dfmounts命令 服務(wù)器上查看共享資源被利用的狀況 dfmounts RESOURCE SERVER PATHNAME CLIENTS venus /usr/share/man earth, pluto,(anon) 掛接遠(yuǎn)程網(wǎng)絡(luò)文件系統(tǒng) mount [ F nfs ] [ o options ] server:pathname mount_point mount venus:/usr/share/man /usr/share/manSolaris網(wǎng)絡(luò)管理員培訓(xùn) 第一章 網(wǎng)絡(luò)地址和掩碼 1. /etc/ Interface是網(wǎng)卡的型號(hào),有l(wèi)e、hme等。Le是十兆網(wǎng)卡,hme為百兆網(wǎng)卡等等。后面跟一個(gè)數(shù)字,第一個(gè)十兆網(wǎng)卡為le0,第二個(gè)為le1;第二個(gè)百兆網(wǎng)卡為hme0,第二個(gè)為hme1等等。 文件的內(nèi)容是這塊網(wǎng)卡的名字,如Sunrise、Sunny。 #more /