一、添加一块新的80G硬盘

[root@server0 ~]# lsblk
vdc 253:32 0 80G 0 disk
[root@server0 ~]# fdisk /dev/vdc #划分三个主分区和二个逻辑分区
p 查看分区表
n 创建主分区----->回车----->回车---->回车----->在last结束时 +10G
n 创建主分区----->回车----->回车---->回车----->在last结束时 +10G
n 创建主分区----->回车----->回车---->回车----->在last结束时 +10G
p 查看分区表
n 创建扩展分区
----->回车---->起始回车----->结束回车 将所有空间给扩展分区
p 查看分区表
n 创建逻辑分区----->起始回车------>结束+10G
n 创建逻辑分区----->起始回车------>结束+10G
p 查看分区表
w 保存并退出
t change a partition’s system id
[root@server0 ~]# lsblk
[root@server0 ~]# ls /dev/vdc[1-6]

##########################################################
逻辑卷
作用:
1.整合分散的空间 2.空间可以扩大

将众多的物理卷(PV)组建成卷组(VG),再从卷组中划分逻辑卷(LV)

LVM管理工具集
功能 物理卷管理 卷组管理 逻辑卷管理
Scan 扫描 pvscan vgscan lvscan
Create 创建 pvcreate vgcreate lvcreate
Display 显示 pvdisplay vgdisplay lvdisplay
Remove 删除 pvremove vgremove lvremove
Extend 扩展 / vgextend lvextend

二、制作逻辑卷
successfully 成功

1.创建卷组
命令格式:vgcreate 卷组的名字 设备路径…
[root@server0 ~]# vgcreate systemvg /dev/vdb /dev/vdc1

[root@server0 ~]# pvs #查看物理卷信息
[root@server0 ~]# vgs #查看卷组信息

2.创建逻辑卷
命令格式:lvcreate -L 逻辑卷大小 -n 逻辑卷名称 基于的卷组名
[root@server0 ~]# lvcreate -L 16G -n vo systemvg
Logical volume “vo” created
[root@server0 ~]# lvs #查看逻辑卷信息
[root@server0 ~]# vgs #查看卷组信息

3.使用逻辑卷
[root@server0 ~]# ls /dev/systemvg/vo
[root@server0 ~]# ls -l /dev/systemvg/vo
[root@server0 ~]# mkfs.xfs /dev/systemvg/vo #格式化文件系统类型

[root@server0 ~]# blkid /dev/systemvg/vo #查看文件系统类型

[root@server0 ~]# vim /etc/fstab
/dev/systemvg/vo /mylv xfs defaults 0 0

[root@server0 ~]# mkdir /mylv
[root@server0 ~]# mount -a #检测/etc/fstab是否书写正确
[root@server0 ~]# df -h #查看正在挂载设备的信息

#######################################################
三、逻辑卷的扩展

1.卷组有足够的剩余空间
1)扩展逻辑卷空间
[root@server0 ~]# lvextend -L 18G /dev/systemvg/vo
[root@server0 ~]# lvs
[root@server0 ~]# df -h
2)扩展逻辑卷文件系统
扩展xfs文件系统: xfs_growfs
扩展ext4文件系统:resize2fs
[root@server0 ~]# blkid /dev/systemvg/vo #查看文件系统类型
[root@server0 ~]# df -h
[root@server0 ~]# xfs_growfs /dev/systemvg/vo
[root@server0 ~]# df -h

2.卷组没有足够的剩余空间
1)扩展卷组空间
[root@server0 ~]# vgextend systemvg /dev/vdc[2-3]
[root@server0 ~]# vgs
2)扩展逻辑卷空间
[root@server0 ~]# lvextend -L 25G /dev/systemvg/vo
[root@server0 ~]# lvs
[root@server0 ~]# df -h
3)扩展逻辑卷文件系统
扩展xfs文件系统: xfs_growfs
扩展ext4文件系统:resize2fs
[root@server0 ~]# blkid /dev/systemvg/vo #查看文件系统类型
[root@server0 ~]# df -h
[root@server0 ~]# xfs_growfs /dev/systemvg/vo
[root@server0 ~]# df -h
#######################################################
了解:逻辑卷可以缩减

#######################################################
卷组划分空间的单位 PE
[root@server0 ~]# vgdisplay systemvg #查看卷组详细信息
PE Size 4.00 MiB

请创建一个250M大小的逻辑卷名为redhat
[root@server0 ~]# vgchange -s 1M systemvg #修改PE的大小
Volume group “systemvg” successfully changed
[root@server0 ~]# vgdisplay systemvg

[root@server0 ~]# lvcreate -L 250M -n redhat systemvg
[root@server0 ~]# lvs

请创建一个大小为500个PE的逻辑卷lvtest02
-l:指定PE的个数
[root@server0 ~]# lvcreate -l 500 -n lvtest02 systemvg
[root@server0 ~]# lvs

#########################################################
删除逻辑卷:
优先删除逻辑卷本身,然后在删除卷组,最后删除物理卷

删除卷组时,前提基于该卷组的所有逻辑卷都要删除。
[root@server0 ~]# lvremove /dev/systemvg/redhat
Do you really want to remove active logical volume redhat? [y/n]: y
Logical volume “redhat” successfully removed
[root@server0 ~]# lvs

#########################################################
find高级使用,查找数据所在的路径
格式: find [目录] [条件1]
– 常用条件表示:
-type 类型(f文件、d目录、l快捷方式)
-name “文档名称”
-size +|-文件大小(k、M、G)
-user 用户名
-mtime 根据文件修改时间

##################################################
-type 类型(f文件、d目录、l快捷方式)
-name “文档名称”

[root@server0 ~]# find /boot/ -type l
[root@server0 ~]# ls /boot/grub/menu.lst

[root@server0 ~]# find /boot/ -type d
[root@server0 ~]# find /boot/ -type f

[root@server0 ~]# find /etc/ -name “passwd”
[root@server0 ~]# find /etc/ -name “*tab”
[root@server0 ~]# find /etc/ -name “tab

[root@server0 ~]# mkdir /root/nsd1911
[root@server0 ~]# touch /root/nsd01.txt
[root@server0 ~]# touch /root/nsd02.txt

[root@server0 ~]# find /root/ -name “nsd*”

[root@server0 ~]# find /root/ -name “nsd*” -a -type f

[root@server0 ~]# find /root/ -name “nsd*” -a -type d

[root@server0 ~]# find /root/ -name “nsd*” -type d
########################################################
-size +或-文件大小(k、M、G)
-user 用户名 #按照所有者进行查找

[root@server0 ~]# find /boot/ -size +10M
[root@server0 ~]# find /boot/ -size -10M
[root@server0 ~]# find /boot/ -size +300k
[root@server0 ~]# find /boot/ -size +1M

[root@server0 ~]# find /home/ -user student

[root@server0 ~]# find / -user student
/proc:不占用磁盘空间,反映内存数据

##########################################################
-mtime 根据文件修改时间,所有的时间表示的为过去时间
-mtime +10 #查找10天之前的数据
-mtime -10 #查找最近10天之内的数据

[root@server0 ~]# find /root/ -mtime +1000

[root@server0 ~]# find /root/ -mtime -10

[root@server0 ~]# find /root/ -mtime +90 #三个月之前

##########################################################
find扩展使用,处理find查询的结果
• 使用find命令的 -exec 操作
– find … … -exec 处理命令 {} ;
– 优势:以 {} 代替每一个结果,逐个处理,遇 ; 结束

]# find /boot/ -size +10M
]# find /boot/ -size +10M -exec cp {} /opt ;
]# ls /opt/

]# find /etc/ -name “*tab”
]# find /etc/ -name “*tab” -exec cp {} /opt ;
]# ls /opt/

#######################################################
grep过滤文本文件内容

[root@server0 ~]# grep root /etc/passwd #包含root的行

[root@server0 ~]# grep ROOT /etc/passwd
[root@server0 ~]# grep -i ROOT /etc/passwd #忽略大小写
[root@server0 ~]# grep -v root /etc/passwd #取反

[root@server0 ~]# grep ^root /etc/passwd #显示以root开头行
[root@server0 ~]# grep bash$ /etc/passwd #显示以bash结尾的行

在Linux大多数配置文件中,以#开头的行一般为注释行

^KaTeX parse error: Expected 'EOF', got '#' at position 8: :匹配空行 ]#̲ grep -v ^ /etc/default/useradd

显示文件的有效信息(去除注释行,去除空行)
]# grep -v ^# /etc/default/useradd | grep -v ^$

]# grep -v ^# /etc/login.defs
]# grep -v ^# /etc/login.defs | grep -v ^$

]# grep -v ^# /etc/login.defs | grep -v ^$ > /opt/1.txt
]# cat /opt/1.txt

##########################################################
案例4:查找并处理文件
• 使用find命令完成以下任务
– 找出所有用户 student 拥有的文件
– 把它们拷贝到 /root/findfiles/ 文件夹中

]# mkdir /root/findfiles
]# find / -user student -type f

]# find / -user student -type f -exec cp {} /root/findfiles/ ;

]# ls -A /root/findfiles/

##########################################################
NTP网络时间协议
• Network Time Protocol
– NTP服务器为客户机提供标准时间
– NTP客户机需要与NTP服务器保持沟通

• RHEL7客户端的校时服务
– 软件包:chrony
– 配置文件:/etc/chrony.conf
– 系统服务:chronyd

NTP服务端:为客户机提供标准时间 虚拟机classroom

NTP客户机:寻找NTP服务端同步时间 虚拟机server
1.安装软件包:chrony
[root@server0 ~]# rpm -q chrony
chrony-1.29.1-1.el7.x86_64
[root@server0 ~]#

2.修改配置文件,指定NTP服务端
[root@server0 ~]# 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 classroom.example.com iburst #指定服务端

3.重起服务(重起程序)
[root@server0 ~]# systemctl restart chronyd #重起chronyd服务
[root@server0 ~]# systemctl enable chronyd #设置开机自启动

4.测试
[root@server0 ~]# date
[root@server0 ~]# date -s “2000-1-1”
[root@server0 ~]# date
[root@server0 ~]# systemctl restart chronyd
[root@server0 ~]# date
[root@server0 ~]# date
[root@server0 ~]# date
##########################################################
Set UID附加权限
• 附加在属主的 x 位上
– 属主的权限标识会变为 s
– 适用于可执行文件,Set UID可以让使用者具有文件属主的身份及部分权限

[root@server0 ~]# /usr/bin/mkdir /opt/haha
[root@server0 ~]# ls /opt/
[root@server0 ~]# cp /usr/bin/mkdir /usr/bin/xixidir

[root@server0 ~]# /usr/bin/xixidir /opt/hehe
[root@server0 ~]# ls /opt/
[root@server0 ~]# chmod u+s /usr/bin/xixidir
[root@server0 ~]# ls -l /usr/bin/xixidir
[root@server0 ~]# ls -l /usr/bin/mkdir
[root@server0 ~]# su - student
[student@server0 ~]$ /usr/bin/mkdir test01
[student@server0 ~]$ ls -l
[student@server0 ~]$ /usr/bin/xixidir test02
[student@server0 ~]$ ls -l
[student@server0 ~]$ exit
######################################################

Linux 卷组逻辑卷创建管理和find高级使用 Set UID附加权限(DAY7)相关推荐

  1. linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例

    转自:truemylife.linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例 基本概念: 磁盘.分区.物理卷[物理部分] 卷组[中间部分] 逻辑卷.文件系统[虚拟化后可控制部分] 磁 ...

  2. CentOS 7 删除LV VG卷组逻辑卷物理卷

    很多用户在XenSystem的默认模版CentOS7默认挂载到/home,无法挂载/www 按如下操作 查看卷组相关信息 [root@MyCloudServer ~]# vgscanReading a ...

  3. LVM逻辑卷 (概述lvm,管理卷组 物理卷 逻辑卷,磁盘配额)

    文章目录 管理LVM逻辑卷 前言 lvm简述 pv物理卷 VG卷组 lv逻辑卷 管理LVM pv物理卷管理 pvscan命令--用于扫描系统中的物理卷 pvcreate命令--把整个硬盘转换成物理卷 ...

  4. Linux 中的逻辑卷 LVM 管理完整初学者指南

    这是 Linux 中 LVM(逻辑卷管理)的完整初学者指南. 在本教程中,您将了解 LVM 的概念.它的组件以及为什么要使用它. 我不会仅限于理论上的解释,我还将展示在 Linux 中创建和管理 LV ...

  5. linux系统创建lvm卷,LVM逻辑卷创建管理

    一.简介 LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵 ...

  6. linux系统挂载逻辑卷和扩展逻辑卷组

    一.独立新磁盘挂载逻辑卷: 1.创建pv: 例如,Linux系统挂载是两块 100G的磁盘 /dev/vdb /dev/vdc 对两块磁盘进行分区,默认全部都是分成一个区: fdisk /dev/vd ...

  7. linux查看lv逻辑卷信息,Linux学习笔记(lvm pv物理卷—VG卷组—LV逻辑卷)

    一.LVM 准备磁盘分区 disk /dev/sdb n创建分区 t更改类型 8e partprobe 将磁盘分区表变化信息通知内核,请求操作系统重新加载分区表.-d 不更新内核 -s 显示磁盘分区汇 ...

  8. Linux中LVM(逻辑卷管理)的使用

    Linux 中我们使用fdisk命令划分好的分区就不能随意的改变,如果不够用的话不可能说把硬盘上的所有数据拷贝后再重新分区,这样可能会导致数据损坏.而在linux中LVM(逻辑卷管理)就可以实现动态的 ...

  9. 每天一个新知识之Linux的LVM逻辑卷管理

    一.什么是LVM逻辑卷 1.什么是逻辑卷 许多Linux使用者安装操作系统时都会遇到这样的困境:如何精确评估和分配各个硬盘分区的容量,如果当初评估不准确,一旦系统分区不够用时可能不得不备份.删除相关数 ...

最新文章

  1. 好消息:Sci-Hub解封了!可以看2021新文献了!附可用网址
  2. SpringSession(redis)
  3. P1569 [USACO11FEB]属牛的抗议Generic Cow Prote…
  4. 一文读懂P Quant与 Q Quant ,量化交易与金融工程
  5. SmartRF Flash Programmer1.6.2打不开程序界面问题
  6. 13.2.6 会话跟踪技术
  7. Min_25筛学习Tip+链接
  8. 第四节:EF Core的并发处理
  9. 转:运维监控系统-监控项及指标的梳理
  10. Unity(四):使用场景Ⅰ:建立类型映射
  11. 箱梁终张拉后弹性上拱度计算_高速铁路预应力简支箱梁反拱预设分析
  12. 学习笔记:2019 张小龙在微信公开课上的演讲
  13. 产品报价单模板_外贸干货 | 外贸人的好东西,报价单这样做才专业!
  14. PolkaFoundry等成立Polkadot区块链开发协会(PBDA)
  15. 华为全系Visio图标下载链接
  16. Mask-RCNN(2)Resnet101
  17. 数据库建模工具PowerDesigner的基本使用方法
  18. 【操作系统】-- 基本分页存储管理(基本地址变换机构、具有快表的地址变换机构)
  19. C++ 加号运算符重载
  20. 仿网易云音乐源码html5

热门文章

  1. 学生管理系统的mysql数据库设计_MySQL数据库--学生管理系统数据库设计
  2. PHP技术与应用基础
  3. 用python画动图_Python 绘图与可视化 matplotlib 制作Gif动图
  4. ettercap局域网内DNS欺骗(隔壁的哥们轻一点 ...)
  5. 启动mongodb数据库服务
  6. 单片机阻塞延时与非阻塞延时(1)
  7. Pandas(一)—— Pandas基础
  8. 不动点迭代(Fixed Point Iteration)
  9. 【调剂】浙江大学计算机学院机械专业2023年硕士研究生招生调剂通知
  10. 【Linux】x86结构