2012/01/04

1   添加4块硬盘
2   分区硬盘
 fdisk /dev/sdb-->n-->p-->1-->enter-->enter-->t-->8e-->w
     其它硬盘同上
3 更新分区表
 partprobe
4 创建raid
 [root@localhost ~]# mdadm --create --auto=yes /dev/md10 --level=10 --raid-devices=3 --spare-devices=1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: array /dev/md10 started.
 mdadm --detail /dev/md10
 vim /etc/mdadm.conf
 ARRAY   /dev/md10 UUID= 5f8e23d6:7ac3908d:d1e3d77b:6abfe5b4

 
5 创建PV
 [root@localhost ~]# pvcreate /dev/md10
  Physical volume "/dev/md10" successfully created
6 创建VG
 [root@localhost ~]# vgcreate vg /dev/md10
 Volume group "vg" successfully created
7 创建LV
 [root@localhost ~]# lvcreate -L 15G -n lv /dev/vg
  Logical volume "lv" created
8 格式化LVM
 mkfs.ext3 /dev/vg/lv
9 开机启动逻辑卷
 vim /etc/fstab
 /dev/vg/lv              /media                  ext3                  defaults,usrquota,grpquota 0 0
10 挂载lvm
 mount -a
 /dev/mapper/vg-lv on /media type ext3 (rw,usrquota,grpquota)
11 创建配额文件
 quotacheck -augv
 [root@localhost ~]# ls /media/
 aquota.group  aquota.user  lost+found
12 创建用户
 vim useradd.sh
 #!/bin/bash
 for abc in abc1 abc2 abc3 abc4 abc5
 do
 useradd $abc
 echo "123456" | passwd --stdin $abc
 done
      
 . useradd.sh
13 配置用户配额
  edquota -u abc1
Disk quotas for user abc1 (uid 500):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/mapper/vg-lv                 0      100000      150000     0           0      0
[root@localhost ~]# edquota -p abc1 -u abc2
[root@localhost ~]# edquota -p abc1 -u abc3
[root@localhost ~]# edquota -p abc1 -u abc4
[root@localhost ~]# edquota -p abc1 -u abc5
 
14 开启配额
 quotaon -a
15 给用户有写入的权限
 chmod o+w /media/
16 切换用户
 su - abc1
17  进入到/media目录下
 [abc1@localhost ~]$ cd /media/
18 复制文件查看手否超出(软限制)配额
 [abc1@localhost media]$ dd if=/dev/zero of=abc1.txt bs=1M count=110
dm-0: warning, user block quota exceeded.
110+0 records in
110+0 records out
115343360 bytes (115 MB) copied, 0.922741 seconds, 125 MB/s
19 验证用户是否能超出硬限制
 [abc1@localhost media]$ dd if=/dev/zero of=abc2.txt bs=1M count=100
dm-0: write failed, user block limit reached.
dd: 写入 “abc2.txt”: 超出磁盘限额
37+0 records in
36+0 records out
38092800 bytes (38 MB) copied, 0.162712 seconds, 234 MB/s


 


 

 

 

 


 
 

你可能感兴趣的:(lvm)