1、图形添加一个80G的硬盘 [[emailprotected] ~]# lsblk [[emailprotected] ~]# fdisk /dev/vdc #划分三个主分区,两个逻辑分区 p 查看分区表 n 创建主分区-----回车-----回车----回车-----在last结束时 +10G n 创
[[email protected] ~]# lsblk
[[email protected] ~]# fdisk /dev/vdc #划分三个主分区,两个逻辑分区
p 查看分区表
n 创建主分区----->回车----->回车---->回车----->在last结束时 +10G
n 创建主分区----->回车----->回车---->回车----->在last结束时 +10G
n 创建主分区----->回车----->回车---->回车----->在last结束时 +10G
p 查看分区表
n 创建扩展分区
----->回车---->起始回车----->结束回车 将所有空间给扩展分区
p 查看分区表
n 创建逻辑分区----->起始回车------>结束+10G
n 创建逻辑分区----->起始回车------>结束+10G
p 查看分区表
w 保存并退出
[[email protected] ~]# lsblk
2、逻辑卷
1.整合分散的空间 2.空间可以扩展
逻辑卷建立:
将众多的物理卷(PV)组建成卷组(VG),再从卷组中划分出逻辑卷(LV)
一、创建逻辑卷
successfully 成功
1.创建卷组
命令格式:vgcreate 卷组名 设备路径.......
[[email protected] ~]# vgcreate systemvg /dev/vdb /dev/vdc1
[[email protected] ~]# pvs #查看物理卷信息
[[email protected] ~]# vgs #查看卷组信息
2.创建逻辑卷
命令格式:lvcreate -L 逻辑卷大小 -n 逻辑卷名 卷组名
* [[email protected] ~]# vgs #查看卷组信息
* [[email protected] ~]# lvcreate -L 16G -n mylv systemvg
* Logical volume "mylv" created
* [[email protected] ~]# lvs #查看逻辑卷信息
* [[email protected] ~]# vgs #查看卷组信息
3.使用逻辑卷
* [[email protected] ~]# ls /dev/systemvg/mylv #查看逻辑卷设备路径
* [[email protected] ~]# ls -l /dev/systemvg/mylv
* [[email protected] ~]# mkfs.xfs /dev/systemvg/mylv #格式化文件系统
* [[email protected] ~]# blkid /dev/systemvg/mylv
* [[email protected] ~]# vim /etc/fstab
* /dev/systemvg/mylv /nsd xfs defaults 0 0
* [[email protected] ~]# mkdir /nsd
* [[email protected] ~]# mount -a
* [[email protected] ~]# df -h
二、逻辑卷的扩展
1.卷组有足够的剩余空间
1)扩展逻辑卷空间
[[email protected] ~]# vgs
[[email protected] ~]# lvs
[[email protected] ~]# lvextend -L 18G /dev/systemvg/mylv
[[email protected] ~]# lvs
[[email protected] ~]# df -h
2)扩展文件系统
xfs文件系统:xfs_growfs
ext4文件系统:resize2fs
* [[email protected] ~]# df -h
* [[email protected] ~]# xfs_growfs /dev/systemvg/mylv
* [[email protected] ~]# df -h
2.卷组没有足够的剩余空间
1)扩展卷组空间
[[email protected] ~]# vgextend systemvg /dev/vdc2
[[email protected] ~]# vgs
[[email protected] ~]# vgextend systemvg /dev/vdc3
[[email protected] ~]# vgs
2)扩展逻辑卷空间
* [[email protected] ~]# vgs
* [[email protected] ~]# lvs
* [[email protected] ~]# lvextend -L 25G /dev/systemvg/mylv
* [[email protected] ~]# lvs
* [[email protected] ~]# df -h
*
3)扩展文件系统
* [[email protected] ~]# df -h
* [[email protected] ~]# xfs_growfs /dev/systemvg/mylv
* [[email protected] ~]# df -h
补充:逻辑卷也可以支持缩小
xfs文件系统,不支持缩小
ext4文件系统,支持缩小
卷组划分空间的单位:PE 默认大小 4M
* [[email protected] ~]# vgdisplay systemvg #查看卷组的详细信息
PE Size 4.00 MiB
请划分一个大小为250M的逻辑卷为lvredhat
[[email protected] ~]# vgchange -s 1M systemvg #修改PE大小
Volume group "systemvg" successfully changed
[[email protected] ~]# vgdisplay systemvg #显示卷组的详细信息
PE Size 1.00 MiB
[[email protected] ~]# lvcreate -L 250M -n lvredhat systemvg
Logical volume "lvtest" created
[[email protected] ~]# lvs
? 创建卷组的时候设置PE大小
– vgcreate -s PE大小 卷组名 空闲分区...
? 创建逻辑卷的时候指定PE个数
– lvcreate -l PE个数 -n 逻辑卷名 卷组名
逻辑卷的删除
首先删除逻辑卷本身,然后再删除卷组,最后删除物理卷
[[email protected] ~]# lvremove /dev/systemvg/lvredhat
Do you really want to remove active logical volume lvredhat? [y/n]: y
Logical volume "lvredhat" successfully removed
[[email protected] ~]# lvs
**find高级使用,查找数据所在的位置**
** 查找文件**
? 根据预设的条件递归查找对应的文件
– find [目录] [条件1] [-a|-o] [条件2] ...
– 常用条件表示:
-type 类型(f文件、d目录、l快捷方式)
-name "文档名称"
-size +|-文件大小(k、M、G)
-user 用户名
-mtime 根据文件修改时间
[[email protected] ~]# find /boot/ -type l #查找是快捷方式
/boot/grub/menu.lst
[[email protected] ~]# ls /boot/grub/menu.lst
[[email protected] ~]# find /boot/ -type f #查找是文本文件
[[email protected] ~]# find /boot/ -type d #查找是目录
/proc:反映内存的数据,不占用磁盘空间
-mtime 根据文件修改时间 都是过去时间
-mtime +10 #10天之前数据
-mtime -10 #最近10天之内数据
[[email protected] ~]# find /root/ -mtime -2
[[email protected] ~]# find /root/ -mtime +10
[[email protected] ~]# find /var/ -mtime +90
find扩展使用
? 使用find命令的 -exec 操作
– find .. .. -exec 处理命令 {} \;
– 优势:以 {} 代替每一个结果,逐个处理,遇 \; 结束
NTP网络时间协议
? Network Time Protocol
– NTP服务器为客户机提供标准时间
– NTP客户机需要与NTP服务器保持沟通
NTP服务器:虚拟机cla***oom
NTP客户机:虚拟机server,指定服务端位置
1.安装chrony软件,与NTP服务器沟通的软件
[[email protected] ~]# rpm -q chrony
chrony-1.29.1-1.el7.x86_64
** 2.修改配置文件**
[[email protected] ~]# vim /etc/chrony.conf
#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
server cla***oom.example.com iburst #指定服务器位置
3.重新启动程序(重起服务)
[[email protected] ~]# systemctl restart chronyd #重新启动服务
[[email protected] ~]# systemctl enable chronyd #设置开机自启动
Set UID
? 附加在属主的 x 位上
– 属主的权限标识会变为 s
– 适用于可执行文件,Set UID可以让使用者具有文件属主的身份及部分权限
* [[email protected] ~]# /usr/bin/mkdir /mnt/test01
* [[email protected] ~]# ls /mnt/
* [[email protected] ~]# cp /usr/bin/mkdir /usr/bin/hahadir
* [[email protected] ~]# ls /usr/bin/hahadir
* [[email protected] ~]# /usr/bin/hahadir /mnt/test02
* [[email protected] ~]# ls /mnt/
* [[email protected] ~]# chmod u+s /usr/bin/hahadir #赋予Set UID
* [[email protected] ~]# ls -l /usr/bin/hahadir
* [[email protected] ~]# su - student
* [[email protected] ~]$ /usr/bin/mkdir abc01
* [[email protected] ~]$ ls -l
* [[email protected] ~]$ /usr/bin/hahadir abc02
* [[email protected] ~]$ ls -l
