linux檔案系統維護(四)

來源:互聯網
上載者:User

一、最佳化ext2/ext3檔案系統
1、磁碟檔案系統的資料區塊的大小,影響磁碟的儲存空間與讀取資料速度,磁碟的工作效率,最佳化檔案系統主要是正確劃分磁碟資料區塊的大小。
mkfs.ext3 -b 1024 /dev/hda1
mdfs.ext3 -b 4096 /dev/hda1

mkfs.ext3 -b 4096 -i 4096 /dev/hda1
i代表節點代表的資料區塊數:
如mkfs.ext3 -b 4096 -i 8192 /dev/hda2 一個節點代表兩個資料區塊,對大資料區塊定址讀取有好處。

2、tune2fs 查看檔案系統的資訊

[root@server root]# tune2fs -l /dev/hda10
tune2fs 1.32 (09-Nov-2002)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          6a364843-8db8-405f-a305-67ca5e1aa3e6
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal filetype sparse_super
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              26112   #節點
Block count:              26097   #資料區塊
Reserved block count:     1304
Free blocks:              24246
Free inodes:              26101
First block:              0
Block size:               4096
Fragment size:            4096
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         26112
Inode blocks per group:   816
Filesystem created:       Tue May 16 13:02:25 2006
Last mount time:          n/a
Last write time:          Tue May 16 13:02:25 2006
Mount count:              0
Maximum mount count:      29   #最大掛載次數,超過次數,分區會自檢;如果為-1分區永遠不會自檢(系統啟動時)
Last checked:             Tue May 16 13:02:25 2006
Check interval:           15552000 (6 months)
Next check after:         Sun Nov 12 13:02:25 2006
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal UUID:             <none>
Journal inode:            8
Journal device:           0x0000
First orphan inode:       0

3、保留塊:為管理員保留的磁碟管理空間,預設為總資料區塊的5%
mkfs.ext3 -b 4096 -i 8192 -m 3 /dev/hda10
設定保留塊的數量點總數的百分比為3%

4、調整ext2/ext3檔案系統
1)tune2fs — 調整ext2/ext3檔案系統特性的工具
 -l <device> 查看檔案系統資訊
 -c <count> 設定強制自檢的掛載次數
 -i <n day> 設定強制自檢的時間間隔
 -m <percentage> 保留塊的百分比
 -j 將ext2檔案系統轉換成ext3格式

二、檔案系統的檢查工具
1、fsck — 檢查檔案系統資料完整性工具
用法一:fsck -t ext2 /dev/hda10   fsck -t ext3 [-y] /dev/hda10
用法二:fsck.ext2 [-y] /dev/hda10 fsck.ext3 [-y] /dev/hda10
2、e2fsck 檢查ext2/ext3檔案系統的工具(不太安全)

三、使用磁碟配額
磁碟配額作用是限制普通使用者使用的磁碟空間,不至於因為個別人的浪費影響所有人的使用
需要核心支援
只有ext2/ext3的檔案系統目前被支援
需要使用者程式quota的軟體包

1、使用usrquota,grpquota選項掛載一個分區,啟用核心的支援
mount -o usrquota,grpquota /dev/hda10 /mnt/d1 或
mount -o remount,usrquota,grpquota /
2、init 1(進入單使用者環境)
3、quotacheck -cvuga 檢查並建立磁碟配額的資料庫檔案
4、edquota -u <username> 為指定使用者指派磁碟空間和節點數量
5、quota命令可查看使用者的配額使用
6、quotaon /quotaoff啟用/除去(刪除相關磁碟配額的資料庫檔案aquota.group 、aquota.user)磁碟配額
[root@server root]#  mount /dev/hda10 /mnt/d1 -o usrquota,grpquota
[root@server root]# mount
/dev/hda7 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda9 on /opt type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/hda10 on /mnt/d1 type ext3 (rw,usrquota,grpquota)

[root@server root]# more /etc/mtab
/dev/hda7 / ext3 rw 0 0
none /proc proc rw 0 0
usbdevfs /proc/bus/usb usbdevfs rw 0 0
none /dev/pts devpts rw,gid=5,mode=620 0 0
/dev/hda9 /opt ext3 rw 0 0
none /dev/shm tmpfs rw 0 0
/dev/hda10 /mnt/d1 ext3 rw,usrquota,grpquota 0 0

[root@server root]# edquota -u redhat
Disk quotas for user redhat (uid 500):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/hda10                        0          0          0          0        0        0

blocks:資料區塊soft、hard限制
inodes:代表檔案個數soft、hard限制

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.