949069-20200416104045527-1858978940.png
查看現(xiàn)有磁盤
[root@ecs-16128 ~]# df -h
文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn)
/dev/vda2 36G 2.2G 34G 7% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 0 63G 0% /dev/shm
tmpfs 63G 8.7M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
tmpfs 13G 0 13G 0% /run/user/0
查看物理磁盤及分區(qū)
[root@ecs-16128 ~]# fdisk -l
磁盤 /dev/vda:42.9 GB, 42949672960 字節(jié),83886080 個(gè)扇區(qū)
Units = 扇區(qū) of 1 * 512 = 512 bytes
扇區(qū)大小(邏輯/物理):512 字節(jié) / 512 字節(jié)
I/O 大小(最小/最佳):512 字節(jié) / 512 字節(jié)
磁盤標(biāo)簽類型:dos
磁盤標(biāo)識(shí)符:0x000ee330
設(shè)備 Boot Start End Blocks Id System
/dev/vda1 2048 8390655 4194304 82 Linux swap / Solaris
/dev/vda2 * 8390656 83886046 37747695+ 83 Linux
磁盤 /dev/vdb:1099.5 GB, 1099511627776 字節(jié)顺呕,2147483648 個(gè)扇區(qū)
Units = 扇區(qū) of 1 * 512 = 512 bytes
扇區(qū)大小(邏輯/物理):512 字節(jié) / 512 字節(jié)
I/O 大小(最小/最佳):512 字節(jié) / 512 字節(jié)
使用fdisk命令重新劃分/dev/cdb
[root@ecs-16128 ~]# fdisk /dev/vdb
歡迎使用 fdisk (util-linux 2.23.2)限煞。
更改將停留在內(nèi)存中团滥,直到您決定將更改寫入磁盤匙握。
使用寫入命令前請(qǐng)三思粒梦。
Device does not contain a recognized partition table
使用磁盤標(biāo)識(shí)符 0x1964a9e4 創(chuàng)建新的 DOS 磁盤標(biāo)簽浩习。
命令(輸入 m 獲取幫助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分區(qū)號(hào) (1-4汽煮,默認(rèn) 1):1
起始 扇區(qū) (2048-2147483647,默認(rèn)為 2048):t
起始 扇區(qū) (2048-2147483647睡毒,默認(rèn)為 2048):
將使用默認(rèn)值 2048
Last 扇區(qū), +扇區(qū) or +size{K,M,G} (2048-2147483647来惧,默認(rèn)為 2147483647):
將使用默認(rèn)值 2147483647
分區(qū) 1 已設(shè)置為 Linux 類型,大小設(shè)為 1024 GiB
命令(輸入 m 獲取幫助):t
已選擇分區(qū) 1
Hex 代碼(輸入 L 列出所有代碼):8e
已將分區(qū)“Linux”的類型更改為“Linux LVM”
命令(輸入 m 獲取幫助):w
The partition table has been altered!
查看結(jié)果
[root@ecs-16128 ~]# fdisk -l
磁盤 /dev/vda:42.9 GB, 42949672960 字節(jié)吕嘀,83886080 個(gè)扇區(qū)
Units = 扇區(qū) of 1 * 512 = 512 bytes
扇區(qū)大小(邏輯/物理):512 字節(jié) / 512 字節(jié)
I/O 大小(最小/最佳):512 字節(jié) / 512 字節(jié)
磁盤標(biāo)簽類型:dos
磁盤標(biāo)識(shí)符:0x000ee330
設(shè)備 Boot Start End Blocks Id System
/dev/vda1 2048 8390655 4194304 82 Linux swap / Solaris
/dev/vda2 * 8390656 83886046 37747695+ 83 Linux
磁盤 /dev/vdb:1099.5 GB, 1099511627776 字節(jié)违寞,2147483648 個(gè)扇區(qū)
Units = 扇區(qū) of 1 * 512 = 512 bytes
扇區(qū)大小(邏輯/物理):512 字節(jié) / 512 字節(jié)
I/O 大小(最小/最佳):512 字節(jié) / 512 字節(jié)
磁盤標(biāo)簽類型:dos
磁盤標(biāo)識(shí)符:0x1964a9e4
設(shè)備 Boot Start End Blocks Id System
/dev/vdb1 2048 2147483647 1073740800 8e Linux LVM
創(chuàng)建新的PV
[root@ecs-16128 /]# pvcreate /dev/vdb
Device /dev/vdb excluded by a filter.
[root@ecs-16128 /]# parted /dev/vdb
GNU Parted 3.1
使用 /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
警告: 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) quit
信息: You may need to update /etc/fstab.
[root@ecs-16128 /]# pvcreate /dev/vdb
WARNING: dos signature detected on /dev/vdb at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/vdb.
Physical volume "/dev/vdb" successfully created.
[root@ecs-16128 /]# pvscan
PV /dev/vdb lvm2 [1.00 TiB]
Total: 1 [1.00 TiB] / in use: 0 [0 ] / in no VG: 1 [1.00 TiB]
[root@ecs-16128 /]# pvdisplay
"/dev/vdb" is a new physical volume of "1.00 TiB"
--- NEW Physical volume ---
PV Name /dev/vdb
VG Name
PV Size 1.00 TiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID dFUFOf-PV64-Q4lQ-9ipY-eCG0-5c36-iGWqfV
創(chuàng)建VG
[root@ecs-16128 /]# vgcreate oracle /dev/vdb
Volume group "oracle" successfully created
[root@ecs-16128 /]# vgs
VG #PV #LV #SN Attr VSize VFree
oracle 1 0 0 wz--n- <1024.00g <1024.00g
[root@ecs-16128 /]# vgdisplay
--- Volume group ---
VG Name oracle
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size <1024.00 GiB
PE Size 4.00 MiB
Total PE 262143
Alloc PE / Size 0 / 0
Free PE / Size 262143 / <1024.00 GiB
VG UUID xtzsCZ-81IQ-PBZf-o462-M1kY-OB5e-0p1n2T
將VG空間分配給LV
[root@ecs-16128 /]# lvcreate -l 100%vg -n oracle oracle
Logical volume "oracle" created.
[root@ecs-16128 /]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
oracle oracle -wi-a----- <1024.00g
[root@ecs-16128 /]# lvdisplay
--- Logical volume ---
LV Path /dev/oracle/oracle
LV Name oracle
VG Name oracle
LV UUID Wi24p2-msTJ-kUoo-rGxM-gHiR-MLnY-Z4ffPy
LV Write Access read/write
LV Creation host, time ecs-16128.novalocal, 2020-09-25 13:40:23 +0800
LV Status available
# open 0
LV Size <1024.00 GiB
Current LE 262143
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:0
格式化分區(qū)
[root@ecs-16128 /]# mkfs.ext4 /dev/oracle/oracle
mke2fs 1.42.9 (28-Dec-2013)
文件系統(tǒng)標(biāo)簽=
OS type: Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
67108864 inodes, 268434432 blocks
13421721 blocks (5.00%) reserved for the super user
第一個(gè)數(shù)據(jù)塊=0
Maximum filesystem blocks=2415919104
8192 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: 完成
正在寫入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
掛載分區(qū)
[root@ecs-16128 /]# mount /dev/oracle/oracle /data
[root@ecs-16128 /]# df -h
文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn)
/dev/vda2 36G 2.2G 34G 7% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 0 63G 0% /dev/shm
tmpfs 63G 8.7M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
tmpfs 13G 0 13G 0% /run/user/0
/dev/mapper/oracle-oracle 1008G 77M 957G 1% /data
將新加分區(qū)信息寫入fstab,否則重啟后需要重新掛載
[root@ecs-16128 /]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu May 9 01:56:05 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=a83f4fdc-2ea1-4fec-a1e2-a42016ce0afe / xfs defaults 0 0
UUID=9e33bd6f-c68c-41c7-95c8-703f4fe8c3d4 swap swap defaults 0 0
[root@ecs-16128 /]# blkid /dev/oracle/oracle
/dev/oracle/oracle: UUID="0f541e0c-f50e-4412-9bad-0c316e6aa008" TYPE="ext4"
[root@ecs-16128 /]# vi /etc/fstab