zoukankan      html  css  js  c++  java
  • 多用户磁盘管理

    思路: 用lvm来生成 /home的virtual卷标,这样新加的磁盘能比较方便并入/home virtual卷标,quota对/home目录下各用户进行空间quota管理

    方法:

    LVM2

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

     

     

    sudo apt-get -y install lvm2

     

     

    sudo fdisk /dev/sda

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

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

    Building a new DOS disklabel with disk identifier 0x568311d6.

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

    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 值为主。

  • 相关阅读:
    成长篇之代码灵异事件
    idea快捷键
    java环境配置常用链接
    MySQL分区
    English 动词篇
    仿stl+函数模板
    java 数组复制
    拓扑排序(Topological Sorting)
    2017蓝桥杯第十题(k倍区间)
    翻译NYOJ
  • 原文地址:https://www.cnblogs.com/venusSolar/p/3681017.html
Copyright © 2011-2022 走看看