添加硬盘驱动器
[root@linuxprobe ~]
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/vdb: 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: 0xd97d5b18
Device Boot Start End Blocks Id System
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): 1
First sector (2048-41943039,default 2048):
Using default value 2048
Last sector,+sectors or +size{K,M,G} (2048-41943039,default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): p
Disk /dev/vdb: 21.5 GB,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: 0xd97d5b18
Device Boot Start End Blocks Id System
/dev/vdb1 2048 41943039 20970496 83 Linux
Command (m for help): 5
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
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/vdb: 21.5 GB,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: 0xd97d5b18
Device Boot Start End Blocks Id System
/dev/vdb1 2048 41943039 20970496 8e Linux LVM
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.
[root@linuxprobe ~]
Disk /dev/vdb: 41610 cylinders,16 heads,63 sectors/track
sfdisk: Warning: The partition table looks like it was made
for C/H/S=*/3/34 (instead of 41610/16/63).
For this listing I'll assume that geometry.
Units: cylinders of 52224 bytes,blocks of 1024 bytes,counting from 0
Device Boot Start End
/dev/vdb1 20+ 411206- 411187- 20970496 8e Linux LVM
sfdisk: start: (c,h,s) expected (20,0,9) found (2,33)
sfdisk: end: (c,s) expected (1023,2,34) found (650,34)
/dev/vdb2 0 - 0 0 0 Empty
/dev/vdb3 0 - 0 0 0 Empty
/dev/vdb4 0 - 0 0 0 Empty@H_124_502@
管理Phisical卷
[root@linuxprobe ~]
Physical volume "/dev/sdb1" successfully created
[root@linuxprobe ~]
Physical volume "/dev/sdb1" successfully created@H_124_502@
[root@linuxprobe ~]# pvdisplay /dev/sdb1
"/dev/sdb1" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID o0nkv0-1XbS-O5Sa-OjKK-kEaL-IVd7-UrSrCP@H_124_502@
[root@linuxprobe ~]
Physical volume "/dev/sdb1" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
[root@linuxprobe ~]
"/dev/sdb1" is a new physical volume of "10.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID o0nkv0-1XbS-O5Sa-OjKK-kEaL-IVd7-UrSrCP@H_124_502@
[root@linuxprobe ~]
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 --- 20.00g 20.00g
[root@linuxprobe ~]
PV /dev/sda2 VG centos lvm2 [19.51 GiB / 40.00 MiB free]
PV /dev/sdb1 lvm2 [20.00 GiB]
Total: 2 [39.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 1 [20.00 GiB]@H_124_502@
[root@linuxprobe ~]
Labels on physical volume "/dev/sdb1" successfully wiped
[root@linuxprobe ~]
Failed to find physical volume "/dev/sdb1".@H_124_502@
[root@linuxprobe ~]# vgcreate vg_linux/dev/sdb1
Volume group "vg_linux" successfully created
# 制定多个磁盘设备如下:
[root@linuxprobe ~]# vgcreate vg_linux /dev/sdb1 /dev/sdd1
Volume group "vg_linux" successfully created@H_124_502@
[root@linuxprobe ~]
Volume group "vg_linux" successfully created
[root@linuxprobe ~]
--- Volume group ---
VG Name vg_linux
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 20.00 GiB
PE Size 4.00 MiB
Total PE 5119
Alloc PE / Size 0 / 0
Free PE / Size 5119 / 20.00 GiB
VG UUID RnRfbj-DUC4-BdUB-kmov-L6Lh-uiCP-SVDsKq@H_124_502@
[root@linuxprobe ~]
Volume group "vg_linux" successfully renamed to "vg_probe"
[root@linuxprobe ~]
--- Volume group ---
VG Name vg_probe
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
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 20.00 GiB
PE Size 4.00 MiB
Total PE 5119
Alloc PE / Size 0 / 0
Free PE / Size 5119 / 20.00 GiB
VG UUID RnRfbj-DUC4-BdUB-kmov-L6Lh-uiCP-SVDsKq@H_124_502@
[root@linuxprobe ~]
Volume group "vg_probe" successfully extended
[root@linuxprobe ~]
--- Volume group ---
VG Name vg_probe
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
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 40.00 GiB
PE Size 4.00 MiB
Total PE 20479
Alloc PE / Size 0 / 0
Free PE / Size 20479 / 160.00 GiB
VG UUID RnRfbj-DUC4-BdUB-kmov-L6Lh-uiCP-SVDsKq@H_124_502@
[root@linuxprobe ~]
Removed "/dev/sdc1" from volume group "vg_probe "
[root@linuxprobe ~]
--- Volume group ---
VG Name vg_probe
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
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 20.00 GiB
PE Size 4.00 MiB
Total PE 20479
Alloc PE / Size 0 / 0
Free PE / Size 20479 / 80.00 GiB
VG UUID RnRfbj-DUC4-BdUB-kmov-L6Lh-uiCP-SVDsKq@H_124_502@
# disable target volume group first and delete it
[root@linuxprobe ~]# vgchange -a n vg_probe
0 logical volume(s) in volume group "vg_probe" now active
[root@linuxprobe ~]# vgremove vg_probe
Volume group "vg_data" successfully removed@H_124_502@
创建LV
[root@linuxprobe ~]
Logical volume "lv_data" created.
[root@linuxprobe ~]
Logical volume "lv_data" already exists in volume group "vg_probe"
[root@linuxprobe ~]
Logical volume "lv_probe" created.
[root@linuxprobe ~]
VG
centos 1 2 0 wz--n- 19.51g 40.00m
vg_probe 1 2 0 wz--n- 20.00g 0@H_124_502@
[root@linuxprobe ~]
LV Path /dev/vg_probe/lv_probe
LV Name lv_probe
VG Name vg_probe
LV UUID s11m21-qn5J-2gLx-IrFm-GZ1B-ZEZx-teHFiw
LV Write Access read/write
LV Creation host,time linuxprobe.org,2017-01-03 19:23:29 +0800
LV Status available
LV Size 15.00 GiB
Current LE 3839
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:3@H_124_502@
[root@linuxprobe ~]
Renamed "lv_probe" to "lv_linux" in volume group "vg_probe"
[root@linuxprobe ~]
LV Path /dev/vg_probe/lv_linux
LV Name lv_linux
VG Name vg_probe
LV UUID s11m21-qn5J-2gLx-IrFm-GZ1B-ZEZx-teHFiw
LV Write Access read/write
LV Creation host,2017-01-03 19:23:29 +0800
LV Status available
LV Size 15.00 GiB
Current LE 3839
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:3
[root@linuxprobe ~]
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao
swap centos -wi-ao
lv_data vg_probe -wi-a
lv_linux vg_probe -wi-a@H_124_502@
[root@linuxprobe ~]
Logical volume "snap-lv_linux" created.
[root@linuxprobe ~]
LV Path /dev/vg_probe/lv_linux
LV Name lv_linux
VG Name vg_probe
LV UUID s11m21-qn5J-2gLx-IrFm-GZ1B-ZEZx-teHFiw
LV Write Access read/write
LV Creation host,2017-01-03 19:23:29 +0800
LV snapshot status source of
snap-lv_linux [active]
LV Status available
LV Size 5.00 GiB
Current LE 1280
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:3
LV Path /dev/vg_probe/snap-lv_linux
LV Name snap-lv_linux
VG Name vg_probe
LV UUID sLLQ2y-IOiv-fgtD-RpPr-y7pw-YWnZ-zqwXhD
LV Write Access read/write
LV Creation host,2017-01-03 19:30:49 +0800
LV snapshot status active destination for lv_linux
LV Status available
LV Size 5.00 GiB
Current LE 1280
COW-table size 5.00 GiB
COW-table LE 1280
Allocated to snapshot 0.00%
Snapshot chunk size 4.00 KiB
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:6@H_124_502@
[root@linuxprobe ~]# lvextend -L 6G /dev/vg_probe/lv_data Size of logical volume vg_probe/lv_data changed from 5.00 GiB (1280 extents) to 6.00 GiB (1536 extents). Logical volume lv_data successfully resized. [root@linuxprobe ~]# lvdisplay /dev/vg_probe/lv_data --- Logical volume --- LV Path /dev/vg_probe/lv_data LV Name lv_data VG Name vg_probe LV UUID 7MVyp5-xw22-dpnu-vQp8-pa5C-ONvs-LQfS09 LV Write Access read/write LV Creation host,time linuxprobe.org,2017-01-03 19:22:52 +0800 LV Status available # open 0 LV Size 6.00 GiB Current LE 1536 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 [root@linuxprobe ~]# xfs_growfs /mnt/ Meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=1144832 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=4579328, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks,lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@linuxprobe ~]# resize resize2fs resizecons resizepart [root@linuxprobe ~]# resize2fs /dev/vg_probe/lv_data #重新格式化 resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/vg_probe/lv_data Couldn't find valid filesystem superblock.@H_124_502@
[root@linuxprobe ~]
WARNING: Reducing active logical volume to 5.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_data? [y/n]: y Size of logical volume vg_probe/lv_data changed from 6.00 GiB (1536 extents) to 5.00 GiB (1280 extents). Logical volume lv_data successfully resized. [root@linuxprobe ~]# lvchange -an /dev/vg_probe/lv_data
[root@linuxprobe ~]
Logical volume "lv_data" successfully removed@H_124_502@