Dell服务器自带阵列卡所有添加的硬盘都要通过阵列卡识别,也就是说为Dell服务器添加硬盘必须为硬盘做RAID,否则服务器无法识别
Centos系统根分区容量不够,现打算加一块硬盘容阔LVM添加到根目录里,操作如下:
现有分区表如下
[root@tHe ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d9fc7
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
为新硬盘sdb分区格式化
[root@tHe ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xff5589ec.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 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
First cylinder (1-2610, default 1): #回车,分配所有磁盘扇区
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): #回车,分配所有容量
Using default value 2610
Command (m for help): t #修改分区系统ID标识
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 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 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-FS data
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 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'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 or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware 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 #8e对应上面的LVM分区
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p #查看硬盘现有分区
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xff5589ec
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 8e Linux LVM
Command (m for help): w #保存并退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
现在有/dev/sdb1分区,把它制作成PV并添加到GV里
[root@tHe ~]# pvcreate /dev/sdb1 #制作PV
Physical volume "/dev/sdb1" successfully created
[root@tHe ~]# vgdisplay #显示当前VG信息
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.51 GiB
PE Size 4.00 MiB
Total PE 4994
Alloc PE / Size 4994 / 19.51 GiB
Free PE / Size 0 / 0
VG UUID ttwVLL-2z7K-VpnM-sqhV-qU0O-x3iJ-kVujQs
[root@tHe ~]# vgextend VolGroup /dev/sdb1 #把PV添加到当前VG里
Volume group "VolGroup" successfully extended
[root@tHe ~]# vgdisplay #查看VG现有信息
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 39.50 GiB #添加PV,VG被容阔了
PE Size 4.00 MiB
Total PE 10112
Alloc PE / Size 4994 / 19.51 GiB
Free PE / Size 5118 / 19.99 GiB
VG UUID ttwVLL-2z7K-VpnM-sqhV-qU0O-x3iJ-kVujQs
最后扩展LV
[root@tHe ~]#
[root@tHe ~]# lvdisplay #查看当前LV信息
--- Logical volume ---
LV Path /dev/VolGroup/lv_root #把PV添加到根目录块设备路径
LV Name lv_root
VG Name VolGroup
LV UUID CxcuRX-lXc0-cQua-3f79-112v-4izC-vlipAC
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2019-07-16 17:36:24 +0800
LV Status available
# open 1
LV Size 17.57 GiB
Current LE 4498
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/VolGroup/lv_swap
LV Name lv_swap
VG Name VolGroup
LV UUID nc7Waw-8JNK-Ppo2-IVsG-9tTe-Saun-TC9r51
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2019-07-16 17:36:26 +0800
LV Status available
# open 1
LV Size 1.94 GiB
Current LE 496
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@tHe ~]# lvextend /dev/VolGroup/lv_root /dev/sdb1 #扩展LV根目录
Size of logical volume VolGroup/lv_root changed from 17.57 GiB (4498 extents) to 37.56 GiB (9616 extents).
Logical volume lv_root successfully resized.
[root@tHe ~]# lvs #LVS现有容量已扩展
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_root VolGroup -wi-ao---- 37.56g
lv_swap VolGroup -wi-ao---- 1.94g
[root@tHe ~]# resize2fs /dev/mapper/VolGroup-lv_root #使用resize2fs更新LVS
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 9846784 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 9846784 blocks long.
[root@tHe ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
37G 4.4G 31G 13% /
tmpfs 490M 0 490M 0% /dev/shm
/dev/sda1 477M 55M 397M 13% /boot
[root@tHe ~]#