Linux Quota 備忘

来源:百度文库 编辑:神马文学网 时间:2024/04/19 05:57:15
Linux Quota 備忘
目的: 建立虛擬檔案系統 (Virtual Filesystem) 練習 quota 配置與相關指令
環境:
SuSE Linux 10.0 quota-3.13-2
建立虛擬檔案系統
使用記憶體建立 8MB 虛擬檔案系統
mkfs -t ext2 /dev/ram0 8192
ps. 若要建立多個 Ramdisk, 重覆上列指令, 目標為 /dev/ram1, /dev/ram2... 即可
掛載 Virtual Filesystem
mkdir /mnt/ram0
mount -t ext2 -o usrquota,grpquota /dev/ram0 /mnt/ram0
chmod 1777 /mnt/ram0
使用硬碟空間建立 10MB 虛擬檔案系統
dd if=/dev/zero of=/opt/virtual_filesystem.img bs=1024K count=10
mkfs -t ext2 /opt/virtual_filesystem.img
掛載 Virtual Filesystem
mkdir /mnt/loop0
mount -t ext2 -o loop,usrquota,grpquota \
/opt/virtual_filesystem.img /mnt/loop0
chmod 1777 /mnt/loop0
ps. 只掛載一個 Virtual Filesystem 時, device name 為 /dev/loop0; 若同時掛載多個 Virtual Filesystem, device name 依序為 /dev/loop1, /dev/loop2...
第一次執行 quotacheck: 建立 quota files
quotacheck -avug
結果: 在 /mnt/loop0 產生 aquota.group 與 aquota.user
設定 quota (for testing)
edquota -u someone
Disk quotas for user someone (uid xxxx):
Filesystem    blocks    soft    hard    inodes    soft    hard
/dev/loop0 0 0 0 0 3 5
blocks:
1. 1 block 等於 1KB; 1024 blocks 即 1MB
2. 設置為 0 表示 quota 不設限 (unlimited)
inodes:
soft=3 inode 數量超過 3 即發出警告, 在期限(以 edquota -t 設定)內需自行將 inodes 降至 3 以下, 否則將不允許再增加 inode
hard=5 inode 數量不得超過 5
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/loop0 7days 7days
以上設置亦可使用 setquota 指令完成:
setquota -u someone 0 0 3 5 /dev/loop0
setquota -t 604800 604800 /dev/loop0
ps. 604800 為 7 天的秒數. 一小時=3600秒, 一天=86400秒
啟用/停用 quota 設置
啟用: quotaon -aug
停用: quotaoff -aug
測試一: 產生數個檔案, 直到觸發 inodes:hard 限制
su - someone
cd /mnt/loop0
touch file_1
touch file_2
touch file_3
touch file_4
loop0: warning, user file quota exceeded.
touch file_5
touch file_6
loop0: write failed, user file limit reached.
touch: cannot touch `file_6‘: No space left on device
測試二: 觸發 inodes:soft 限制, 並等候 Inode grace period 期限屆滿
edquota -t
Inode grace period → 10seconds
su - someone
cd /mnt/loop0
touch a b c d
loop0: warning, user file quota exceeded.
... 10 seconds later ...
touch e
loop0: write failed, user file quota exceeded too long.
touch: cannot touch `e‘: No space left on device
檢視 quota 報告
quota: display user‘s disk usage and limits.
quota -vu someone
repquota: prints a summary of the disc usage and quotas for the specified file system
repquota -avug
設定開機自動掛載 Virtual Filesystem, 並啟用 quota
vi /etc/fstab
/opt/virtual_filesystem.img   /mnt/loop0   ext2   defaults,loop,usrquota,grpquota   0 0
vi /etc/init.d/boot.local (same as /etc/rc.d/rc.local in Red Hat Linux)
/sbin/quotaon -a
排程 Quota 檢查 / e-mail 通知
vi /etc/warnquota.conf
#註解底下這行
#FAIL = "configure /etc/warnquota.conf before running warnquota"
vi /etc/quotatab
#替 Quota Device 寫上註解
/dev/loop0: This is a test.
vi /etc/crontab
#排程每日凌晨三點執行 quota 檢查, 若超過 soft limit 或已達 hard limit 即發送 e-mail 通知
0 3 * * * root /usr/sbin/warnquota > /dev/null 2>&1
其他備忘
quotastats - program to query quota statistics rpc.rquotad - remote quota server
在 server 端啟用 quota 並以 NFS 分享 quota filesystem 時, 於 server 端執行 rpc.rquotad 可讓 NFS client 以 quota 指令查詢 quota 狀況
參考資料:
鳥哥的 Linux 私房菜 - Linux 磁碟配額 (Quota)
Posted by Jamyy at 2006年09月19日 10:41
Trackback Pings
TrackBack URL for this entry:
http://cha.homeip.net/cgi-bin/mt/mt-tb.cgi/228
Comments
hey
ettercap ng 如果arp spoof之后
如果用命令停止?
ettercap -mitm ??
Posted by: aldds at 2006年09月20日 23:40
Text Mode:
sudo ettercap -i eth0 -T -M arp:remote /gw.ip.addr/ /target.ip.addr-range/
按 q 結束程序即自動 stop mitm attack (target hosts 的 arp table 恢復正常)
GUI Mode:
sudo ettercap -i eth0 -G -n 255.255.255.0
Sniff → Unified sniffing (Shift + U)
Hosts → Scan for hosts (Ctrl + S)
Targets → Select TARGET(s) (Ctrl + T)
Target 1: /gw.ip.addr/
Target 2: /target.ip.addr-range/
(// & // for any)
Mitm → Arp poisoning
Start → Start sniffing (Ctrl + W)
此時若直接關閉 ettercap 視窗, 將造成持續的 arp 欺騙
導致 target hosts 網路異常
正確的結束方式為:
Mitm → Stop mitm attack(s)
Start → Exit (Ctrl + X)
如果已經造成持續的 arp 欺騙,
最簡單的解決方法就是執行 Text Mode, 對同個目標再 "欺騙" 一次
離開後 target hosts 的 arp table 即自動恢復正常
Ref:
ettercap on-line man page:
http://www.penguin-soft.com/penguin/man/8/ettercap.html
網路監聽 vs. 反監聽
http://cha.homeip.net/blog/archives/2006/05/_vs.html
Posted by: Jamyy at 2006年09月21日 09:53
哦,谢谢,可以知道你其他的联系方式吗?
比如msn or skype or icq? :D
Posted by: aldds at 2006年09月21日 11:04
e-mail 可以嗎? (因為我沒在用 IM 軟體)
jamyychang 小老鼠 gmail 點 com :)
Posted by: Jamyy at 2006年09月21日 14:47
from: http://cha.homeip.net/blog/archives/2006/09/linux_quota.html#more