创建逻辑卷

准备素材:centos7
1、新增一块新硬盘,sdb 20G, 不必reboot,直接可以“ echo ‘- - -‘ > /sys/class/scsi_host/host0/scan ”扫描即可出现。
[[email protected] ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 50G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 10G 0 part /data
sdb 8:16 0 20G 0 disk
sr0 11:0 1 10G 0 rom
2、现在我们想把/home独立出来,放在新硬盘中,
[[email protected] ~]# ls /home
wang
[[email protected] ~]# fdisk /dev/sda 先将sda再分出一个分区:
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/sda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000d72bb

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 106956799 52428800 83 Linux
/dev/sda3 106956800 111151103 2097152 82 Linux swap / Solaris
/dev/sda4 111151104 419430399 154139648 5 Extended
/dev/sda5 111153152 132124671 10485760 83 Linux

Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (132126720-419430399, default 132126720):
Using default value 132126720
Last sector, +sectors or +size{K,M,G} (132126720-419430399, default 419430399): +1G
Partition 6 of type Linux and of size 1 GiB is set

Command (m for help): P

Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000d72bb

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 106956799 52428800 83 Linux
/dev/sda3 106956800 111151103 2097152 82 Linux swap / Solaris
/dev/sda4 111151104 419430399 154139648 5 Extended
/dev/sda5 111153152 132124671 10485760 83 Linux
/dev/sda6 132126720 134223871 1048576 83 Linux

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
此处出现警报,是因为没有同步,
3、[[email protected] ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[[email protected] ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 50G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 512B 0 part
├─sda5 8:5 0 10G 0 part /data
└─sda6 8:6 0 1G 0 part
sdb 8:16 0 20G 0 disk
sr0 11:0 1 10G 0 rom /mnt
此时,sda6已被创建。
我们想要将/home独立出去,要在新分区中创建文件系统:
4、[[email protected] ~]# mkfs.xfs /dev/sda6
meta-data=/dev/sda6 isize=512 agcount=4, agsize=65536 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=262144, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[[email protected] ~]# blkid
/dev/sda2: UUID="4f823650-e522-46fa-9904-c1e7476f89ad" TYPE="xfs"
/dev/sr0: UUID="2018-11-26-14-22-58-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sda1: UUID="bfb9c261-33b4-4602-91ea-a71995a8ef96" TYPE="xfs"
/dev/sda3: UUID="8cc37a26-d321-4331-a020-05f3a08af552" TYPE="swap"
/dev/sda5: UUID="0f16b61c-d601-4783-8e3d-0a6452aad27d" TYPE="xfs"
/dev/sda6: UUID="d52cade8-fb69-447c-b236-f004ab27112f" TYPE="xfs"
5、将分区先挂载,/home下文件拷贝到/mnt下,
[[email protected] ~]# mount /dev/sda6 /mnt
[[email protected] ~]# ls /mnt
[[email protected] ~]# ls /home
wang
[[email protected] ~]# cp -a /home/* /mnt/
[[email protected] ~]# ll /mnt
total 0
drwx------. 3 wang wang 78 Apr 11 2018 wang
6、将/dev/sda6挂载到/home中,所以修改/etc/fstab文件:

[[email protected] ~]# vim /etc/fstab

/dev/sda6: UUID="d52cade8-fb69-447c-b236-f004ab27112f" TYPE="xfs"

/etc/fstab

Created by anaconda on Thu Jan 3 22:00:10 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=4f823650-e522-46fa-9904-c1e7476f89ad / xfs defaults 0 0
UUID=bfb9c261-33b4-4602-91ea-a71995a8ef96 /boot xfs defaults 0 0
UUID=0f16b61c-d601-4783-8e3d-0a6452aad27d /data xfs defaults 0 0
UUID=8cc37a26-d321-4331-a020-05f3a08af552 swap swap defaults 0 0
UUID=d52cade8-fb69-447c-b236-f004ab27112f /home xfs defaualt 0 0
将UUID=d52cade8-fb69-447c-b236-f004ab27112f /home xfs defaualt 0 添加其中。
7、[[email protected] ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 52403200 4171040 48232160 8% /
devtmpfs 915824 0 915824 0% /dev
tmpfs 931624 0 931624 0% /dev/shm
tmpfs 931624 10452 921172 2% /run
tmpfs 931624 0 931624 0% /sys/fs/cgroup
/dev/sda5 10475520 33012 10442508 1% /data
/dev/sda1 1038336 177912 860424 18% /boot
tmpfs 186328 12 186316 1% /run/user/42
tmpfs 186328 0 186328 0% /run/user/0
/dev/sr0 10491772 10491772 0 100% /mnt
/dev/sda6 1038336 33100 1005236 4% /home
8、用其他用户登录查看
[[email protected] ~]# su - wang
[[email protected] ~]$ pwd
/home/wang
[[email protected] ~]$ ls -a
. .bash_logout .bashrc .config
.. .bash_profile .cache .mozilla
[[email protected] ~]$ exit
logout
原数据还在,所以很成功。
9、现在,我们创建逻辑卷,它的突出优势就是可以变大变小。
A、首先,为了方便做实验,我们新增一块2G的新硬盘sdc。
[[email protected] ~]# echo ‘- - -‘ > /sys/class/scsi_host/host0/scan
[[email protected] ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 50G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 512B 0 part
├─sda5 8:5 0 10G 0 part /data
└─sda6 8:6 0 1G 0 part /home
sdb 8:16 0 20G 0 disk
sdc 8:32 0 2G 0 disk
sr0 11:0 1 10G 0 rom /mnt
B、我们在新硬盘上做分区,并修改名称为“ 8e ”:
[[email protected] ~]# 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.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x2889f07c.

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):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1G
Partition 1 of type Linux and of size 1 GiB is set

Command (m for help): P

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x2889f07c

Device Boot Start End Blocks Id System
/dev/sdb1 2048 2099199 1048576 83 Linux

Command (m for help): T
Selected partition 1
Hex code (type L to list all codes): L

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 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 hi eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext‘d (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
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: 21.5 GB, 21474836480 bytes, 41943040 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: 0x2889f07c

Device Boot Start End Blocks Id System
/dev/sdb1 2048 2099199 1048576 8e Linux LVM

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

Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 50G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 512B 0 part
├─sda5 8:5 0 10G 0 part /data
└─sda6 8:6 0 1G 0 part /home
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 1G 0 part
sdc 8:32 0 2G 0 disk
sr0 11:0 1 10G 0 rom /mnt
因为是干净硬盘,所以不需同步。
C、我们把sdb1和sdc组合在一起做逻辑卷。
[[email protected] ~]# pvs
[[email protected] ~]# pvcreate /dev/sd{b1,c}
Physical volume "/dev/sdb1" successfully created.
Physical volume "/dev/sdc" successfully created.
[[email protected] ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 --- 1.00g 1.00g
/dev/sdc lvm2 --- 2.00g 2.00g
[[email protected] ~]# pvdisplay
"/dev/sdc" is a new physical volume of "2.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc
VG Name
PV Size 2.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID ht6mmd-jV04-acuk-4Ez7-9VZP-Pdho-dfTz5h

"/dev/sdb1" is a new physical volume of "1.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 1.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 2HmtlV-G0kb-YkqG-zU0A-Zh6U-SIKC-k4zrbL
“ pvdisplay ”可看到更详细信息。
D、我们将sdb1分区和sdc硬盘一起添加在一个vg name中,
[[email protected] ~]# vgcreate -s 16M vg0 /dev/sd{b1,c}
Volume group "vg0" successfully created
[[email protected] ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg0
PV Size 1.00 GiB / not usable 16.00 MiB
Allocatable yes
PE Size 16.00 MiB
Total PE 63
Free PE 63
Allocated PE 0
PV UUID 2HmtlV-G0kb-YkqG-zU0A-Zh6U-SIKC-k4zrbL

--- Physical volume ---
PV Name /dev/sdc
VG Name vg0
PV Size 2.00 GiB / not usable 16.00 MiB
Allocatable yes
PE Size 16.00 MiB
Total PE 127
Free PE 127
Allocated PE 0
PV UUID ht6mmd-jV04-acuk-4Ez7-9VZP-Pdho-dfTz5h

[[email protected] ~]# blkid
/dev/sda2: UUID="4f823650-e522-46fa-9904-c1e7476f89ad" TYPE="xfs"
/dev/sr0: UUID="2018-11-26-14-22-58-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sda1: UUID="bfb9c261-33b4-4602-91ea-a71995a8ef96" TYPE="xfs"
/dev/sda3: UUID="8cc37a26-d321-4331-a020-05f3a08af552" TYPE="swap"
/dev/sda5: UUID="0f16b61c-d601-4783-8e3d-0a6452aad27d" TYPE="xfs"
/dev/sda6: UUID="d52cade8-fb69-447c-b236-f004ab27112f" TYPE="xfs"
/dev/sdb1: UUID="2HmtlV-G0kb-YkqG-zU0A-Zh6U-SIKC-k4zrbL" TYPE="LVM2_member"
/dev/sdc: UUID="ht6mmd-jV04-acuk-4Ez7-9VZP-Pdho-dfTz5h" TYPE="LVM2_member"
[[email protected] ~]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size <2.97 GiB
PE Size 16.00 MiB
Total PE 190
Alloc PE / Size 0 / 0
Free PE / Size 190 / <2.97 GiB
VG UUID qOMCgY-yImZ-18AI-qJFH-Mueb-3FzP-TEE0Kh
此时,物理卷已经变成了卷组,我们可以在上表中看到非常详细地信息。
E、创建逻辑卷,LV Name为mysql,VG Name为vg0
[[email protected] ~]# lvs
[[email protected] ~]# lvcreate -n mysql -l 100%FREE vg0
Logical volume "mysql" created.
注:lvcreate -n mysql -l :-l 后跟PE的个数,-L后跟容量x.G大小。
[[email protected] ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vg0/mysql
LV Name mysql
VG Name vg0
LV UUID meorkL-K7yM-2PlH-4Ovx-JjnW-sb2I-8ubEU5
LV Write Access read/write
LV Creation host, time centos7, 2019-02-11 18:06:31 +0800
LV Status available

open 0

LV Size <2.97 GiB
Current LE 190
Segments 2
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 253:0
    以上是详细信息。
    F、接着,我们创建文件系统:
    [[email protected] ~]# mkfs.xfs /dev/vg0/mysql
    meta-data=/dev/vg0/mysql isize=512 agcount=4, agsize=194560 blks
    = sectsz=512 attr=2, projid32bit=1
    = crc=1 finobt=0, sparse=0
    data = bsize=4096 blocks=778240, imaxpct=25
    = sunit=0 swidth=0 blks
    naming =version 2 bsize=4096 ascii-ci=0 ftype=1
    log =internal log bsize=4096 blocks=2560, version=2
    = sectsz=512 sunit=0 blks, lazy-count=1
    realtime =none extsz=4096 blocks=0, rtextents=0
    [[email protected] ~]# blkid
    /dev/sda2: UUID="4f823650-e522-46fa-9904-c1e7476f89ad" TYPE="xfs"
    /dev/sr0: UUID="2018-11-26-14-22-58-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
    /dev/sda1: UUID="bfb9c261-33b4-4602-91ea-a71995a8ef96" TYPE="xfs"
    /dev/sda3: UUID="8cc37a26-d321-4331-a020-05f3a08af552" TYPE="swap"
    /dev/sda5: UUID="0f16b61c-d601-4783-8e3d-0a6452aad27d" TYPE="xfs"
    /dev/sda6: UUID="d52cade8-fb69-447c-b236-f004ab27112f" TYPE="xfs"
    /dev/sdb1: UUID="2HmtlV-G0kb-YkqG-zU0A-Zh6U-SIKC-k4zrbL" TYPE="LVM2_member"
    /dev/sdc: UUID="ht6mmd-jV04-acuk-4Ez7-9VZP-Pdho-dfTz5h" TYPE="LVM2_member"
    /dev/mapper/vg0-mysql: UUID="4f9e419d-8959-4f18-b24e-1ed7847021cf" TYPE="xfs"
    我们并没有给sdb1和sdc创建文件系统,而是对逻辑卷创建的文件系统。
    [[email protected] ~]# vim /etc/fstab
    /dev/sda6: UUID="d52cade8-fb69-447c-b236-f004ab27112f" TYPE="xfs"
    #

    /etc/fstab

    Created by anaconda on Thu Jan 3 22:00:10 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=4f823650-e522-46fa-9904-c1e7476f89ad / xfs defaults 0 0
    UUID=bfb9c261-33b4-4602-91ea-a71995a8ef96 /boot xfs defaults 0 0
    UUID=0f16b61c-d601-4783-8e3d-0a6452aad27d /data xfs defaults 0 0
    UUID=8cc37a26-d321-4331-a020-05f3a08af552 swap swap defaults 0 0
    UUID=d52cade8-fb69-447c-b236-f004ab27112f /home xfs defaualt 0 0
    UUID=4f9e419d-8959-4f18-b24e-1ed7847021cf /data/mysql xfs defaults0 0
    我们将UUID=4f9e419d-8959-4f18-b24e-1ed7847021cf /data/mysql xfs defaults0 0 填入。
    [[email protected] ~]# df
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/sda2 52403200 4170528 48232672 8% /
    devtmpfs 915824 0 915824 0% /dev
    tmpfs 931624 0 931624 0% /dev/shm
    tmpfs 931624 10464 921160 2% /run
    tmpfs 931624 0 931624 0% /sys/fs/cgroup
    /dev/sda5 10475520 33012 10442508 1% /data
    /dev/sda1 1038336 177912 860424 18% /boot
    tmpfs 186328 12 186316 1% /run/user/42
    tmpfs 186328 0 186328 0% /run/user/0
    /dev/sr0 10491772 10491772 0 100% /mnt
    /dev/sda6 1038336 33108 1005228 4% /home
    /dev/mapper/vg0-mysql 3102720 32992 3069728 2% /data/mysql 此处已生效。
    G、使用逻辑卷读写文件
    [[email protected] ~]# cd /data/mysql/
    [[email protected] /data/mysql]# ls
    [[email protected] /data/mysql]# dd if=/dev/zero of=f1 bs=1M count=1024
    1024+0 records in
    1024+0 records out
    1073741824 bytes (1.1 GB) copied, 2.16338 s, 496 MB/s
    H、查看逻辑卷的各功能的工作情况
    [[email protected] /data/mysql]# pvdisplay
    --- Physical volume ---
    PV Name /dev/sdb1
    VG Name vg0
    PV Size 1.00 GiB / not usable 16.00 MiB
    Allocatable yes (but full)
    PE Size 16.00 MiB
    Total PE 63
    Free PE 0
    Allocated PE 63
    PV UUID 2HmtlV-G0kb-YkqG-zU0A-Zh6U-SIKC-k4zrbL

    --- Physical volume ---
    PV Name /dev/sdc
    VG Name vg0
    PV Size 2.00 GiB / not usable 16.00 MiB
    Allocatable yes (but full)
    PE Size 16.00 MiB
    Total PE 127
    Free PE 0
    Allocated PE 127
    PV UUID ht6mmd-jV04-acuk-4Ez7-9VZP-Pdho-dfTz5h

[[email protected] /data/mysql]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 52403200 4171056 48232144 8% /
devtmpfs 915824 0 915824 0% /dev
tmpfs 931624 0 931624 0% /dev/shm
tmpfs 931624 10464 921160 2% /run
tmpfs 931624 0 931624 0% /sys/fs/cgroup
/dev/sda5 10475520 33012 10442508 1% /data
/dev/sda1 1038336 177912 860424 18% /boot
tmpfs 186328 12 186316 1% /run/user/42
tmpfs 186328 0 186328 0% /run/user/0
/dev/sr0 10491772 10491772 0 100% /mnt
/dev/sda6 1038336 33108 1005228 4% /home
/dev/mapper/vg0-mysql 3102720 1081568 2021152 35% /data/mysql
至此,我们的逻辑卷创建就圆满结束。
总结:1、pvcreate /dev/sd{b1,c}
2、vgcreate -s 16M vg0 /dev/sd{b1,c}
3、lvcreate -n mysql -l 100%FREE vg0
4、mkfs.xfs /dev/vg0/mysql 格式化文件系统
5、mount /dev/vg0/mysql /data/mysql 挂载文件

原文地址:http://blog.51cto.com/14128387/2349260

时间: 2024-10-10 06:29:52

创建逻辑卷的相关文章

Linux下创建逻辑卷和增大逻辑卷的方法

第一步 给硬盘分区       fdisk /dev/sdb 第二步 修改硬盘的ID号为8e id默认为83       fdisk /dev/sdb       按t进入       输入分区表号       输入8e 第三步  创建pv 物理卷        pvcreate /dev/sdb1 查看pv  pvdisplay 第四步  创建vg 卷组        vgcreate 卷组的名字 /dev/sdb1 查看vg 卷组 vgdisplay 第五步  扩容卷组        先将分

17.文件系统——逻辑卷、快照以及如何创建逻辑卷(pv、vg、lv)

一.逻辑卷管理器LVM概述 前面我们在Linux系统上模拟软RAID,使用的是md模块,事实上,还有一个模块dm--device mapper,也可以实现软RAID的模拟.md模块的管理工具是mdadm,它专门用来管理RAID设备:dm模块则更为强大,它的管理工具不再是一个单一的工具,而是一组工具,根据不同的规则进行管理(如物理卷的创建.删除.修改:卷组的大小调整.扫描.显示等:逻辑卷的创建.删除和修改等),为dm提供设备映射法则:它支持将多个物理设备以多种不同的方式组合起来,其中包含但不仅限于

vmware上给根分区增加空间以及创建逻辑卷

1.在vmware上给根分区增加空间 509  cd /sys/class/scsi_host/ 查看添加的硬盘信息是否在系统中 521  echo "- - -" > /sys/class/scsi_host/host0/scan加载硬盘信息 522  echo "- - -" > /sys/class/scsi_host/host1/scan 523  echo "- - -" > /sys/class/scsi_host/

在VMware中的linux系统中创建逻辑卷

1.用poweroff将虚拟机关机. 2.给linux虚拟机添加4块1G的硬盘.开机后可用lsblk查看.fdisk -l 也可以. 3.开启linux虚拟机,将4块1G的硬盘做LVM逻辑卷管理. 步骤如下: a:将sdb.sdc.sdd.sde各分一个主分区,使用所有剩余空间. 用lsblk查看所有的硬盘块设备 b:将sdb1.sdc1.sdd1分区创建成一个名称为vg0的卷组. c:将sde1加入到vg0卷组中,然后将sdc1从vg0卷组中删除. d:在vg0卷组中创建一个容量为2G的名称为

RHCE7.0答案之创建逻辑卷

创建逻辑卷配置: fdisk /dev/vdb  n,e,+200M,t,8e,p,w partprobe; ll /devvdb* pvcreate /dev/vdb5; pvscan vgcreate -s 16M datastore /dev/vdb5 vgdisplay lvcreate -l 10 -n database datastore mkfs -t ext4/xfs /dev/datastore/database mkdir /mnt/database vim /etc/fst

基于Centos6系统创建逻辑卷LVM,执行扩容,缩减,删除等操作

什么是逻辑卷? LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性. LVM的工作原理其实很简单,它就是通过将底层的物理硬盘抽象的封装起来,然后以逻辑卷的方式呈现给上层应用.在传统的磁盘管理机制中,我们的上层应用是直接访问文件系统,从而对底层的物理硬盘进行读取,而在LVM中,其通过对底层的硬盘进行封装,当我们对底层的物理硬盘进行操作时,其不再是针对于分区

基于CentOS 6 系统创建逻辑卷LVM,执行扩容,缩减,删除等操作

2016-08-29 05:37:57 标签:Linux LVMFstab VG PV 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://51eat.blog.51cto.com/11892702/1843663 什么是逻辑卷? LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性. LV

Linux创建逻辑卷详细步骤

1.物理卷物理卷是由磁盘或分区转换得来的,由一个一个pe组成(每个pe默认大小为4MB). 分区的类型必须修改为8e创建pv:格式:pvcreate 分区1 [分区2 分区3 --查看系统中有哪些pv:pvscan查看某个pv的详细信息:pvdisplay 某个pv删除某个pv:pvremove 某个pv 2.卷组卷组由一个或多个物理卷组成创建vg:格式:vgcreate vg名称 pv1 [pv2 pv3 --] 创建vg并将pe的大小修改为8M格式:vgcreate -s 8M vg名称 p

创建磁盘分区,创建逻辑卷组。

1.1 查看新增磁盘fdisk -l 1.2 首先从空的硬盘sdb上创建一个分区sdb1. 为接下来做LVM做准备.[[email protected]_11_3_centos ~]# fdisk /dev/vdb 1.3 为了后期便于维护管理,记得给分区加上标示,这样即使你不在的情况下,别人看到标示了就不会轻易动这块区域了. LVM的标识是8e,设置完成后记得按w保存 1.4 创建逻辑卷将新创建的一个分区/dev/vdb1转化成物理卷,主要是添加LVM属性信息并划分PE存储单元. 1.5 创建

centos7.5 创建逻辑卷

查看分区信息: [[email protected] ~]# fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk lab