리눅스

 

 

 

 

#fdisk /dev/sdb

n => p =>1 =>엔터=>엔터 =>p =>w

 

< 포멧>

# mkfs.ext4    /dev/sdb1


# mkdir  /userHome
# mount /dev/sdb1    /userHome/

# vi /etc/fstab


/dev/sdb1     /userHome  ext4  defaults    1 2


<사용자 지정>

[root@localhost ~]# useradd -d  /userHome/john john
[root@localhost ~]# useradd -d  /userHome/bann bann

[root@localhost ~]# ls -l /userHome/
합계 24
drwx------ 3 bann bann  4096  3월 30 18:50 bann
drwx------ 3 john john  4096  3월 30 18:50 john
drwx------ 2 root root 16384  3월 30 18:47 lost+found

 

 

<사용자 비밀번호 지정>


[root@localhost ~]# passwd john
john 사용자의 비밀 번호 변경 중
새  암호:1111
잘못된 암호: 암호가 앞뒤 어느쪽에서 읽어도 같은 문맥임
새  암호 재입력:1111
passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.

[root@localhost ~]# passwd bann
bann 사용자의 비밀 번호 변경 중
새  암호:1111
잘못된 암호: 암호가 앞뒤 어느쪽에서 읽어도 같은 문맥임
새  암호 재입력:1111
passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.
[root@localhost ~]# 

 

 

<사용자별로 용량을 제한 >


/dev/sdb1  /userHome    ext4  defaults,usrjquota=aquota.user,jqfmt=vfsv0      1 2

 


< userHome 만 재 마운트  리부팅 효과>

[root@localhost ~]# mount --options remount /userHome

 

마우트 확인

[root@localhost ~]# mount

/dev/sdb1 on /userHome type ext4 (rw,relatime,data=ordered,jqfmt=vfsv0,usrjquota=aquota.user)

 


<쿼터 생성>

[root@localhost ~]# cd /userHome/
[root@localhost userHome]# quotaoff -avug
/dev/sdb1 [/userHome]: user quotas turned off

[root@localhost userHome]# quotacheck  -augmn
[root@localhost userHome]# rm -rf aquota.*
[root@localhost userHome]# quotacheck -augmn
[root@localhost userHome]# touch aquota.user aquota.group
[root@localhost userHome]# chmod 600 aquota.*
[root@localhost userHome]# quotacheck -augmn
[root@localhost userHome]# quotaon -avug
/dev/sdb1 [/userHome]: user quotas turned on
[root@localhost userHome]# ls -l
합계 32
-rw------- 1 root root     0  3월 30 19:09 aquota.group
-rw------- 1 root root  7168  3월 30 19:10 aquota.user
drwx------ 3 bann bann  4096  3월 30 18:50 bann
drwx------ 3 john john  4096  3월 30 18:50 john
drwx------ 2 root root 16384  3월 30 18:47 lost+found
[root@localhost userHome]#


< 사용자마자 용량을 지정 >

[root@localhost userHome]# edquota -u john

 
Disk quotas for user john (uid 1001):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/sdb1                        28       10240      15360          7        0        0

 


확인 테스트

[root@localhost userHome]# su - john


[john@localhost ~]$ cp /boot/vmlinuz-3.10.0-514.el7.x86_64  test1
[john@localhost ~]$ ls -l
합계 5268
-rwxr-xr-x 1 john john 5392080  3월 30 19:18 test1
[john@localhost ~]$ cp test1 test2
sdb1: warning, user block quota exceeded.
[john@localhost ~]$ lst -l
bash: lst: 명령을 찾을 수 없습니다...
[john@localhost ~]$ ls -l
합계 10536
-rwxr-xr-x 1 john john 5392080  3월 30 19:18 test1
-rwxr-xr-x 1 john john 5392080  3월 30 19:18 test2
[john@localhost ~]$ cp test1 test4
sdb1: write failed, user block limit reached.
cp: `test4'에 쓰는 도중 오류 발생: 디스크 할당량이 초과됨
cp: failed to extend `test4': 디스크 할당량이 초과됨
[john@localhost ~]$ ls -l
합계 15312
-rwxr-xr-x 1 john john 5392080  3월 30 19:18 test1
-rwxr-xr-x 1 john john 5392080  3월 30 19:18 test2
-rwxr-xr-x 1 john john 4890624  3월 30 19:19 test4

 


<자신의 할당량 확인>


[john@localhost ~]$ quota
Disk quotas for user john (uid 1001): 
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
      /dev/sdb1   15360*  10240   15360   6days      15       0       0 

[john@localhost ~]$ exit;
logout
[root@localhost userHome]# repquota /userHome/
*** Report for user quotas on device /dev/sdb1
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --      20       0       0              3     0     0       
john      +-   15360   10240   15360  6days      16     0     0       
bann      --      28       0       0              7     0     0       


[root@localhost userHome]# 


[root@localhost userHome]# edquota -p john bann

[root@localhost userHome]# edquota -p john bann
[root@localhost userHome]# repquota /userHome
*** Report for user quotas on device /dev/sdb1
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --      20       0       0              3     0     0       
john      +-   15360   10240   15360  6days      16     0     0       
bann      --      28   10240   15360              7     0     0  


 

 

 

 

 

 

 

 

 

about author

PHRASE

Level 60  머나먼나라

꿈을 계속 간직하고 있으면 반드시 실현할 때가 온다. -괴테

댓글 ( 4)

댓글 남기기

작성
  •    
  •    
  •