linux 创建逻辑卷
创建分区
[root@localhost lohr]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0xa7a34d5d 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):m
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition
's system idu change display/entry units
v verify the partition table
wwrite table to disk and exit
x extra functionality (experts only)
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4free)
e extended
Select (default p): p
分区号 (1-4,默认 1):
起始 扇区 (2048-10485759,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-10485759,默认为 10485759):+5G
值超出范围。
Last 扇区, +扇区 or +size{K,M,G} (2048-10485759,默认为 10485759):+4G
分区 1 已设置为 Linux 类型,大小设为 4 GiB
命令(输入 m 获取帮助):T
已选择分区 1
Hex 代码(输入 L 列出所有代码):L
0 空 24 NEC DOS 81 Minix / 旧 Linu bf Solaris
1 FAT12 27 隐藏的 NTFS Win 82 Linux 交换 / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 983 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 隐藏的 C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 8028685 Linux 扩展 c7 Syrinx
5 扩展 41 PPC PReP Boot 86 NTFS 卷集 da 非文件系统数据
6 FAT16 42 SFS 87 NTFS 卷集 db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux 纯文本 de Dell 工具
8 AIX 4e QNX4.x 第2部分 8e Linux LVM df BootIt
9 AIX 可启动 4f QNX4.x 第3部分 93 Amoeba e1 DOS 访问
a OS/2 启动管理器 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad 休 eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 扩展 (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC
11 隐藏的 FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq 诊断 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 隐藏的 FAT16 <361 SpeedStor ab Darwin 启动 f2 DOS 次要
16 隐藏的 FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 隐藏的 HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST 智能睡眠 65 Novell Netware b8 BSDI swap fd Linux raid 自动
1b 隐藏的 W95 FAT3 70 DiskSecure 多启 bb Boot Wizard 隐 fe LANstep
1c 隐藏的 W95 FAT3 75 PC/IX be Solaris 启动 ff BBT
1e 隐藏的 W95 FAT1 80 旧 Minix
Hex 代码(输入 L 列出所有代码):8e
已将分区“Linux”的类型更改为“Linux LVM”
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
向内核注册分区
[root@localhost lohr]# partprobe /dev/sdb
创建物理卷
[root@localhost lohr]# pvcreate /dev/sdbPhysical volume
"/dev/sdb" successfully created.
创建卷组
[root@localhost lohr]# vgcreate thomas /dev/sdbVolume group
"thomas" successfully created
创建逻辑卷
[root@localhost lohr]# lvcreate -n thomas-lv -L 1G thomasLogical volume
"thomas-lv" created.
创建文件系统
[root@localhost lohr]# mkfs.ext4 /dev/thomas/thomas-lvmke2fs
1.42.9 (28-Dec-2013)文件系统标签
=OS type: Linux
块大小
=4096 (log=2)分块大小
=4096 (log=2)Stride
=0 blocks, Stripe width=0 blocks65536 inodes, 262144 blocks13107 blocks (5.00%) reserved for the super user第一个数据块
=0Maximum filesystem blocks
=2684354568 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
挂载
[root@localhost lohr]# vi /etc/fstab#
#
/etc/fstab# Created by anaconda on Sun Jun
711:20:492020#
# Accessible filesystems, by reference, are maintained under
'/dev/disk'# See
man pages fstab(5), findfs(8), mount(8) and/or blkid(8) formoreinfo#
.host:
/VMShare /mnt/hgfs fuse.vmhgfs-fuse allow_other,defaults 00/dev/mapper/centos-root / xfs defaults 00
UUID=4cd669bd-4db1-49d9-afb6-245b36db7470 /boot xfs defaults 00
/dev/mapper/centos-swap swap swap defaults 00
/dev/thomas/lv-thomas /mnt/lv-thomas ext4 defaults 00 #添加
mount -a
挂载成功
查看物理卷
[root@localhost lohr]# pvdisplay--- Physical volume ---PV Name
/dev/sdbVG Name thomas
PV Size
5.00 GiB / not usable 4.00 MiBAllocatable yes
PE Size
4.00 MiBTotal PE
1279Free PE
1023Allocated PE
256PV UUID pVLZ0a
-1DmV-13SP-8Keq-GaW0-5gdP-PmosB2
查看卷组信息
[root@localhost lohr]# vgdisplay--- Volume group ---VG Name thomas
System ID
Format lvm2
Metadata Areas
1Metadata Sequence No
2VG Access read
/writeVG Status resizable
MAX LV
0Cur LV
1Open LV
1Max PV
0Cur PV
1Act PV
1VG Size
<5.00 GiBPE Size
4.00 MiBTotal PE
1279Alloc PE
/ Size 256 / 1.00 GiBFree PE
/ Size 1023 / <4.00 GiBVG UUID gSH0Zs
-rC1U-D8PY-WaE1-nzGI-t3Jh-Xj8VXo
查看逻辑卷
[root@localhost lohr]# lvdisplay--- Logical volume ---LV Path
/dev/thomas/thomas-lvLV Name thomas
-lvVG Name thomas
LV UUID 4enjau
-4c83-tFX1-xvw5-vrMv-fsv3-S3xhNdLV Write Access read
/writeLV Creation host,
time localhost, 2020-08-0910:06:52 -0400LV Status available
# open
1LV Size
1.00 GiBCurrent LE
256Segments
1Allocation inherit
Read ahead sectors auto
- currently set to 8192Block device
253:2
以上是 linux 创建逻辑卷 的全部内容, 来源链接: utcz.com/a/54514.html