一、系统配额
1 挂载设备 挂载参数
[root@localhost ~]# mkfs.xfs /dev/vdb1 先将硬盘格式化
meta-data=/dev/vdb1 isize=256 agcount=4, agsize=65536 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=262144, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# mount /dev/vdb1 /mnt/ 尝试能否挂载
[root@localhost ~]# umount /mnt/
[root@localhost ~]# vim /etc/fstab 编写开机自动启动文件
[root@localhost ~]# mount -o usrquota /dev/vdb1
vim内
#
# /etc/fstab
# Created by anaconda on Wed May 7 01:22:57 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9bf6b9f7-92ad-441b-848e-0257cbb883d1 / xfs defaults 1 1
/dev/vdb1 /mnt xfs defaults,usrquota
~
~
~
编辑配额
[student@localhost ~]$ edquota -u student
在编辑文本下
Disk quotas for user student (uid 1000):
Filesystem blocks soft hard inodes soft hard
/dev/vdb1 0 0 20480 0 0 0
真实容量 提示容量 最大容量
切换需要的用户
su - student
dd if=/dev/zero of=/mnt/studentfile bs=1M count=10 测试
du -sh /mnt/studentfile 查看大小
开机启动
二、
[root@localhost ~]# fdisk /dev/vdb ##首先用fdisk创建分盘
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 (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
Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# 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):
Using default response 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): 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): n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default 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): +100M
Partition 4 of type Extended 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: 0x1eb75ba4
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 821247 102400 5 Extended
Command (m for help): t 开始更改硬盘格式
Partition number (1-4, default 4): 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): t
Partition number (1-4, default 4): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): t
Partition number (1-4, default 4): 3
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
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: 0x1eb75ba4
Device Boot Start End Blocks Id System
/dev/vdb1 2048 206847 102400 8e Linux LVM
/dev/vdb2 206848 411647 102400 8e Linux LVM
/dev/vdb3 411648 616447 102400 8e Linux LVM
/dev/vdb4 616448 821247 102400 5 Extended
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe 同步分区
[root@localhost ~]# pvcreate /dev/vdb1
WARNING: xfs signature detected on /dev/vdb1 at offset 0. Wipe it? [y/n] y
Wiping xfs signature on /dev/vdb1.
Physical volume "/dev/vdb1" successfully created
[root@localhost ~]# vgcreat vg0 /dev/vdb1
bash: vgcreat: command not found...
[root@localhost ~]# vgcreate vg0 /dev/vdb1
Volume group "vg0" successfully created
[root@localhost ~]# lvcreate -L 300M -n lv0
Please provide a volume group name
Run `lvcreate --help' for more information.
[root@localhost ~]# lvcreate -L 50M -n lv0 vg0
Rounding up size to full physical extent 52.00 MiB
Logical volume "lv0" created
[root@localhost ~]# mkfs.xfs /dev/vg0/lv0 格式化
meta-data=/dev/vg0/lv0 isize=256 agcount=2, agsize=6656 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=13312, 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
[root@localhost ~]# mount /dev/vg0/lv0 /mnt/ 挂载
检查
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 5803876 4670024 56% /
devtmpfs 469344 0 469344 0% /dev
tmpfs 484932 140 484792 1% /dev/shm
tmpfs 484932 12836 472096 3% /run
tmpfs 484932 0 484932 0% /sys/fs/cgroup
/dev/mapper/vg0-lv0 49836 2756 47080 6% /mnt
三、拉伸
[root@localhost ~]# lvextend -L 70M /dev/vg0/lv0 @1处图片 拉伸设备
Rounding size to boundary between physical extents: 72.00 MiB
Extending logical volume lv0 to 72.00 MiB
Logical volume lv0 successfully resized
[root@localhost ~]# xfs_growfs /dev/vg0/lv0 拓展文件系统
meta-data=/dev/mapper/vg0-lv0 isize=256 agcount=2, agsize=6656 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=13312, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13312 to 18432
[root@localhost ~]# pvcreate /dev/vdb2 @2图片
Physical volume "/dev/vdb2" successfully created
[root@localhost ~]# vgextend vg0 /dev/vdb2
Volume group "vg0" successfully extended
[root@localhost ~]# lvextend -L 100M /dev/vg0/lv0
Extending logical volume lv0 to 100.00 MiB
Logical volume lv0 successfully resized
[root@localhost ~]# xfs_growfs /dev/vg0/v0
xfs_growfs: /dev/vg0/v0 is not a mounted XFS filesystem
[root@localhost ~]# xfs_growfs /dev/vg0/lv0
meta-data=/dev/mapper/vg0-lv0 isize=256 agcount=3, agsize=6656 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=18432, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 18432 to 25600
@1
@2
三、
[root@localhost ~]# umount /mnt/
[root@localhost ~]# mkfs.ext4 /dev/vg0/lv0
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25688 inodes, 102400 blocks
5120 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33685504
13 block groups
8192 blocks per group, 8192 fragments per group
1976 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@localhost ~]# mount /dev/vg0/lv0 /mnt/
[root@localhost ~]# mount
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=469344k,nr_inodes=117336,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel,size=484932k,nr_inodes=121233)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,size=484932k,nr_inodes=121233,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,seclabel,size=484932k,nr_inodes=121233,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/vda1 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=29,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
sunrpc on /proc/fs/nfsd type nfsd (rw,relatime)
gvfsd-fuse on /run/user/0/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/mapper/vg0-lv0 on /mnt type ext4 (rw,relatime,seclabel,data=ordered)
[root@localhost ~]# lvextend -L 140M /dev/vg0/lv0
Extending logical volume lv0 to 140.00 MiB
Logical volume lv0 successfully resized
[root@localhost ~]# resize2fs /dev/vg0/lv0
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vg0/lv0 is mounted on /mnt; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/vg0/lv0 is now 143360 blocks long.
文件的缩减
[root@localhost ~]# umount /mnt/
[root@localhost ~]# e2fsck -f /dev/vg0/lv0
e2fsck 1.42.9 (28-Dec-2013)
The filesystem size (according to the superblock) is 143360 blocks
The physical size of the device is 94208 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? yes
[root@localhost ~]# resize2fs /dev/v
vcs vcsa vda vdb1 vdb4 vga_arbiter
vcs1 vcsa1 vda1 vdb2 vfio/ vhost-net
vcs6 vcsa6 vdb vdb3 vg0/
[root@localhost ~]# resize2fs /dev/vg0/lv0 100M
resize2fs 1.42.9 (28-Dec-2013)
The containing partition (or device) is only 94208 (1k) blocks.
You requested a new size of 102400 blocks.
[root@localhost ~]# mount /dev/vg0/lv0 /mnt/
mount: wrong fs type, bad option, bad superblock on /dev/mapper/vg0-lv0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
[root@localhost ~]# lvreduce -L 80M /dev/vg0/lv0
WARNING: Reducing active logical volume to 80.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv0? [y/n]: y
Reducing logical volume lv0 to 80.00 MiB
Logical volume lv0 successfully resized
2.
[root@localhost ~]# pvmove /dev/vdb1 /dev/vdb2 将vdb1的数据迁移至vdb2中
/dev/vdb1: Moved: 20.0%
/dev/vdb1: Moved: 100.0%
[root@localhost ~]# vgreduce vg0 /dev/vdb1 将vg0中的vdb1移除
Removed "/dev/vdb1" from volume group "vg0"
[root@localhost ~]# pvremove /dev/vdb1 将pv中的vdb1移除
Labels on physical volume "/dev/vdb1" successfully wiped
3.
[root@localhost ~]# umount /mnt/ 解除挂载
[root@localhost ~]# lvremove /dev/vg0/lv0backup 删除lv0backup
Do you really want to remove active logical volume lv0backup? [y/n]: y
Logical volume "lv0backup" successfully removed
[root@localhost ~]# lvremove /dev/vg0/lv0 删除lv0
Do you really want to remove active logical volume lv0? [y/n]: y
Logical volume "lv0" successfully removed
[root@localhost ~]# lvremove /dev/vg0/ 删除vg0
One or more specified logical volume(s) not found.
[root@localhost ~]# vgremove /dev/vg0
Volume group "vg0" successfully removed
[root@localhost ~]# pvremove /dev/vdb2
Labels on physical volume "/dev/vdb2" successfully wiped