Linux操作系统内核由6个部分组成:
操作系统中负责管理和存储文件信息的软件机构称为文件管理系统,简称文件系统。
从系统角度来看,文件系统是对文件存储设备的空间进行组织和分配,负责文件存储并对存入的文件进行保护和检索的系统。
具体地说,它负责为用户建立文件,存入、读出、修改、转储文件,控制文件的存取,当用户不再使用时撤销文件等。
查看系统支持的文件系统
ls /lib/modules/$(uname -r)/kernel/fs
系统目前已加载到内存中支持的文件系统
more /proc/filesystems
索引式文件系统(indexed allocation)
文件系统内的信息主要有:
rhel6
[root@rhel6 ~]# mkfs
mkfs 2 4 mkfs.msdos
amfs 3 4dev mkfs.vfat
rhel7
[root@rhel7 ~]# mkfs
mkfs amfs 3 mkfs.fat mkfs.msdos mkfs.xfs
mkfs.btrfs 2 4 mkfs.minix mkfs.vfat
EXT4 Linux kernel 自 2.6.28 开始正式支持新的文件系统 Ext4。Ext4 是 Ext3 的改进版,修改了 Ext3 中部分重要的数据结构,而不仅仅像 Ext3 对 Ext2 那样,只是增加了一个日志功能而已。Ext4 可以提供更佳的性能和可靠性,还有更为丰富的功能,不向下兼容ext3。
XFS 针对海量小文件的存储及超大文件的存储有一些有时,但 EXT 系统相对稳定。XFS 是 Silicon Graphics,Inc. 于 90 年代初开发的文件系统。它至今仍作为 SGI 基于 IRIX 的产品(从工作站到超级计算机)的底层文件系统来使用。现在,XFS 也可以用于 Linux。XFS 的 Linux 版的到来是激动人心的,首先因为它为 Linux 社区提供了一种健壮的、优秀的以及功能丰富的文件系统,并且这种文件系统所具有的可伸缩性能够满足最苛刻的存储需求。
实例:
[#3#root@rhel6 ~]#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_rhel6-LogVol01 17G 3.0G 13G 19% /
tmpfs 499M 72K 499M 1% /dev/shm
/dev/vda1 477M 58M 390M 13% /boot
/dev/mapper/vg_rhel6-LogVol00 380M 2.3M 354M 1% /home
[#4#root@rhel6 ~]#df -a
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_rhel6-LogVol01 17535796 3127044 13494936 19% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
tmpfs 510368 72 510296 1% /dev/shm
/dev/vda1 487652 58631 399325 13% /boot
/dev/mapper/vg_rhel6-LogVol00 388480 2335 361569 1% /home
none 0 0 0 - /proc/sys/fs/binfmt_misc
实例:
[#9#root@rhel6 ~]#du -s /var/
140252 /var/
[#10#root@rhel6 ~]#du -sh /var/
137M /var/
[#16#root@rhel6 ~]#du -h /tmp
8.0K /tmp/pulse-oCBy0hGD1JT6
4.0K /tmp/.X11-unix
4.0K /tmp/.esd-0
4.0K /tmp/virtual-root.JyC7Qb
8.0K /tmp/orbit-gdm
4.0K /tmp/.ICE-unix
8.0K /tmp/pulse-q5sECpImz7Ju
48K /tmp
[#15#root@rhel6 ~]#du -ha /tmp
4.0K /tmp/pulse-oCBy0hGD1JT6/pid
0 /tmp/pulse-oCBy0hGD1JT6/native
8.0K /tmp/pulse-oCBy0hGD1JT6
0 /tmp/.X11-unix/X0
4.0K /tmp/.X11-unix
0 /tmp/.esd-0/socket
4.0K /tmp/.esd-0
4.0K /tmp/virtual-root.JyC7Qb
4.0K /tmp/.X0-lock
0 /tmp/orbit-gdm/linc-6c2-0-7846478690c68
0 /tmp/orbit-gdm/bonobo-activation-register-75c59b1ecf3edd6ad04cfcfd00000056.lock
4.0K /tmp/orbit-gdm/bonobo-activation-server-75c59b1ecf3edd6ad04cfcfd00000056-ior
0 /tmp/orbit-gdm/linc-6e5-0-3bda60586d2f0
0 /tmp/orbit-gdm/linc-6bb-0-2bf2fd0bb015c
0 /tmp/orbit-gdm/linc-6e1-0-44f3459db98f9
0 /tmp/orbit-gdm/linc-6d9-0-26db8cdee8dec
0 /tmp/orbit-gdm/linc-6e0-0-7f7b8d4664593
0 /tmp/orbit-gdm/linc-6e4-0-540f978681aee
0 /tmp/orbit-gdm/linc-6d4-0-3a04cbe9566
0 /tmp/orbit-gdm/linc-6d5-0-75caf0f81ab48
8.0K /tmp/orbit-gdm
0 /tmp/.ICE-unix/1723
4.0K /tmp/.ICE-unix
4.0K /tmp/pulse-q5sECpImz7Ju/pid
0 /tmp/pulse-q5sECpImz7Ju/native
8.0K /tmp/pulse-q5sECpImz7Ju
48K /tmp
新增一颗硬盘时 , 该怎么做 :
fdisk命令用于观察硬盘实体使用情况,也可对硬盘分区。它采用传统的问答式界面。
语法 fdisk(选项)(参数)
选项
参数 设备文件:指定要进行分区或者显示分区的硬盘设备文件。
[#20#root@rhel6 ~]#fdisk -lDisk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d166bDevice Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 5179 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/vda3 5179 41611 18361344 8e Linux LVM
Partition 3 does not end on cylinder boundary.Disk /dev/vdb: 10.7 GB, 10737418240 bytes
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000Disk /dev/mapper/vg_rhel6-LogVol01: 18.4 GB, 18379440128 bytes
255 heads, 63 sectors/track, 2234 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: 0x00000000Disk /dev/mapper/vg_rhel6-LogVol00: 419 MB, 419430400 bytes
255 heads, 63 sectors/track, 50 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: 0x00000000
[#21#root@rhel6 ~]#fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x23c41712.
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 toswitch off the mode (command 'c') and change display units tosectors (command 'u').Command (m for help): m <== 输入 m 后 , 就会看到底下这些指令介绍
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition <== 删除一个分区
l list known partition types
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<== 不储存离开 fdisk 程序
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit<== 将刚刚的动作写入分割表
x extra functionality (experts only)
Command (m for help): pDisk /dev/vdb: 10.7 GB, 10737418240 bytes
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x23c41712Device Boot Start End Blocks Id SystemCommand (m for help): n
Command actione extendedp primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-20805, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-20805, default 20805):
Using default value 20805Command (m for help): pDisk /dev/vdb: 10.7 GB, 10737418240 bytes
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x23c41712Device Boot Start End Blocks Id System
/dev/vdb1 1 20805 10485688+ 83 LinuxCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
[#22#root@rhel6 ~]#ls /dev|grep vdb
vdb
vdb1
[root@rhel7 ~]# 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 0x8366bb08.Command (m for help): pDisk /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: 0x8366bb08Device Boot Start End Blocks Id SystemCommand (m for help): n
Partition type:p primary (0 primary, 0 extended, 4 free)e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):
Using default value 20971519
Partition 1 of type Linux and of size 10 GiB is setCommand (m for help): pDisk /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: 0x8366bb08Device Boot Start End Blocks Id System
/dev/vdb1 2048 20971519 10484736 83 LinuxCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
[#23#root@rhel6 ~]#mkfs
mkfs amfs 2 3 4 4dev mkfs.msdos mkfs.vfat
[#24#root@rhel6 ~]#4 /dev/vdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621422 blocks
131071 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@rhel7 ~]# mkfs
mkfs amfs 3 mkfs.fat mkfs.msdos mkfs.xfs
mkfs.btrfs 2 4 mkfs.minix mkfs.vfat
[root@rhel7 ~]# mkfs.xfs /dev/vdb1
meta-data=/dev/vdb1 isize=256 agcount=4, agsize=655296 blks= sectsz=512 attr=2, projid32bit=1= crc=0
data = bsize=4096 blocks=2621184, 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
/etc/fstab
/etc/filesystems: 系统指定的测试挂载文件系统类型 ;
/proc/filesystems:Linux 系统已经加载的文件系统类型。
标准用法 mount -t ext4 /dev/vdb1 /mnt/vdb1
远程挂载 mount ip:/xx /xx
mount 172.25.254.250 : /content /mnt
<== 远程挂载案例
其他选项:
A.-o loop 挂载镜像文件
B.-o ro 以只读方式挂载
C.-o remount 重新挂载
用法: mount -o remount 被挂载的设备 挂载点
例如: mount -o remount,rw,auto / <== 重新挂载根目录
mount -o remount,ro newdir <== 重新挂载为只读
D.-t iso9660 挂载CD/DVD
df -h
mount <== 查看设备和目录挂载点的关系
[#27#root@rhel6 ~]#mount
/dev/mapper/vg_rhel6-LogVol01 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/vda1 on /boot type ext4 (rw)
/dev/mapper/vg_rhel6-LogVol00 on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
umount [-fn] 设备文件名与挂载点
umount /mnt
注意事项:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SDgxG3iK-1616288135095)(pic/26.png)]
是否需要检测:非 0 代表检测,数字越小优先级越高
修改后保存,通过 mount -a
让配置生效
如前面介绍章节讲到的类 Unix 系统最初设计理念就让许多人一起使用,多任务的操作系统,但是硬件的资源是固定有限 的,如果出现个小破坏份子不断的创建文件或下载电影,那么硬盘空间总有一天会被占满的吧,这时就需要 quota服务 帮助我们为每个用户限制可以使用的硬盘空间,一旦超出预算就不再允许他们使用。
quota 的磁盘配额可以限制用户的硬盘可用空间或最大创建文件数量,并且还有软/硬限制的区别:
quotacheck命令通过扫描指定的文件系统,获取磁盘的使用情况,创建、检查和修复磁盘配额(quota)文件。执行quotacheck指令,扫描挂入系统的分区,并在各分区的文件系统根目录下产生quota.user和up文件,设置用户和群组的磁盘空间限制。
语法 quotacheck(选项)(参数)
选项
参数 文件系统:指定要扫描的文件系统。
quota命令用于显示用户或者工作组的磁盘配额信息。输出信息包括磁盘使用和配额限制。
语法 quota(选项)(参数)
选项
参数 用户或者工作组:指定要显示的用户或者工作组。
quotaon命令用于激活Linux内核中指定文件系统的磁盘配额功能。
语法 quotaon(选项)(参数)
选项
参数 文件系统:指定要激活磁盘配额功能的文件系统。
repquota命令以报表的格式输出指定分区,或者文件系统的磁盘配额信息。
语法 repquota(选项)(参数)
选项
参数 文件系统:要打印报表的文件系统或者对应的设备文件名。
edquota 命令用于超级用户编辑其他用户的 quota 配额限制
格式为: “ edquota [参数] [用户]”。
参数 作用
xfs_quota 命令用于管理 XFS 文件系统的 quota 硬盘配额
格式为: “ quota [参数] 配额 文件系统 ” 。
参数 作用
划分分区/dev/vdb2,格式化成ext4文件系统,并挂载在student家目录下使用,限制磁盘软限制为 3M、磁盘硬限制为 6M、文件软限制为 20 个且文件硬限制为 30 个
[root@rhel6 ~]# mount -o usrquota,grpquota /dev/vdb2 /home/student
[root@rhel6 ~]# ll /home/student
total 16
drwx------. 2 root root 16384 Jul 1 15:56 lost+found
[root@rhel6 ~]# cd /etc/skel
[root@rhel6 skel]# cp .bash* .gnome* .moz* -r /home/student
[root@rhel6 skel]# ll /home/student -a
total 42
drwxr-xr-x. 5 root root 4096 Jul 1 16:00 .
drwxr-xr-x. 4 root root 1024 Jul 2 2015 ..
-rw-r--r--. 1 root root 18 Jul 1 16:00 .bash_logout
-rw-r--r--. 1 root root 176 Jul 1 16:00 .bash_profile
-rw-r--r--. 1 root root 124 Jul 1 16:00 .bashrc
drwxr-xr-x. 2 root root 4096 Jul 1 16:00 .gnome2
drwx------. 2 root root 16384 Jul 1 15:56 lost+found
drwxr-xr-x. 4 root root 4096 Jul 1 16:00 .mozilla
[root@rhel6 skel]# chown student. /home/student -R
[root@rhel6 skel]# setenforce 0
[root@rhel6 skel]# quotacheck -cugm /home/student
[root@rhel6 skel]# ll /home/student
total 32
-rw-------. 1 root root 6144 Jul 1 16:up
-rw-------. 1 root root 6144 Jul 1 16:03 aquota.user
drwx------. 2 student student 16384 Jul 1 15:56 lost+found
[root@rhel6 skel]# quotaon /home/student
[root@rhel6 skel]# repquota /home/student
*** Report for user quotas on device /dev/vdb2
Block grace time: 7days; Inode grace time: 7daysBlock limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
student -- 48 0 0 9 0 0 [root@rhel6 skel]# edquota student
edquota: WARNING - /dev/vdb2: cannot change current inode allocation
[root@rhel6 skel]# edquota student
[root@rhel6 skel]# repquota /home/student
*** Report for user quotas on device /dev/vdb2
Block grace time: 7days; Inode grace time: 7daysBlock limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
student -+ 48 3072 6144 9 3 6 7days[root@rhel6 skel]# quota student
Disk quotas for user student (uid 500):Filesystem blocks quota limit grace files quota limit grace/dev/vdb2 48 3072 6144 9* 3 6 7days
[root@rhel6 skel]# su - student
[student@rhel6 ~]$ touch file{1..10}
vdb2: write failed, user file limit reached.
touch: cannot touch `file1': Disk quota exceeded
touch: cannot touch `file2': Disk quota exceeded
touch: cannot touch `file3': Disk quota exceeded
touch: cannot touch `file4': Disk quota exceeded
touch: cannot touch `file5': Disk quota exceeded
touch: cannot touch `file6': Disk quota exceeded
touch: cannot touch `file7': Disk quota exceeded
touch: cannot touch `file8': Disk quota exceeded
touch: cannot touch `file9': Disk quota exceeded
touch: cannot touch `file10': Disk quota exceeded
root用户:
xfs_quota -x -c 'limit bsoft=3m bhard=6m isoft=3 ihard=6 tom' /boot
xfs_quota -x -c report /boot
切换至 tom 用户: su - tom
切换至root用户:exit
切换至 tom 用户: su - tom
[root@rhel7 ~]# dmesg|grep quota
[ 0.836809] VFS: Disk quotas dquot_6.5.2
[root@rhel7 ~]# rpm -q quota
quota-4.01-11.el7.x86_64
[root@rhel7 ~]# mount|grep boot
/dev/vda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[root@rhel7 ~]# vim /etc/fstab
UUID=abbadca9-0a0d-453f-b713-d3d978cd6909 /boot xfs defaults,usrquota 1 2
[root@rhel7 ~]# reboot
[root@rhel7 ~]# mount|grep boot
/dev/vda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,usrquota)
[root@rhel7 ~]# useradd tom
[root@rhel7 ~]# passwd tom
Changing password for user tom.
New password:
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
[root@rhel7 ~]# chmod -Rf o+w /boot
[root@rhel7 ~]# ll -d /boot
dr-xr-xrwx. 3 root root 4096 Jun 27 03:59 /boot
[root@rhel7 ~]# xfs_quota -x -c 'limit bsoft=3m bhard=6m isoft=3 ihard=6 tom' /boot
[root@rhel7 ~]# xfs_quota -x -c report /boot
User quota on /boot (/dev/vda1)Blocks
User ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 120384 0 0 00 [--------]
tom 0 3072 6144 00 [--------][root@rhel7 ~]# su - tom
Last login: Fri Jul 1 02:51:33 EDT 2016 on pts/0
[tom@rhel7 ~]$ dd if=/dev/zero of=/boot/tom bs=5M count=1
1+0 records in
1+0 records out
5242880 bytes (5.2 MB) copied, 0.0270144 s, 194 MB/s
[tom@rhel7 ~]$ dd if=/dev/zero of=/boot/tom bs=8M count=1
dd: error writing ‘/boot/tom’: Disk quota exceeded
1+0 records in
0+0 records out
6291456 bytes (6.3 MB) copied, 0.218067 s, 28.9 MB/s
[tom@rhel7 ~]$ quota
Disk quotas for user tom (uid 1001):Filesystem blocks quota limit grace files quota limit grace/dev/vda1 6144* 3072 6144 6days 1 3 6
[tom@rhel7 ~]$ exit
logout
[root@rhel7 ~]# edquota -u tom
Disk quotas for user tom (uid 1001):Filesystem blocks soft hard inodes soft hard/dev/vda1 8192 3072 8192 1 3 6
[root@rhel7 ~]# xfs_quota -x -c report /boot
User quota on /boot (/dev/vda1)Blocks
User ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 120384 0 0 00 [--------]
tom 6144 3072 8192 00 [6 days][root@rhel7 ~]# su - tom
Last login: Fri Jul 1 02:58:22 EDT 2016 on pts/0
[tom@rhel7 ~]$ dd if=/dev/zero of=/boot/tom bs=8M count=1
1+0 records in
1+0 records out
8388608 bytes (8.4 MB) copied, 0.267325 s, 31.4 MB/s
[tom@rhel7 ~]$ exit
logout
逻辑卷管理 (Logical Volume Manager)
当用户根据实际情况需要对分区增加、减小等调整时,经常会受到硬盘 “ 灵活性 ” 的限制,很不方便。
逻辑卷管理器则是在磁盘分区与文件系统之间添加的逻辑层,提供一个抽象的卷组,使得管理者可以忽略底层磁盘布局, 从而实现对分区的灵活动态调整,这毫不夸张,所以红帽 RHEL7 系统已经默认启用了 LVM(Logical Volume Manager) 机制。
将物理分区做成 pv ;将 pv 组合成 vg ;再从 vg 分出 lv 分区 -->pv–>vg–>lv
实验:linear 目前用户的映射目标为linear型,线性型,/dev/vdb1 pv1 100M;/dev/vdb2 pv2 100M;/dev/vdb3 pv 3 100M----->myvg 300M----->lv1-linear 20M;lv2-linear 60M现在lv1-linear不够用了,需要拓展60M的空间,lv2-linear也不够用了,需要拓展30M的空间,如何做才能提高读写速度?
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nkPZAgSj-1616288135107)(pic/32.png)]
root@iscsi1-f15 ~]# dmsetup table|grep my
myvg-lv1--linear: 0 40960 linear 252:21 2048
myvg-lv1--linear: 40960 32768 linear 252:21 165888
myvg-lv1--linear: 73728 90112 linear 252:22 2048
myvg-lv2--linear: 0 122880 linear 252:21 43008
myvg-lv2--linear: 122880 65536 linear 252:22 92160
–------------------------------------------------------------------------
[root@iscsi1-f15 ~]# dmsetup table|grep myvg
myvg-lv1--linear: 0 73728 linear 252:25 2048
myvg-lv1--linear: 73728 90112 linear 252:25 75776
myvg-lv2--linear: 0 122880 linear 252:25 165888
myvg-lv2--linear: 122880 65536 linear 252:25 288768
[root@iscsi1-f15 ~]# fdisk /dev/vdb --->vdb[123] 100M
[root@iscsi1-f15 ~]# pvcreate /dev/vdb[123]
[root@iscsi1-f15 ~]# vgcreate myvg /dev/vdb[123]
[root@iscsi1-f15 ~]# lvcreate -L 20M myvg -n lv1-linear
[root@iscsi1-f15 ~]# lvcreate -L 60M myvg -n lv2-linear
[root@iscsi1-f15 ~]# 4 /dev/myvg/lv1-linear
[root@iscsi1-f15 ~]# 4 /dev/myvg/lv2-linear
[root@iscsi1-f15 ~]# mount /dev/myvg/lv1-linear /opt/lv1
[root@iscsi1-f15 ~]# mount /dev/myvg/lv2-linear /opt/lv2
[root@iscsi1-f15 ~]# lvextend -L +60M /dev/myvg/lv1-linear
[root@iscsi1-f15 ~]# lvextend -L +30M /dev/myvg/lv2-linear
[root@iscsi1-f15 ~]# resize2fs /dev/myvg/lv1-linear
[root@iscsi1-f15 ~]# resize2fs /dev/myvg/lv2-linear
[root@iscsi1-f15 ~]# dmsetup table|grep my
myvg-lv1--linear: 0 40960 linear 252:21 2048
myvg-lv1--linear: 40960 32768 linear 252:21 165888
myvg-lv1--linear: 73728 90112 linear 252:22 2048
myvg-lv2--linear: 0 122880 linear 252:21 43008
myvg-lv2--linear: 122880 65536 linear 252:22 92160
–------------------------------------------------------------------------
[root@iscsi1-f15 ~]# fdisk /dev/vdb --->vdb4 500M vdb5 500M
[root@iscsi1-f15 ~]# partx -a /dev/vdb
[root@iscsi1-f15 ~]# pvcreate /dev/vdb[45]
[root@iscsi1-f15 ~]# vgextend myvg /dev/vdb[45]
[root@iscsi1-f15 ~]# pvmove /dev/vdb1 /dev/vdb4
[root@iscsi1-f15 ~]# pvmove /dev/vdb2 /dev/vdb4
[root@iscsi1-f15 ~]# pvmove /dev/vdb4 /dev/vdb5
[root@iscsi1-f15 ~]# dmsetup table|grep myvg
myvg-lv1--linear: 0 73728 linear 252:25 2048
myvg-lv1--linear: 73728 90112 linear 252:25 75776
myvg-lv2--linear: 0 122880 linear 252:25 165888
myvg-lv2--linear: 122880 65536 linear 252:25 288768
1. 查看内核是否支持 quota 功能:2. 查看 quota 程序包是否已经安装:3. 查看 boot 目录是否支持 quota 功能(noquota 表示暂时不支持):4. 让/boot 目录支持 quota 功能:5. 重启主机后即可生效:6. 查看 boot 目录是否支持 quota 功能(usrquota 表示已经支持):7. 创建一个用于 quota 实验的用户 tom:8. 需要允许其他用户对/boot 目录写入文件操作:9. 使用 xfs_quota 命令设置对 tom 用户在/boot 目录的磁盘配额,具体要求如下:
使用 quota 专家模式限制磁盘软限制为 3m、磁盘硬限制为 6m、文件软限制为 3 个且文件硬限制为 6 个。 获取当前/boot 目录上的 quota 配额限制
切换至 tom 用户:
切换至root用户:
切换至 tom 用户:
1)/dev/vdb1 100M;/dev/vdb2 100M;/dev/vdb3 100M;/dev/vdb4 100M2) 将/dev/vdb[1,2,3,4]做成pv3)/dev/vdb1,/dev/vdb2组成vgtest300M4)从vgtest中划分50M的lvtest15)将lvtest1挂载到/mnt下使用6)拓展lvtest1至200M7)拓展lvtest1至400M8)缩小lvtest1至50M
本文发布于:2024-02-05 08:13:31,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170727994664835.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |