others linux服务器运维 django3 监控 k8s golang 数据库 大数据 前端 devops 理论基础 java oracle 运维日志

fdisk分区、创建 lvm

访问量:1277 创建时间:2021-02-03

fdisk分区

[root@yonghongbi-0002 ~]# fdisk /dev/vdb 
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
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): n
Partition number (1-128, default 1): 
First sector (34-4294967262, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-4294967262, default 4294967262): 
Created partition 1


Command (m for help): w
The partition table has been altered!

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

parted分区(2T以上磁盘)

[root@yonghongbi-0002 ~]# parted /dev/vdb 
GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
Warning: The existing disk label on /dev/vdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes                                                               
(parted) p                                                                
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
Number  Start  End  Size  File system  Name  Flags
###全部空间创建一个分区
(parted) mkpart  primary  0  -1                                           
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i                                                          
(parted) p                                                                
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  2199GB  2199GB               primary
(parted) quit
Information: You may need to update /etc/fstab.

创建lvm(裸设备如果无其他用途,可以不分区直接创建pv ,例如pvcreate /dev/vdb)

[root@yonghongbi-0002 ~]# yum -y install lvm2
#创建物理卷
[root@yonghongbi-0002 ~]# pvcreate /dev/vdb1 
  Physical volume "/dev/vdb1" successfully created.
#创建卷组
[root@yonghongbi-0002 ~]# vgcreate vgdisk /dev/vdb1 
  Volume group "vgdisk" successfully created
# 将vgdisk所有空间创建lv,名字lvdisk
[root@yonghongbi-0002 ~]# lvcreate -l 100%FREE -n lvdisk  vgdisk
  Logical volume "lvdisk" created.
[root@yonghongbi-0002 ~]# lvs
  LV     VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvdisk vgdisk -wi-a----- <2.00t
#格式化
[root@yonghongbi-0002 ~]# mkfs.xfs /dev/vgdisk/lvdisk 
[root@yonghongbi-0002 ~]# mount /dev/vgdisk/lvdisk /yh
#配置开机挂载
[root@yonghongbi-0002 ~]# vim /etc/fstab 
UUID=d9a55f09-b12e-41c3-8e8b-267c46b68cfb /                       ext4    defaults        1 1
/dev/vgdisk/lvdisk /yh xfs defaults 0 0
登陆评论: 使用GITHUB登陆