Linux 中的 LVM 架构及磁盘逻辑划分的方式

您所在的位置:网站首页 挂载system什么意思 Linux 中的 LVM 架构及磁盘逻辑划分的方式

Linux 中的 LVM 架构及磁盘逻辑划分的方式

2023-03-28 17:34| 来源: 网络整理| 查看: 265

Written By: Xinyao Tian

Abstract

本文档详细记录了如何识别物理设备并创建 PV (Physical Volume), 并将多个 PV 合并为一个 VG (Volume Group),在此基础上对 VG 进行逻辑上的划分并创建 LV (Logical Volume),基于 LV 创建 FileSystem,最后将细分的 LV 挂载到 Linux 的相应目录上。

Definitions (概念) Logical Volume Manager (LVM)

LVM 是用于逻辑卷管理的工具,可以帮助我们分配磁盘,移除、复制、重新分配逻辑卷。

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes. With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks. Physical volumes (PV)

PV (Physical volumes) 是使用 LVM 操作硬盘的基本模块,也是物理磁盘在操作系统中的直接映射。

Physical volumes (PV) are the base "block" that you need in order to manipulate a disk using Logical Volume Manager (LVM). Volume Group (VG)

VG (Volume Group) 是 LVM (Logical Volume Manager) 架构的核心部位。它可以帮助我们将许多物理的 Volumes 合并成一个单独的存储结构,相当于在逻辑上将所有物理设备的存储能力都进行了合并,以便于使用和管理。简单来讲,VG 可以帮助管理员抽象底层硬件的细节,并把多块硬盘组合成一个抽象的存储以供逻辑上的划分。

A volume group (VG) is the central unit of the Logical Volume Manager (LVM) architecture. It is what we create when we combine multiple physical volumes to create a single storage structure, equal to the storage capacity of the combined physical devices. Physical volumes are devices that are initialized using LVM, i.e., hard disk drives, solid-state drives, partitions, etc. -- Given By RedHat documents Logical volumes (LV)

LV (Logical volumes) 是 LVM 架构的最顶层的存储单元,它们从由 PV 构成的 VG 创建而来。LV 可以根据需要将 VG 划分成多个逻辑上的分区以供系统管理员精细化使用。

Logical Volumes (LV) are the final storage unit in the standard LVM architecture. These units are created from the volume group, which is made up of physical volumes (PV). 操作步骤

本节记录了如何将物理设备映射为 PV,再用多个 PVs 组成 VG,最后在 VG 上划分 LV 并创建 FileSystem 挂载至相应的 Mountpoint。

检视硬件设备挂载情况

使用 fdisk -l 查看全部物理设备的情况:

[root@p0-tkldmp-rc12 /]# fdisk -l Disk /dev/nvme0n1: 960.2 GB, 960197124096 bytes, 1875385008 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 /dev/sda: 479.6 GB, 479559942144 bytes, 936640512 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk label type: dos Disk identifier: 0x00072cde Device Boot Start End Blocks Id System /dev/sda1 2048 4095 1024 83 Linux /dev/sda2 * 4096 1052671 524288 83 Linux /dev/sda3 1052672 936640511 467793920 8e Linux LVM Disk /dev/mapper/rootvg-root: 68.7 GB, 68719476736 bytes, 134217728 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/mapper/rootvg-swap: 34.4 GB, 34359738368 bytes, 67108864 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/mapper/rootvg-kdump: 34.4 GB, 34359738368 bytes, 67108864 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/mapper/rootvg-home: 34.4 GB, 34359738368 bytes, 67108864 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/mapper/rootvg-tmp: 307.1 GB, 307090161664 bytes, 599785472 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/mapper/datavg-data: 955.6 GB, 955630223360 bytes, 1866465280 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

使用 lsblk 命令查看所有物理设备与逻辑卷之间的映射情况与挂载情况:

[root@p0-tkldmp-rc11 /]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 446.6G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 512M 0 part /boot └─sda3 8:3 0 446.1G 0 part ├─rootvg-root 253:0 0 64G 0 lvm / ├─rootvg-swap 253:1 0 32G 0 lvm ├─rootvg-kdump 253:2 0 32G 0 lvm /var/crash ├─rootvg-home 253:3 0 32G 0 lvm /home └─rootvg-tmp 253:4 0 286G 0 lvm /var nvme0n1 259:0 0 894.3G 0 disk

可以看到有一块名为 nvme0n1 的硬盘没有任何 MOUNTPOINT ,证明该设备没有任何挂载点。

在 /dev 中查询设备情况:

[root@p0-tkldmp-rc11 dev]# ls -l | grep disk drwxr-xr-x 5 root root 100 Jan 6 2022 disk brw-rw---- 1 root disk 253, 0 Jan 5 2022 dm-0 brw-rw---- 1 root disk 253, 1 Feb 17 2022 dm-1 brw-rw---- 1 root disk 253, 2 Jan 5 2022 dm-2 brw-rw---- 1 root disk 253, 3 Jan 5 2022 dm-3 brw-rw---- 1 root disk 253, 4 Mar 14 11:11 dm-4 crw-rw---- 1 root disk 10, 237 Jan 5 2022 loop-control brw-rw---- 1 root disk 259, 0 Jan 5 2022 nvme0n1 brw-rw---- 1 root disk 8, 0 Jan 5 2022 sda brw-rw---- 1 root disk 8, 1 Jan 5 2022 sda1 brw-rw---- 1 root disk 8, 2 Jan 5 2022 sda2 brw-rw---- 1 root disk 8, 3 Mar 14 11:11 sda3 crw-rw---- 1 root disk 21, 0 Jan 5 2022 sg0

可以看到 nvme0n1 位于 /dev 目录之下。

创建 PV (Physical Volume) 并查看

使用该命令使用已有的硬盘硬件创建一个新的 PV: pvcreate /dev/nvme0n1

执行结果如下所示:

[root@p0-tkldmp-rc11 dev]# pvcreate /dev/nvme0n1 WARNING: dos signature detected on /dev/nvme0n1 at offset 510. Wipe it? [y/n]: y Wiping dos signature on /dev/nvme0n1. Physical volume "/dev/nvme0n1" successfully created.

查看创建完毕的 PV 信息:

[root@p0-tkldmp-rc11 dev]# pvscan PV /dev/sda3 VG rootvg lvm2 [446.09 GiB / 96.00 MiB free] PV /dev/nvme0n1 lvm2 [894.25 GiB] Total: 2 [


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3