中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

CentOS7下怎么快速創建LVM

發布時間:2022-02-17 09:54:47 來源:億速云 閱讀:218 作者:iii 欄目:開發技術

今天小編給大家分享一下CentOS7下怎么快速創建LVM的相關知識點,內容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

LVM是在硬盤分區和文件系統之間添加的一個邏輯層,為文件系統屏蔽下層硬盤分區布局,并提供一個抽象的盤卷,在盤卷上建立文件系統。管理員利用LVM可以在硬盤不用重新分區的情況下動態調整文件系統的大小,并且利用LVM管理的文件系統可以跨越物理硬盤。

CentOS7下怎么快速創建LVM

環境:CentOS7虛擬機,掛載了一塊2G硬盤

二、配置過程:

二、配置過程:

1、給硬盤分區:

  創建三個分區,前兩個512M,最后一個默認大小,1G多一些,最后一個默認指定大小,具體操作根據自己環境而定。把分區都改成Linux LVM格式就好了。

Command (m for help): p //查看分區表

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 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: 0xbe89015f

Device Boot Start End Blocks Id System

Command (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-4194303, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): +512M //指定大小
Partition 1 of type Linux and of size 512 MiB is set

Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (1050624-4194303, default 1050624):
Using default value 1050624
Last sector, +sectors or +size{K,M,G} (1050624-4194303, default 4194303): +512M
Partition 2 of type Linux and of size 512 MiB is set

Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3):
First sector (2099200-4194303, default 2099200):
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-4194303, default 4194303): //默認剩下全部大小
Using default value 4194303
Partition 3 of type Linux and of size 1023 MiB is set

Command (m for help): w //保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# fdisk /dev/sdb
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.

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 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: 0xbe89015f

Device Boot Start End Blocks Id System
/dev/sdb1 2048 1050623 524288 83 Linux
/dev/sdb2 1050624 2099199 524288 83 Linux
/dev/sdb3 2099200 4194303 1047552 83 Linux

Command (m for help): t //修改分區類型
Partition number (1-3, default 3): 1 //選擇分區
Hex code (type L to list all codes): 8e //更變為Linux LVM類型分區,8e為分區代碼,l可以查看

Changed type of partition ‘Linux’ to ‘Linux LVM’

Command (m for help): t
Partition number (1-3, default 3): 2
Hex code (type L to list all codes): 8e
Changed type of partition ‘Linux’ to ‘Linux LVM’

Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 8e
Changed type of partition ‘Linux’ to ‘Linux LVM’

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 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: 0xbe89015f

Device Boot Start End Blocks Id System
/dev/sdb1 2048 1050623 524288 8e Linux LVM
/dev/sdb2 1050624 2099199 524288 8e Linux LVM
/dev/sdb3 2099200 4194303 1047552 8e Linux LVM
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

2、創建物理卷:

命令:pv系列命令

root@localhost ~]# pv
pvchange pvcreate pvmove pvresize pvscan
pvck pvdisplay pvremove pvs

創建物理卷:選擇自己要創建的分區

[root@localhost ~]# pvcreate /dev/sdb{1,2,3} //用sdb1,sdb2,sdb3三個分區來創建物理卷
Physical volume “/dev/sdb1” successfully created.
Physical volume “/dev/sdb2” successfully created.
Physical volume “/dev/sdb3” successfully created.

簡單查看物理卷:

[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 — 512.00m 512.00m
/dev/sdb2 lvm2 — 512.00m 512.00m
/dev/sdb3 lvm2 — 1023.00m 1023.00m

詳細查看:

[root@localhost ~]# pvdisplay
“/dev/sdb1” is a new physical volume of “512.00 MiB”
— NEW Physical volume —
PV Name /dev/sdb1
VG Name
PV Size 512.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 413TpT-NC3F-ch4r-3xsy-TW10-P3Rr-qT6dm5

“/dev/sdb3” is a new physical volume of “1023.00 MiB”
— NEW Physical volume —
PV Name /dev/sdb3
VG Name
PV Size 1023.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID DDu25l-PBlg-sRJY-qgl1-Io3s-ezmj-KVuZCT

“/dev/sdb2” is a new physical volume of “512.00 MiB”
— NEW Physical volume —
PV Name /dev/sdb2
VG Name
PV Size 512.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0

PV UUID Z5QKKi-RoKG-MZ1b-ed3s-Ibgg-eyAr-PDK0kV

PE(physical extent):物理區域是物理卷中可用于分配的最小存儲單元,物理區域大小在建立卷組時指定,一旦確定不能更改,同一卷組所有物理卷的物理區域大小需一致,新的pv加入到vg后,pe的大小自動更改為vg中定義的pe大小。

LE(logical extent):邏輯區域是邏輯卷中可用于分配的最小存儲單元,邏輯區域的大小取決于邏輯卷所在卷組中的物理區域的大小。
卷組描述區域:卷組描述區域存在于每個物理卷中,用于描述物理卷本身、物理卷所屬卷組、卷組中邏輯卷、邏輯卷中物理區域的分配等所有信息,它是在使用pvcreate建立物理卷時建立的。


3、創建卷組:vg系列命令

[root@localhost ~]# vg
vgcfgbackup vgconvert vgextend vgmknodes vgs
vgcfgrestore vgcreate vgimport vgreduce vgscan
vgchange vgdisplay vgimportclone vgremove vgsplit
vgck vgexport vgmerge vgrename
創建卷組,名字可以隨意起

[root@localhost ~]# vgremove myvg
Volume group “myvg” successfully removed
[root@localhost ~]# vgcreate -s 16M myvg /dev/sdb{1,2,3}
Volume group “myvg” successfully created
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
myvg 3 0 0 wz–n- 1.95g 1.95g
[root@localhost ~]# vgdisplay
— Volume group —
VG Name myvg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 1.95 GiB
PE Size 16.00 MiB
Total PE 125
Alloc PE / Size 0 / 0
Free PE / Size 125 / 1.95 GiB
VG UUID 3Eu9GX-U4ip-mxSF-zibe-7802-8Suh-38b4dG

創建邏輯卷
[root@localhost ~]# lvcreate -L 1.4G -n mylv myvg /dev/sdb{1,3} //-L 指定大小,-n指定名稱
Rounding up size to full physical extent 1.41 GiB
Logical volume “mylv” created.
[root@localhost ~]# lvs //簡單查看信息
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
mylv myvg -wi-a—– 1.41g
[root@localhost ~]# lvdisplay //詳細查看信息
— Logical volume —
LV Path /dev/myvg/mylv
LV Name mylv
VG Name myvg
LV UUID coMhuV-ywOe-FEbm-SkQd-upfQ-0era-cCfqHy
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-05-17 16:30:37 +0800
LV Status available

open 0

LV Size 1.41 GiB
Current LE 90
Segments 2
Allocation inherit
Read ahead sectors auto

  • currently set to 8192
    Block device 253:0

格式化:

[root@localhost ~]# mkfs.ext4 /dev/myvg/mylv
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
92160 inodes, 368640 blocks
18432 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=377487360
12 block groups
32768 blocks per group, 32768 fragments per group
7680 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

3、掛載使用

查看物理位置:

[root@localhost ~]# ll /dev/myvg/mylv
lrwxrwxrwx 1 root root 7 May 17 16:30 /dev/myvg/mylv -> ../dm-0

掛載到目錄并進行讀寫操作:

[root@localhost ~]# mount /dev/myvg/mylv /mnt
[root@localhost ~]# mkdir /mnt/test
[root@localhost ~]# ls /mnt/ > /mnt/test/test.txt
[root@localhost ~]# cat /mnt/test/test.txt
lost+found
test

以上就是“CentOS7下怎么快速創建LVM”這篇文章的所有內容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

原阳县| 五原县| 玛曲县| 平顺县| 临邑县| 陆丰市| 大邑县| 广安市| 永平县| 麻江县| 丹棱县| 全南县| 阜城县| 梁河县| 尉氏县| 涿鹿县| 资中县| 北辰区| 肇庆市| 沙雅县| 马鞍山市| 崇州市| 新巴尔虎左旗| 津南区| 万荣县| 陇西县| 荥经县| 阿克| 龙井市| 福海县| 凤山市| 长岭县| 井研县| 新干县| 平舆县| 宜州市| 东平县| 青州市| 乌兰察布市| 黎城县| 乐平市|