準(zhǔn)備工作
添加一塊新硬盤/dev/sdb
$ fdisk -l
Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 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
查看當(dāng)前更分區(qū)大小
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 3.6G 44G 8% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 477M 33M 419M 8% /boot
/dev/mapper/VolGroup-lv_home
5.5G 12M 5.2G 1% /home
格式化新硬盤
$ 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 0x070d6722.
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 //創(chuàng)建新分區(qū)
Command action
e extended
p primary partition (1-4)
p //創(chuàng)建為主分區(qū)
Partition number (1-4): 1 //分區(qū)號
First cylinder (1-133674, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-133674, default 133674):
Using default value 133674
Command (m for help): t //設(shè)置分區(qū)為lvm, 因?yàn)楦謪^(qū)為lvm
Selected partition 1
Hex code (type L to list codes): 8e //lvm類型
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w //保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
創(chuàng)建物理卷
$ pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
查看當(dāng)前卷組vgdisplay
$ vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 59.51 GiB
PE Size 4.00 MiB
Total PE 15234
Alloc PE / Size 15234 / 59.51 GiB
Free PE / Size 0 / 0
VG UUID dUUORQ-j5l9-Jd4N-EFNl-N6Qc-rGWq-12QmMA
擴(kuò)展卷組
$ lvextend -L +1023G /dev/VolGroup/lv_root
Size of logical volume VolGroup/lv_root changed from 50.00 GiB (12800 extents) to 1.05 TiB (274688 extents).
Logical volume lv_root successfully resized
重置根分區(qū)容量
$ resize2fs /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 68
Performing an on-line resize of /dev/VolGroup/lv_root to 281280512 (4k) blocks.