多用戶磁盤管理 - lvm + quota

思路: 用lvm來生成 /home的virtual卷標,這樣新加的磁盤能比較方便併入/home virtual卷標,quota對/home目錄下各用戶進行空間quota管理php

 

方法:node

LVM2linux

http://ubuntuforums.org/showthread.php?t=1782296ubuntu

 

 

 

sudo apt-get -y install lvm2app

 

 

sudo fdisk /dev/sdaide

ubuntu@ubuntu:~$ sudo fdisk /dev/sdasvg

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelui

Building a new DOS disklabel with disk identifier 0x568311d6.spa

Changes will remain in memory only, until you decide to write them.code

After that, of course, the previous content won't be recoverable.

 

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-5221, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-5221, default 5221): +1G

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (133-5221, default 133):

Using default value 133

Last cylinder, +cylinders or +size{K,M,G} (133-5221, default 5221):

Using default value 5221

 

Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): 8e

 

Changed system type of partition 2 to 8e (Linux LVM)

 

Command (m for help): p

 

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track, 5221 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x568311d6

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1               1         132     1060258+  83  Linux

/dev/sda2             133        5221    40877392+  8e  Linux LVM

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

5. pvcreate, vgcreate, lvcreate, mkfs

 

sudo pvcreate /dev/sda2

sudo vgcreate sysvg /dev/sda2

sudo lvcreate -L 1G -n lvswap sysvg

sudo lvcreate -L 20G -n lvroot sysvg

sudo lvcreate -l 100%FREE -n lvhome sysvg

 

 

  1. fdisk來分區須要 /boot,  / swap,和 /home

/boot - 20G, Linux

/ - 100G, linux

Swap partition - 64G, linux

/home - Linux LVM

 

Sudo pvcreate /dev/sda4 /dev/sdb1 /dev/sdc1

Sudo vgcreate vghome /dev/sda4 /dev/sdb1 /dev/sdc1

Sudo lvcreate -l 100%FREE -n lvhome vghome

Sudo mkfs.ext4 /dev/sda1 …..

Sudo mkswap -f /dev/sda2 …..

 

  1. Install ubuntu

Need to mount /, /boot, /home and swap area

 

  1. Install lvm2 again

Sudo mount /dev/sda1 /mnt

Sudo mount /dev/mapper/vghome-lvhome /mnt/home

Sudo mount /dev/sda1 /mnt/boot

Sudo chroot /mnt

Apt-get install lvm2

 

  1. Reboot and Install quota

Sudo apt-get install quota

這是個人。。只要在defaults後面加個usrquota就好了

/dev/sda1       /               ext3    defaults,usrquota        1       1

 

  1. reboot

 

  1. edquota 用戶名, Disk quotas for user 用戶名 (uid *****):

Filesystem                   blocks       soft       hard     inodes     soft     hard

/dev/sda1                      數字        0           0       數字        0         0

兩個數字咱們不須要改動,咱們只要對付「前兩個」soft hard 就好了。單位是KBsoft 應該比 hard 的值稍微小些,實際的分配空間以hard 值爲主。

相關文章
相關標籤/搜索