标签:cto 操作 selected The pvcreate info 新建 cond summary
一、逻辑卷的创建[root@centos7 ~ ]#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 199G 0 part ├─centos-root 253:0 0 50G 0 lvm / ├─centos-swap 253:1 0 2G 0 lvm [SWAP] └─centos-home 253:2 0 147G 0 lvm /home sdb 8:16 0 10G 0 disk //新加入的磁盘sdb sdc 8:32 0 5G 0 disk //新加入的磁盘sdc sr0 11:0 1 8.8G 0 rom
[root@centos7 ~ ]#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. 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-20971519, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): Using default value 20971519 Partition 1 of type Linux and of size 10 GiB is set Command (m for help): t //选择标签 Selected partition 1 Hex code (type L to list all codes): 8e // 8e Linux LVM Changed type of partition ‘Linux‘ to ‘Linux LVM‘ Command (m for help): w //保存 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
同理分出(sdc)分区
[root@centos7 ~ ]#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 199G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 2G 0 lvm [SWAP]
└─centos-home 253:2 0 147G 0 lvm /home
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 10G 0 part
sdc 8:32 0 5G 0 disk
└─sdc1 8:33 0 5G 0 part
sr0 11:0 1 8.8G 0 rom
[root@centos7 ~ ]#pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@centos7 ~ ]#pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg0
PV Size <10.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2559
Free PE 1279
Allocated PE 1280
PV UUID arm45N-isin-be4N-ob5a-Xwj1-i7Wc-Nwf73e
[root@centos7 ~ ]#vgcreate vg0 /dev/sdb1
Volume group "vg0" successfully created
[root@centos7 ~ ]#vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- <199.00g 4.00m
vg0 1 0 0 wz--n- <10.00g <10.00g
[root@centos7 ~ ]#lvcreate -L 5G -n /dev/vg0/lv0 vg0
Logical volume "lv0" created.
[root@centos7 ~ ]#lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- 146.99g
root centos -wi-ao---- 50.00g
swap centos -wi-ao---- 2.00g
lv0 vg0 -wi-ao---- 5.00g
[root@centos7 ~ ]#mkfs.xfs /dev/vg0/lv0
meta-data=/dev/vg0/lv0 isize=512 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=1310720, 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
[root@centos7 ~ ]#mount /dev/vg0/lv0 /data
[root@centos7 ~ ]#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 199G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 2G 0 lvm [SWAP]
└─centos-home 253:2 0 147G 0 lvm /home
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 10G 0 part
└─vg0-lv0 253:3 0 5G 0 lvm /data
sdc 8:32 0 5G 0 disk
└─sdc1 8:33 0 5G 0 part
sr0 11:0 1 8.8G 0 rom
#
# /etc/fstab
# Created by anaconda on Tue Aug 14 16:09:13 2018
#
# 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
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=936ee62c-93ff-4f19-ae07-1112add772b6 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
UUID=8e7e026a-4025-4cee-ac6d-b3766fef9993 /data xfs defaults 0 0
[root@centos7 ~ ]#vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <10.00 GiB
PE Size 4.00 MiB
Total PE 2559
Alloc PE / Size 1280 / 5.00 GiB
Free PE / Size 1279 / <5.00 GiB
VG UUID 501kCS-IukG-st2J-5wUs-R7vQ-JdC9-wPjq0S
[root@centos7 ~ ]#lvextend -l +100%FREE /dev/vg0/lv0
Size of logical volume vg0/lv0 changed from 5.00 GiB (1280 extents) to <10.00 GiB (2559 extents).
Logical volume vg0/lv0 successfully resized.
[root@centos7 ~ ]#lvextend -r -l +100%FREE /dev/vg0/lv0
Size of logical volume vg0/lv0 unchanged from <10.00 GiB (2559 extents).
Logical volume vg0/lv0 successfully resized.
meta-data=/dev/mapper/vg0-lv0 isize=512 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1310720 to 2620416
[root@centos7 ~ ]#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 199G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 2G 0 lvm [SWAP]
└─centos-home 253:3 0 147G 0 lvm /home
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 10G 0 part
└─vg0-lv0 253:2 0 10G 0 lvm /data
sdc 8:32 0 5G 0 disk
└─sdc1 8:33 0 5G 0 part
sr0 11:0 1 8.8G 0 rom
[root@centos7 ~ ]#umount /dev/vg0/lv0
[root@centos7 ~ ]#e2fsck -f /dev/vg0/lv0
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg0/lv0: 11/655360 files (0.0% non-contiguous), 83137/2620416 blocks
[root@centos7 ~ ]#resize2fs /dev/vg0/lv0 1G
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vg0/lv0 to 262144 (4k) blocks.
The filesystem on /dev/vg0/lv0 is now 262144 blocks long.
[root@centos7 ~ ]#lvreduce -L 1G /dev/vg0/lv0
WARNING: Reducing active logical volume to 1.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg0/lv0? [y/n]: y
Size of logical volume vg0/lv0 changed from <10.00 GiB (2559 extents) to 1.00 GiB (256 extents).
Logical volume vg0/lv0 successfully resized.
[root@centos7 ~ ]#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 199G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 2G 0 lvm [SWAP]
└─centos-home 253:3 0 147G 0 lvm /home
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 10G 0 part
└─vg0-lv0 253:2 0 1G 0 lvm
sdc 8:32 0 5G 0 disk
└─sdc1 8:33 0 5G 0 part
sr0 11:0 1 8.8G 0 rom
[root@centos7 ~ ]#mount /dev/vg0/lv0 /data
[root@centos7 ~ ]#umount /dev/vg0/lv0
[root@centos7 ~ ]#lvremove /dev/vg0/lv0
Do you really want to remove active logical volume vg0/lv0? [y/n]: y
Logical volume "lv0" successfully removed
[root@centos7 ~ ]#lvdisplay | grep "/dev/vg0/lv0"
[root@centos7 ~ ]#vgchange -a n vg0
0 logical volume(s) in volume group "vg0" now active
[root@centos7 ~ ]#vgremove /dev/vg0
Volume group "vg0" successfully removed
[root@centos7 ~ ]#pvremove /dev/sdb1
___ Labels on physical volume "/dev/sdb1" successfully wiped.
标签:cto 操作 selected The pvcreate info 新建 cond summary
原文地址:http://blog.51cto.com/13854765/2160019