整理此前linux 系統、邏輯卷擴容全過程:新增加的硬盤已經安裝到服務器中
用戶此前的磁盤容量為600G,由於數據大部分在data目錄存放,先需要將新加1T的磁盤全部空間擴容到data目錄下
[root@CMS-1 ~]# fdisk -l #通過此命令可以查看服務上所有磁盤的容量、分區等詳細信息
Disk /dev/sda: 599.6 GB, 599550590976 bytes #紅色部分600G是服務器本身的硬盤
255 heads, 63 sectors/track, 72891cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000c2f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinderboundary.
/dev/sda2 26 72892 585292800 8e Linux LVM
Disk /dev/sdb: 999.7 GB, 999653638144 bytes #這個便是新增加的1T硬盤
255 heads, 63 sectors/track, 121534cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-LogVol00: 53.7GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-LogVol02: 34.4GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-LogVol01: 107.4GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-LogVol03: 403.9GB, 403915669504 bytes
255 heads, 63 sectors/track, 49106cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
#以上是服務器硬盤信息,兩塊盤1個600G,1個1T;
#這部分開始對新增加磁盤分區、指定分區表示為LVM、保存退出
[root@CMS-1 ~]# fdisk /dev/sdb #管理新增硬盤
Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with diskidentifier 0xfdc6ff07.
Changes will remain in memory only, untilyou decide to write them.
After that, of course, the previous contentwon't be recoverable.
Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated.It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n #新建分區
Command action
e extended
p primary partition (1-4)
p #建主分區
Partition number (1-4): 1 #分區號1到4之間
First cylinder (1-121534, default 1):
Using default value 1 #磁盤柱面開始位置
Last cylinder, +cylinders or +size{K,M,G}(1-121534, default 121534): #柱面結束位置、默認全部
Using default value 121534
Command (m for help): t #查看分區代碼
Selected partition 1
Hex code (type L to list codes): L #顯示所有表示代碼
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIXroot 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIXusr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16<32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FSdata
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS /.
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIXbootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD orSys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS/ HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 NovellNetware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): 8e #輸入8eLVM
Changed system type of partition 1 to 8e(Linux LVM)
Command (m for help): p #查看分區信息
Disk /dev/sdb: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0xfdc6ff07
Device Boot Start End Blocks Id System
/dev/sdb1 1 121534 976221823+ 8e Linux LVM
Command (m for help): w #保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#到這新增磁盤分區已完成
[root@CMS-1 ~]# fdisk -l #查看分區後的磁盤信息
Disk /dev/sda: 599.6 GB, 599550590976 bytes
255 heads, 63 sectors/track, 72891cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000c2f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinderboundary.
/dev/sda2 26 72892 585292800 8e Linux LVM
Disk /dev/sdb: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0xfdc6ff07
Device Boot Start End Blocks Id System
/dev/sdb1 1 121534 976221823+ 8e Linux LVM
Disk /dev/mapper/VolGroup-LogVol00: 53.7GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-LogVol02: 34.4GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-LogVol01: 107.4GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-LogVol03: 403.9GB, 403915669504 bytes
255 heads, 63 sectors/track, 49106 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
[root@CMS-1 ~]# pvcreate /dev/sdb1 #用此命令建立pv
Physical volume "/dev/sdb1" successfully created
[root@CMS-1 ~]# df -h #查看磁盤使用情況
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
50G 12G 35G 26% /
tmpfs 16G 0 16G 0% /dev/shm
/dev/sda1 190M 46M 135M 26% /boot
/dev/mapper/VolGroup-LogVol03
371G 322G 30G 92% /data #此為要擴容的邏輯卷、可用容量為30G
/dev/mapper/VolGroup-LogVol01
99G 43G 51G 46% /var
[root@CMS-1 ~]# vgs #查看卷組、總大小為558.18G、可用為0
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 4 0wz--n- 558.18g 0
[root@CMS-1 ~]# vgextend VolGroup /dev/sdb1 #將物理卷/dev/sdb1加入卷組
Volume group "VolGroup" successfully extended
[root@CMS-1 ~]# vgs #再次查看卷組、總大小為1.45T、931G可用
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 4 0wz--n- 1.45t 931.00g
[root@CMS-1 ~]# df -h #查看磁盤使用情況、沒變化
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
50G 12G 35G 26% /
tmpfs 16G 0 16G 0% /dev/shm
/dev/sda1 190M 46M 135M 26% /boot
/dev/mapper/VolGroup-LogVol03
371G 322G 30G 92% /data
/dev/mapper/VolGroup-LogVol01
99G 43G 51G 46% /var
[root@CMS-1 ~]# lvextend -l +100%free /dev/mapper/VolGroup-LogVol03 #將所有空間擴容到指定指定邏輯卷
Size of logical volume VolGroup/LogVol03 changed from 376.18 GiB (96301extents) to 1.28 TiB (334636 extents).
Logical volume LogVol03 successfully resized
[root@CMS-1 ~]# df -h #再次查看還變化
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
50G 12G 35G 26% /
tmpfs 16G 0 16G 0% /dev/shm
/dev/sda1 190M 46M 135M 26% /boot
/dev/mapper/VolGroup-LogVol03
371G 322G 30G 92% /data
/dev/mapper/VolGroup-LogVol01
99G 43G 51G 46% /var
[root@CMS-1 ~]# resize2fs/dev/mapper/VolGroup-LogVol03 #調整分區大小
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-LogVol03is mounted on /data; on-line resizing required
old desc_blocks = 24, new_desc_blocks = 82
Performing an on-line resize of/dev/mapper/VolGroup-LogVol03 to 342667264 (4k) blocks.
The filesystem on/dev/mapper/VolGroup-LogVol03 is now 342667264 blocks long.
df -h
本文出自 “沒有你的城市” 博客,請務必保留此出處http://46231571.blog.51cto.com/10939031/1815532