RHCE培训笔记-5.2

2020-08-17 11:52:11 浏览数 (1)

访问Linux文件系统

  1. 文件系统:操作系统管理组织文件的方式 带日志

命令:mkfs.xfs /dev/sdb1

  1. 挂载: 文件系统必须挂载才可以使用。mount -t 文件系统类型 设备名 挂载点
  2. 挂载点:就是一个目录。
  3. 块设备 :/dev/ (以下为文件名解释)
代码语言:javascript复制
IDE  /dev/hda   服务器: SCSI

SATA II   3Gb/s  /dev/sda

SATA III  6Gb/s  SSD 500MB/S  /dev/sda   服务器: SAS

M.2 :2000MB/S  1800MB/S 399 480GB 3700MB/S  3000MB/s 706 500GB
/dev/sda :第一块磁盘  /dev/sdb   : 第二块磁盘   /dev/sda1 第一块磁盘的第一个分区 

虚拟化:

kvm: /dev/vda

vmware : /dev/sda

iscsi:  /dev/sda
  1. 磁盘分区表格式:

MBR :master bootloader record: 主引导记录 , 兼容性好, 各种操作系统都支持

缺点:

1)分区数量 :15

2)磁盘支持最大 2TB

分区类型:4 主分区 , 扩展分区:占用一个主分区的编号 ,逻辑分区 从 5开始 ,到 15

GPT: 支持 128个主分区 , PB级别

查看当前系统中的文件系统挂载:

查看目录或文件的磁盘空间占用大小:

本地文件系统类型:不能共享

linux: xfs , ext4 , ext3 windows: ntfs ,extfat , fat32 共享文件系统:GFS2 创建文件系统:mbr

查看新的磁盘设备:

代码语言:javascript复制
[root@server1 /]# ls -l /dev/sdb*
brw-rw----. 1 root disk 8, 16 Oct 20 14:20 /dev/sdb
brw-rw----. 1 root disk 8, 17 Oct 20 14:20 /dev/sdb1
[root@server1 /]# 
[root@server1 /]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=1310656 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=5242624, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
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@server1 /]# 
[root@server1 /]# 
[root@server1 /]#

挂载使用:

代码语言:javascript复制
[root@server1 /]# 
[root@server1 /]# mkdir /mnt/disk1
[root@server1 /]# 
[root@server1 /]# mount /dev/sdb1 /mnt/disk1
[root@server1 /]# 
[root@server1 /]# 
[root@server1 /]# df -hT
Filesystem            Type      Size  Used Avail Use% Mounted on
devtmpfs              devtmpfs  969M     0  969M   0% /dev
tmpfs                 tmpfs     984M     0  984M   0% /dev/shm
tmpfs                 tmpfs     984M  9.7M  974M   1% /run
tmpfs                 tmpfs     984M     0  984M   0% /sys/fs/cgroup
/dev/mapper/rhel-root xfs        20G  4.0G   17G  20% /
/dev/mapper/rhel-tmp  xfs        20G  180M   20G   1% /tmp
/dev/mapper/rhel-var  xfs        50G  639M   50G   2% /var
/dev/mapper/rhel-home xfs        10G  113M  9.9G   2% /home
/dev/sda1             xfs       2.0G  161M  1.9G   8% /boot
tmpfs                 tmpfs     197M   16K  197M   1% /run/user/42
tmpfs                 tmpfs     197M  3.5M  194M   2% /run/user/0
/dev/sr0              iso9660   6.7G  6.7G     0 100% /mnt/iso
/dev/sdb1             xfs        20G  176M   20G   1% /mnt/disk1
[root@server1 /]#

GPT分区

一 分区模式之MBR 1、主分区不超过4个 2、单个分区容量最大2TB 二 分区模式之GPT 1、主分区个数“几乎”没有限制。 在GPT的分区表中最多支持128个主分区。 2、单个分区容量“几乎”没有限制。 在GPT的分区模式中,每个分区的大小突破了MBR分区2TB限制。 来源:https://blog.csdn.net/chengqiuming/article/details/78601872

创建一个gpt分区的文件系统:

代码语言:javascript复制
[root@server1 /]# 
[root@server1 /]# 
[root@server1 /]# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
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.
The size of this disk is 3 TiB (3221225472000 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).

Created a new DOS disklabel with disk identifier 0xf52bc711.

Command (m for help):

创建GPT分区:

代码语言:javascript复制
[root@server1 /]# 
[root@server1 /]# gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-6291455966, default = 2048) or { -}size{KMGTP}: 
Last sector (2048-6291455966, default = 6291455966) or { -}size{KMGTP}:  10G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/sdc: 6291456000 sectors, 2.9 TiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 5CE0812B-FCFB-4D02-B06A-8308F8E66CA3
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 6291455966
Partitions will be aligned on 2048-sector boundaries
Total free space is 6270484413 sectors (2.9 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        20973567   10.0 GiB    8300  Linux filesystem

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
[root@server1 /]#
[root@server1 /]# 
[root@server1 /]# 
[root@server1 /]# 
[root@server1 /]# 
[root@server1 /]# 
[root@server1 /]# gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.3
.....(懒)

KVM虚拟化

KVM 全称:kernel-base virtual machine

启动服务:

代码语言:javascript复制
[root@ropu ~]# systemctl enable libvirtd


[root@ropu ~]# systemctl start libvirtd
[root@ropu ~]# 

[root@ropu ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor pr>
   Active: active (running) since Sun 2019-10-20 15:55:48 CST; 2min 4s ago
     Docs: man:libvirtd(8)
           https://libvirt.org
 Main PID: 2690 (libvirtd)
    Tasks: 19 (limit: 32768)
   Memory: 60.6M
   CGroup: /system.slice/libvirtd.service
           ├─2084 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defaul>
           ├─2086 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defaul>
           └─2690 /usr/sbin/libvirtd

Oct 20 15:55:48 ropu.example.com systemd[1]: Starting Virtualization daemon...
Oct 20 15:55:48 ropu.example.com systemd[1]: Started Virtualization daemon.
Oct 20 15:55:49 ropu.example.com dnsmasq[2084]: read /etc/hosts - 2 addresses
Oct 20 15:55:49 ropu.example.com dnsmasq[2084]: read /var/lib/libvirt/dnsmasq/d>
Oct 20 15:55:49 ropu.example.com dnsmasq-dhcp[2084]: read /var/lib/libvirt/dnsm>

安装图形化工具:virt-manager

代码语言:javascript复制
[root@ropu ~]# yum -y install virt-manager
Last metadata expiration check: 0:07:54 ago on Sun 20 Oct 2019 03:50:50 PM CST.
Dependencies resolved.
===============================================================================
 Package            Arch   Version                             Repository
                                                                          Size
===============================================================================
Installing:
 virt-manager       noarch 2.0.0-5.1.el8                       AppStream 365 k
Installing dependencies:
 python3-libvirt    x86_64 4.5.0-2.module_el8.0.0 189 f9babebb AppStream 291 k
 virt-manager-common
                    noarch 2.0.0-5.1.el8                       AppStream 921 k

Transaction Summary
===============================================================================
Install  3 Packages

Total download size: 1.5 M
Installed size: 8.4 M
Downloading Packages:

安装完直接输入命令就可以了

安装cockpit webui管理工具:(插件)

代码语言:javascript复制
yum -y install cockpit-machines.noarch subscription-manager-cockpit.noarch

启动后,浏览器输入 ip <端口号9090>

输入账号密码

0 人点赞