1. 程式人生 > >Linux系統中的系統分割槽管理

Linux系統中的系統分割槽管理


儲存是每個計算機系統的基本需求 .Red Hat Linux 提供了一些強大的工具 , 它們能在大量的場景中管理多種型別的儲存裝置

 

本地儲存裝置的區別

fdisk -l              #列出磁碟分割槽資訊,系統中真實存在的硬碟,但是不一定能夠識別
cat /proc/partitions  #系統識別也不一定能用
blkid                 #列出系統中可以使用的裝置id,能夠識別,也能夠使用的
df                    #檢視系統中正在使用的裝置資訊,系統正在掛載的裝置

fdisk -l        

    

cat /proc/partitions

blkid     

           

df                 
 
  

裝置的掛載和解除安裝

1.裝置名稱

/dev/xdx         ##/dev/hd0  /dev/hd1 /dev/sda  /dev/sdb  /dec/sda1  /dev/sda2
/dev/sr0         ##光碟機
/dev/mapper/*    ##虛擬裝置
/sda             ##系統第一塊串列埠硬碟,a代表第一塊
/cdrom,/dev/sr0 ##代表光碟機
/hd0             ##系統閉口硬碟

 

2.裝置的掛載

mount  裝置  掛載點            #掛載
umount /mnt                   #解除安裝掛載到/mnt下,可能會掛載到別的目錄下
umount /dev/sdb1              #解除安裝u盤掛載
注意:在/mnt/目錄下解除安裝不了

mount  -o ro /dev/sdb1   /mnt/                #只讀掛載
mount  -o  remount,rw  /dev/sdb1 | /mnt/      #重新讀寫掛載
mount    #檢視掛載資訊


注意:兩個裝置掛載到同一個目錄上,第二個會將第一個覆蓋,一般情況下不能掛載在同一個目錄下

3.解決裝置正忙的情況
解決方法1:

fuser -kvm /mnt
umount /mnt


解決方法2:

lsof /mnt/
kill -9  程序號
umount /mnt


 

磁碟分割槽

1.硬碟0磁軌1扇區的512個位元組中記錄的資訊如下:

512 = 446   +64   +2  位元組
      mbr   mot   55aa

mbr      主引導記錄
mpt      主分割槽標
55aa     硬碟有效標識

注意:
mpt   硬碟分割槽標   64位元組
一塊硬碟上最多可以劃分4個主分割槽,每個分五佔16個位元組,記錄分割槽
硬碟的分割槽:主分割槽、擴充套件分割槽、邏輯分割槽 

主分割槽;用主分割槽表記錄的分割槽
擴充套件分割槽:主分割槽表記錄的容器,不能直接使用
邏輯分割槽:容器中的分割槽

分割槽表記錄容器資訊,容器自己記錄容器分割槽
 
 
2.分割槽步驟
第一步:fdisk -l

[[email protected] Desktop]# fdisk -l

Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00013f3e

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    20970332    10484142+  83  Linux

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


第二步:fdisk /dev/ 進入分割槽介面

command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition                             ##刪除
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types                     ##查詢分割槽id
   m   print this menu                                ##查詢幫助
   n   add a new partition                            ##新建
   o   create a new empty DOS partition table
   p   print the partition table                      ##顯示分割槽
   q   quit without saving changes                    ##退出
   s   create a new empty Sun disklabel
   t   change a partition's system id                 ##修改分割槽id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit                    ##儲存分割槽標資訊到硬碟
   x   extra functionality (experts only)



第三步:建立主分割槽

[[email protected] Desktop]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x312c67f3.

Command (m for help): n                                          ##新建分割槽
Partition type:
   p   primary (0 primary, 0 extended, 4 free)                   ##主分割槽
   e   extended                                                  ##擴充套件分割槽
Select (default p):  
Using default response p                                         ##選擇預設
Partition number (1-4, default 1): 
First sector (2048-20971519, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +100M  ##100M
Partition 1 of type Linux and of size 100 MiB is set

Command (m for help): p                                         ##檢視分割槽

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux

Command (m for help): wq                                         ##儲存並退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


第四步:格式化分割槽  mkfs.xfs /dev/vdb1

[[email protected] Desktop]# mkfs.xfs /dev/vdb1
meta-data=/dev/vdb1              isize=256    agcount=4, agsize=6400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=25600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

檢視可用裝置,此時/dev/vdb1為可用裝置

[[email protected] Desktop]# blkid
/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs" 
/dev/vdb1: UUID="0168a321-bdd9-4ef5-b476-83de5ecd8b63" TYPE="xfs" 


第五步:掛載,裝置掛載之後才能使用
 

[[email protected] Desktop]# mount /dev/vdb1 /mnt/
[[email protected] Desktop]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       10473900 3165192   7308708  31% /
devtmpfs          469344       0    469344   0% /dev
tmpfs             484932     140    484792   1% /dev/shm
tmpfs             484932   12736    472196   3% /run
tmpfs             484932       0    484932   0% /sys/fs/cgroup
/dev/vdb1          98988    5280     93708   6% /mnt

 

[[email protected] Desktop]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n                                                ####繼續新增分割槽
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 
First sector (206848-20971519, default 206848): 
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-20971519, default 20971519): +100M
Partition 2 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux
/dev/vdb2          206848      411647      102400   83  Linux


Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 
First sector (411648-20971519, default 411648): 
Using default value 411648
Last sector, +sectors or +size{K,M,G} (411648-20971519, default 20971519): +100M
Partition 3 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux
/dev/vdb2          206848      411647      102400   83  Linux
/dev/vdb3          411648      616447      102400   83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e):                             ####當新增到第四個分割槽,預設分割槽為擴充套件分割槽e
Using default response e
Selected partition 4
First sector (616448-20971519, default 616448): 
Using default value 616448
Last sector, +sectors or +size{K,M,G} (616448-20971519, default 20971519): 
Using default value 20971519
Partition 4 of type Extended and of size 9.7 GiB is set

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux
/dev/vdb2          206848      411647      102400   83  Linux
/dev/vdb3          411648      616447      102400   83  Linux
/dev/vdb4          616448    20971519    10177536    5  Extended

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.

    
 注意:
1.若新增完成一個分割槽之後繼續新增,會出現warning ,此時可以手動同步分割槽partprobe 

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

手動同步分割槽標

[[email protected] Desktop]# partprobe
[[email protected] Desktop]# cat /proc/partitions 
major minor  #blocks  name

 253        0   10485760 vda
 253        1   10484142 vda1
 253       16   10485760 vdb
 253       17     102400 vdb1
 253       18     102400 vdb2
 253       19     102400 vdb3
 253       20          1 vdb4


2.當系統已經有三個主分割槽時,新增擴充套件分割槽
    新增擴充套件分割槽後,不能對擴充套件分割槽進行格式化,要對擴充套件分割槽中的邏輯分割槽進行格式化
 

[[email protected] Desktop]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (618496-20971519, default 618496): 
Using default value 618496
Last sector, +sectors or +size{K,M,G} (618496-20971519, default 20971519): +100M
Partition 5 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux
/dev/vdb2          206848      411647      102400   83  Linux
/dev/vdb3          411648      616447      102400   83  Linux
/dev/vdb4          616448    20971519    10177536    5  Extended        ##把剩下的空間全給擴充套件分割槽
/dev/vdb5          618496      823295      102400   83  Linux

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[[email protected] Desktop]# partprobe
[[email protected] Desktop]# cat /proc/partitions 
major minor  #blocks  name

 253        0   10485760 vda
 253        1   10484142 vda1
 253       16   10485760 vdb
 253       17     102400 vdb1
 253       18     102400 vdb2
 253       19     102400 vdb3
 253       20          1 vdb4
 253       21     102400 vdb5

[[email protected] Desktop]# mkfs.xfs /dev/vdb5
meta-data=/dev/vdb5              isize=256    agcount=4, agsize=6400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=25600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[[email protected] Desktop]# mount /dev/vdb5 /test/
[[email protected] Desktop]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       10473900 3165944   7307956  31% /
devtmpfs          469344       0    469344   0% /dev
tmpfs             484932     472    484460   1% /dev/shm
tmpfs             484932   12792    472140   3% /run
tmpfs             484932       0    484932   0% /sys/fs/cgroup
/dev/vdb1          98988    5280     93708   6% /mnt
/dev/vdb5          98988    5280     93708   6% /test


永久掛載:
vim /etc/fatab      開機自動掛載策略檔案
/dev/vdb5   /mnt  xfs  defaults              0    0  
 分割槽        掛載點 格式     掛載引數        是否備份 是否檢測
 
 


檔案系統比較


ext3 是rhel5及之前的版本,最多支援32TB的檔案系統和2T檔案,實際2TB檔案系統,16G檔案


ext4 是 Red Hat Enterprise Linux 6 的標準檔案系統。它非常強靠 ,具有多項可以提高現代工作量處理效能的功能,最多支援1EB的檔案系統和16T檔案


ext2 是常用於 Linux 中的較舊的檔案系統。它簡單可靠 , 非常適合小型儲存裝置 , 但是效率低於 ext4


vfat 支援包括一系列相關檔案系統 ( VFAT/FAT16 ,FAT32 ), 這些檔案系統針對較舊版本的 Microsoft Windows 開發 , 在大量的系統和裝置上受支援


xfs 在 Red Hat Enterprise Linux 7 的標準檔案系統其具備資料完全、效能穩定、擴充套件性強 ( 8eb-1byte ) 、傳輸速率高 ( 7G/s ),最多支援18EB的檔案系統和9E檔案  7G/s   4G/s
 
 


swap分割槽管理


換空間或交換區是磁碟驅動器上的空間 , 用作當前未使用部分記憶體的溢位。這樣 , 系統就能在主記憶體中留出空間用於儲存當前正在處理的資料 , 並在系統面臨主記憶體空間不足的風險時提供應急溢位


swap分割槽新建

第一步:使用 fdisk 建立新分割槽。此外 , 在用 fdisk 儲存更改之前 ,  將分割槽型別更改為 “ 0x82 Linux Swap”

[[email protected] Desktop]# swapon -s
[[email protected] Desktop]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux
/dev/vdb2          206848      411647      102400   83  Linux
/dev/vdb3          411648      616447      102400   83  Linux
/dev/vdb4          616448    20971519    10177536    5  Extended
/dev/vdb5          618496      823295      102400   83  Linux

Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (825344-20971519, default 825344): 
Using default value 825344
Last sector, +sectors or +size{K,M,G} (825344-20971519, default 20971519): +100M
Partition 6 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux
/dev/vdb2          206848      411647      102400   83  Linux
/dev/vdb3          411648      616447      102400   83  Linux
/dev/vdb4          616448    20971519    10177536    5  Extended
/dev/vdb5          618496      823295      102400   83  Linux
/dev/vdb6          825344     1030143      102400   83  Linux

Command (m for help): t                                       ####更改型別
Partition number (1-6, default 6): 6
Hex code (type L to list all codes): l

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs        
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT            
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor      
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary  
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS    
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE 
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep        
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT            
1e  Hidden W95 FAT1 80  Old Minix      
Hex code (type L to list all codes): 82                             ##改換分割槽
Changed type of partition 'Linux' to 'Linux swap / Solaris'

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux
/dev/vdb2          206848      411647      102400   83  Linux
/dev/vdb3          411648      616447      102400   83  Linux
/dev/vdb4          616448    20971519    10177536    5  Extended
/dev/vdb5          618496      823295      102400   83  Linux
/dev/vdb6          825344     1030143      102400   82  Linux swap / Solaris

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

第二步:準備好將分割槽用作交換區

[[email protected] Desktop]# mkswap /dev/vdb6
Setting up swapspace version 1, size = 102396 KiB
no label, UUID=bffb98b1-3b73-41e8-b132-18df4d95cd22


第三步:將新交換空間新增到 /etc/fstab

 
第四步:swapon -a 將啟用新交換區

[[email protected] Desktop]# swapon -a /dev/vdb6

swapon -s 將顯示當前交換區的狀態

 [[email protected] Desktop]# swapon -s
Filename                Type        Size    Used    Priority
/dev/vdb6                                  partition    102396    0    -1

 

swap分割槽刪除


第一步:編輯 /etc/fstab檔案,將檔案內容刪除
第二步:swapoff /dev/vdaN 將停用該特定交換區

[[email protected] Desktop]# swapoff /dev/vdb6

 第三步:fdisk  /dev/vdb,進入編輯介面,刪除裝置

[[email protected] Desktop]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d                                  ##刪除裝置
Partition number (1-6, default 6): 6
Partition 6 is deleted

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x312c67f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048      206847      102400   83  Linux
/dev/vdb2          206848      411647      102400   83  Linux
/dev/vdb3          411648      616447      102400   83  Linux
/dev/vdb4          616448    20971519    10177536    5  Extended
/dev/vdb5          618496      823295      102400   83  Linux

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

注意:刪除裝置之前程式要先停止,否則會出現錯誤,出現錯誤時,解掛載後,同步分割槽

第四步:同步分割槽標

partprobe

 

 

配額

1.什麼是quota

  簡單的說就是限制使用者對磁碟空間的使用量。

  因為Linux是多使用者多工的作業系統,許多人共用磁碟空間,為了合理的分配磁碟空間,於是就有了quota的出現。

 

2.quota的用途
    顯示磁碟使用情況和配額

 

3.quota的一般作用物件
    (1)針對WWW server
    (2)針對mail server
    (3)針對file server
 

4.quota的限制
    (1)僅能針對整個檔案系統
    (2)需要kernel的支援
    (3)只對一般使用者有效

 

5.如何設定配額的限額???

第一步:開啟quota功能

mount -o usrquota /dev/vdb5  /westos 
chmod  777 /westos

第二步:設定student使用者對磁碟/dev/vdb5的配額,使用edquota -u student命令編輯檔案

filesystem blocks    soft  hard   inodes   soft   hard
  1         2         3     4      5        6      7
1:檔案系統,說明該限制值時針對哪個檔案系統
2:磁碟容量,這個值時quota自己算出來的,不要更改
3:磁碟容量的soft限制值
4:磁碟容量的hard限制值
5:檔案數量,quota自己算出來的,不要改動
6:inode的soft值
7:inode的hard值

soft/hard為0時,表示沒有限制,我們需要的是設定blocks的soft/hard值,inode的不要更改

 

如何讓配額自動掛載,需要編輯/etc/fstab檔案??
vim /etc/fstab
/dev/vdb5  /pub  xfs   defauits,usrquota  0  0
 
 
測試:切換到student使用者進行測試