ext3格式下的quota的實現(轉)

BSDLite發表於2007-08-12
ext3格式下的quota的實現(轉)[@more@]  ext3是由開放資源社群開發的日誌檔案系統,ext3被設計成是ext2的升級版本,ext3在ext2的基礎上加入了記錄後設資料的日誌功能,努力保持向前和向後的相容性。這個檔案系統被稱為ext2的下一個版本。
  ext3fs最大的優點是向下相容ext2,而且ext3fs還支援非同步的日誌,這意味著它的效能可能比ext2還好。但是使用ext3檔案系統時不支援磁碟限量功能。
  red hat從kernel2.4.17-pre8以後支援ext3的磁碟quota,我選擇了更為穩定的kernel2.4.18來實現。
  
  <1.原始檔>
  kernel-2.4.18:
  quota:
  把檔案放在/home/src下

  2-1-2)kernel升級過程:
  #cd /home/src
  #mkdir kernel_update
  #cp ./linux-2.4.18.tar.gz ./kernel_update
  #cd kernel_update
  #tar zxvf linux-2.4.18.tar.gz
  #cd linux
  #make menuconfig
  此時出現Linux Kernel v2.4.18 Configuration的視窗
  
  Processor type and features ---&gt
  General setup ---&gt
  Memory Technology Devices (MTD) ---&gt
  Parallel port support ---&gt
  Plug and Play configuration ---&gt
  Block devices ---&gt
  Multi-device support (RAID and LVM) ---&gt
  Networking options ---&gt
  Telephony Support ---&gt
  ATA/IDE/MFM/RLL support ---&gt
  SCSI support ---&gt
  Fusion MPT device support ---&gt
  I2O device support ---&gt
  Network device support ---&gt
  Amateur Radio support ---&gt
  IrDA (infrared) support ---&gt
  ISDN subsystem ---&gt
  Old CD-ROM drivers (not SCSI, not IDE) ---&gt
  Input core support ---&gt
  Character devices ---&gt
  Multimedia devices ---&gt
  File systems ---&gt
  Console drivers ---&gt
  Sound ---&gt
  USB support ---&gt
  Kernel hacking ---&gt
  ---
  Load an Alternate Configuration File
  Save Configuration to an Alternate File
  以下都是kernel裡的選項,可以根據server硬體的不同自行選擇
  
  與quota有關的設定如下
  找到File systems ---&gt 的字樣 (第22行) 按空格鍵
  把第一行的Quota support前打上*號
  
  • Quota support
      Kernel automounter support
       Kernel automounter version 4 support (also supports v3)
       Reiserfs support
      Ext3 journalling file system support (EXPERIMENTAL)

      
  • JBD (ext3) debugging support
       DOS FAT fs support
       Compressed ROM file system support
      
  • Virtual memory file system support (former shm fs)
       Simple RAM-based file system support
       ISO 9660 CDROM file system support
      [ ] Microsoft Joliet CDROM extensions
      [ ] Transparent decompression extension
       Minix fs support
       FreeVxFS file system support (VERITAS VxFS(TM) compatible)
       NTFS file system support (read only)
       OS/2 HPFS file system support

      
  • /proc file system support
      
  • /dev/pts file system for Unix98 PTYs
       ROM file system support
       Second extended fs support
       System V/Xenix/V7/Coherent file system support
       UDF file system support (read only)
       UFS file system support (read only)
      Network File Systems ---&gt
      
      選定以後選擇exit退出。
      
      出現以下:
      ┌──────────────────────────────────────────────────────────┐
      │ Do you wish to save your new kernel configuration? │
      ├──────────────────────────────────────────────────────────┤
      │ │
      └──────────────────────────────────────────────────────────┘
      選擇yes
      
      然後出現以下字樣:
      Saving your kernel configuration...
      
      *** End of Linux kernel configuration.
      *** Check the top-level Makefile for additional configuration.
      *** Next, you must run 'make dep'.
      
      2-1-2)編譯kernel
      #make dep
      #make clean
      #make bzImage
      #make modules
      #make modules_install
      
      2-1-3)cp新的kernel到啟動區
      #cp /home/src/kernel_update/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.4.18
      #mkinitrd /boot/initrd-2.4.18.img 2.4.18
      #vi /etc/lilo.conf
      在最後新增以下
      image=/boot/vmlinuz-2.4.18 <= kernel的路徑
      label=newkernel <= 啟動時的卷標
      initrd=/boot/initrd-2.4.18.img <= kernelimg的路徑
      read-only
      root=/dev/hda2 <= / 所在的區
      
      #/sbin/lilo -m /boot/map
      
      2-1-4)重新啟動server
      #reboot
      
      重新啟動進入時在redhat lilo的選擇介面選擇newkernel進入
      
      2-2)設定quota

      2-2-1)安裝quota。
      #cd /home/src
      #rpm -ivv quota-3.03-1.i386.rpm
      
      2-2-2)設定quota,以home為例
      #vi /etc/fstab
      把
      LABEL=/home /home ext3 defaults 1 2
      改成
      LABEL=/home /home ext3 defaults,usrquota,grpquota 1 2
      重啟server
      #/sbin/reboot
      
      2-2-3)設定使用者限定
      #quotacheck -uvg /home
      #edquota -u test
      Disk quotas for user chenc (uid 694):
      Filesystem blocks soft hard inodes soft hard
      /dev/hda5 6000 5000 6000 3 5000 6000
      在soft和hard下添上需要限制的磁碟大小(單位是K)
      
      #edquota -t
      Grace period before enforcing soft limits for users:
      Time units may be: days, hours, minutes, or seconds
      Filesystem Block grace period Inode grace period
      /dev/hda5 1minutes 1minutes
      設定soft quota和hard quota之間的時間。
      
      啟動quota
      #quotaon -av
      
      
      用test帳號用ftp進行測試,當test目錄達到了5M時,提示Disk quota exceeded。
  • 來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617542/viewspace-948723/,如需轉載,請註明出處,否則將追究法律責任。

    相關文章