fdisk -l 查看硬盘信息
[root@PPlive-RHEL73 ~]# fdisk -l
Disk /dev/sda: 146.8 GB, 146815733760 bytes, 286749480 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: 0x00033e86
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 105883647 52428800 83 Linux
/dev/sda3 105883648 110077951 2097152 82 Linux swap / Solaris
/dev/sda4 110077952 286748671 88335360 5 Extended
/dev/sda5 110080000 151039999 20480000 83 Linux
/dev/sda6 151042048 286748671 67853312 83 Linux
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x0005fe17
Device Boot Start End Blocks Id System
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x000069e5
Device Boot Start End Blocks Id System
Disk /dev/sde: 2000.4 GB, 2000398934016 bytes, 3907029168 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/sdm: 2000.4 GB, 2000398934016 bytes, 3907029168 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/sdj: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x0002bd26
Device Boot Start End Blocks Id System
Disk /dev/sdb: 146.8 GB, 146815733760 bytes, 286749480 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: 0x000941cb
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 411647 204800 83 Linux
/dev/sdb2 411648 105269247 52428800 83 Linux
/dev/sdb3 105269248 109463551 2097152 82 Linux swap / Solaris
/dev/sdb4 109463552 285474815 88005632 83 Linux
Disk /dev/sdh: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x00042864
Device Boot Start End Blocks Id System
Disk /dev/sdk: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x000c5379
Device Boot Start End Blocks Id System
Disk /dev/sdg: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x000c7542
Device Boot Start End Blocks Id System
Disk /dev/sdl: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x00041060
Device Boot Start End Blocks Id System
Disk /dev/sdi: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x000ebe0f
Device Boot Start End Blocks Id System
Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x0000008b
Device Boot Start End Blocks Id System
Disk /dev/sdn: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x00095be7
所以可以看到一共挂了12块硬盘,如下
/dev/sdc
/dev/sdd
/dev/sde
/dev/sdf
/dev/sdg
/dev/sdh
/dev/sdi
/dev/sdj
/dev/sdk
/dev/sdl
/dev/sdm
/dev/sdn
这会可以通过 cat /proc/partitions 或者 lsblk 或者 blkid 查看12块硬盘状态是否正常,比如使用lsblk
sdc 8:32 0 1.8T 0 disk
└─sdc1 8:33 0 1.8T 0 part
sdd 8:48 0 1.8T 0 disk
└─sdd1 8:49 0 1.8T 0 part
sde 8:64 0 1.8T 0 disk
└─sde1 8:65 0 1.8T 0 part
sdf 8:80 0 1.8T 0 disk
└─sdf1 8:81 0 1.8T 0 part
sdg 8:96 0 1.8T 0 disk
└─sdg1 8:97 0 1.8T 0 part
sdh 8:112 0 1.8T 0 disk
└─sdh1 8:113 0 1.8T 0 part
sdi 8:128 0 1.8T 0 disk
└─sdi1 8:129 0 1.8T 0 part
sdj 8:144 0 1.8T 0 disk
└─sdj1 8:145 0 1.8T 0 part
sdk 8:160 0 1.8T 0 disk
└─sdk1 8:161 0 1.8T 0 part
sdl 8:176 0 1.8T 0 disk
└─sdl1 8:177 0 1.8T 0 part
sdm 8:192 0 1.8T 0 disk
└─sdm1 8:193 0 1.8T 0 part
sdn 8:208 0 1.8T 0 disk
└─sdn1 8:209 0 1.8T 0 part
接下来进行 pvcreate 操作
在这里遇到了一个坑,pvcreate /dev/sdc1 的时候报错
Can‘t open /dev/sdc1 exclusively. Mounted filesystem?
通过mount看没有加载, dmsetup status 查看也没有被占用(如果发现占用,再去remove,具体方法搜索)
最后无奈reboot,成功!
pvcreate /dev/sdc1
pvcreate /dev/sdd1
.....
....
pvcreate /dev/sdn1
创建卷组
创建卷组的命令为vgcreate;用此命令将使用pvcreate建立的物理卷创建为一个完整的卷组;
将物理卷/dev/sdc1创建为一个名为vgmysql的卷组:
[root@MYSQL-SERVER ~]# vgcreate vgmysql /dev/sdb1
Volume group "vgmysql" successfully created
添加新的物理卷到卷组中
此步即为将2块磁盘空间合二为一的关键步骤;当系统中新增了磁盘或新建了物理卷,而要将其添加到已有卷组时,就可使用vgextend命令;
将物理卷/dev/sdc1添加到vgmysql卷组中:
[root@MYSQL-SERVER ~]# vgextend vgmysql /dev/sdc1
Volume group "vgmysql" successfully extended
查看卷组
查看卷组用vgs:
[root@MYSQL-SERVER ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vgmysql 2 0 0 wz--n- 32.74t 32.74t
vgroot 1 4 0 wz--n- 264.00g 4.00m
从vgs命令的回显结果来看,卷组vgmysql成功添加,并且其总空间为两块物理磁盘的总大小(因换算单位不同,所以不是精确的38T)。
创建逻辑卷
创建逻辑卷的命令为lvcreate;用此命令将在使用vgcreate建立的卷组上创建逻辑卷;
在卷组vgmysql上创建一个名为lvmysql的逻辑卷,起大小为32.7T;
- -n:指定逻辑卷名
- -L:指定逻辑卷大小
[root@MYSQL-SERVER ~]# lvcreate -L 32.7T -n lvmysql vgmysql
Rounding up size to full physical extent 32.70 TiB
Logical volume "lvmysql" created.
格式化逻辑卷
将创建的lvmysql逻辑卷格式化为xfs
[root@MYSQL-SERVER ~]# mkfs -t xfs /dev/vgmysql/lvmysql
meta-data=/dev/vgmysql/lvmysql isize=512 agcount=33, agsize=268435328 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0, reflink=0
data = bsize=4096 blocks=8777839616, imaxpct=5
= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=521728, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
创建挂载目录并挂载
- 创建挂载目录/mysql_data
[root@MYSQL-SERVER ~]# mkdir /mysql_data
- 挂载
[root@MYSQL-SERVER ~]# mount /dev/vgmysql/lvmysql /mysql_data/
- 做开机自动挂载
vi /etc/fstab
/dev/mapper/vgmysql-lvmysql /mysql_data xfs defaults 0 0
查看是否挂载成功
[root@MYSQL-SERVER ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vgroot-lv_root 40G 1.8G 36G 5% /devtmpfs 126G 0 126G 0% /devtmpfs 126G 0 126G 0% /dev/shmtmpfs 126G 1.1M 126G 1% /runtmpfs 126G 0 126G 0% /sys/fs/cgroup/dev/sda1 976M 197M 713M 22% /boot/dev/mapper/vgroot-lv_var 59G 197M 56G 1% /var/dev/mapper/vgroot-lv_home 99G 5.6G 88G 6% /hometmpfs 26G 0 26G 0% /run/user/0/dev/mapper/vgmysql-lvmysql 33T 34M 33T 1% /mysql_data
[root@MYSQL-SERVER ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 446.1G 0 disk
├─sda1 8:1 0 1G 0 part /boot├─sda2 8:2 0 264G 0 part
│ ├─vgroot-lv_root 253:0 0 40G 0 lvm /│ ├─vgroot-lv_swap 253:1 0 64G 0 lvm [SWAP]
│ ├─vgroot-lv_var 253:2 0 60G 0 lvm /var│ └─vgroot-lv_home 253:3 0 100G 0 lvm /home└─sda3 8:3 0 64M 0 part
sdb 8:16 0 16.4T 0 disk
└─sdb1 8:17 0 16.4T 0 part
└─vgmysql-lvmysql 253:4 0 32.7T 0 lvm /mysql_datasdc 8:32 0 16.4T 0 disk
└─sdc1 8:33 0 16.4T 0 part
└─vgmysql-lvmysql 253:4 0 32.7T 0 lvm /mysql_datanvme0n1 259:0 0 1.5T 0 disk
[root@MYSQL-SERVER ~]# blkid /dev/sda1: UUID="5a350fc9-d3d2-44c7-9574-30bf9a9dd0d3" TYPE="ext4"
/dev/sda2: UUID="Sum0Mm-6ShR-6ajh-cYQO-091c-r7QI-zfbDpm" TYPE="LVM2_member"
/dev/sda3: UUID="2019-05-24-11-39-22-00" LABEL="config-2" TYPE="iso9660"
/dev/mapper/vgroot-lv_root: UUID="df07731a-5e56-4cc3-95ab-b723b5979332" TYPE="ext4"
/dev/mapper/vgroot-lv_swap: UUID="7b5cd64d-d316-430d-8a83-aca89c4708d2" TYPE="swap"
/dev/mapper/vgroot-lv_var: UUID="025cb128-de8f-4bca-8206-5c1601e79715" TYPE="ext4"
/dev/mapper/vgroot-lv_home: UUID="7bd155b6-9200-442a-a61a-32076c0e4b7e" TYPE="ext4"
/dev/sdc1: UUID="rWbWuV-nt59-ba72-VJrL-RTM2-EJJt-VVkhZF" TYPE="LVM2_member" PARTLABEL="sdc1" PARTUUID="355eb343-f2c9-4f13-9477-52b0fb267d5f"
/dev/sdb1: UUID="yfQk1G-nlN8-OOYu-nptl-cg2d-rD0L-uBFnhW" TYPE="LVM2_member" PARTLABEL="sdb1" PARTUUID="19db36ba-ec9c-4f35-9b29-b7bd2155f0dd"
/dev/mapper/vgmysql-lvmysql: UUID="67cda45d-4282-4346-8be1-e4ec375c2892" TYPE="xfs"
[root@MYSQL-SERVER ~]# tail -1 /etc/fstab /dev/mapper/vgmysql-lvmysql /mysql_data xfs defaults 0 0
标签:12,Disk,sectors,bytes,dev,挂载,512,硬盘,size
From: https://www.cnblogs.com/netstat/p/18075696