Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6269425
  • 博文数量: 2759
  • 博客积分: 1021
  • 博客等级: 中士
  • 技术积分: 4091
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-11 14:14
文章分类

全部博文(2759)

文章存档

2019年(1)

2017年(84)

2016年(196)

2015年(204)

2014年(636)

2013年(1176)

2012年(463)

分类: LINUX

2014-03-31 09:08:38

原文地址:linux 添加磁盘+lvm扩容 作者:tybtao

l
环境:
virtual box 下,redhat5 64位版本,原来系统默认分区.
新添加一个8G的硬盘sdb,将新加的硬盘容量扩充到原来的/上去.



1.分区,
[root@test ~]# fdisk -l


Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1044     8281507+  8e  Linux LVM


Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sdb doesn't contain a valid partition table
[root@test ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


Command (m for help): n

Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): 
Using default value 1044


Command (m for help): w
The partition table has been altered!


Calling ioctl() to re-read partition table.
Syncing disks.



2.创建pv

[root@test ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

查看pv
root@test ~]# pvdisplay
  /dev/hdc: open failed: No medium found
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup00
  PV Size               7.90 GB / not usable 23.41 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              252
  Free PE               0
  Allocated PE          252
  PV UUID               ntpCtU-7gX3-988d-ifQv-SCyb-oFcx-S0jFrM
   
  "/dev/sdb1" is a new physical volume of "8.00 GB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name               
  PV Size               8.00 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               2XiyBc-5hJD-LJDQ-Fslo-t3CD-go4j-Zt8nxO



3.查看vg
vgdisplay
  /dev/hdc: open failed: No medium found
  --- Volume group ---
  VG Name               VolGroup00
  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               7.88 GB
  PE Size               32.00 MB
  Total PE              252
  Alloc PE / Size       252 / 7.88 GB
  Free  PE / Size       0 / 0   
  VG UUID               Mjkp7h-lSOy-qR7r-RQ1b-FRrH-rNjQ-BOJYDY


4.扩容vg
[root@test ~]# vgextend VolGroup00 /dev/sdb1
  /dev/hdc: open failed: No medium found
  Volume group "VolGroup00" successfully extended


5.检查vg
[root@test ~]# vgdisplay
  /dev/hdc: open failed: No medium found
  --- Volume group ---
  VG Name               VolGroup00
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  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               15.84 GB
  PE Size               32.00 MB
  Total PE              507
  Alloc PE / Size       252 / 7.88 GB
  Free  PE / Size       255 / 7.97 GB
  VG UUID               Mjkp7h-lSOy-qR7r-RQ1b-FRrH-rNjQ-BOJYDY

6.查看lv
[root@test ~]# lvdisplay
  /dev/hdc: open failed: No medium found
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                KBRr5T-kBNg-UfqY-5kEE-snsd-eKl3-1dtUT9
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                6.88 GB
  Current LE             220
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                YMu5P9-nuwE-GbD6-9T9P-knzk-H1rQ-ccyzYX
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.00 GB
  Current LE             32
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1



7.扩容lv
[root@test ~]# lvextend /dev/VolGroup00/LogVol00 /dev/sdb1
  /dev/hdc: open failed: No medium found
  Extending logical volume LogVol00 to 14.84 GB
  Logical volume LogVol00 successfully resized

8.查看lv
[root@test ~]# lvdisplay
  /dev/hdc: open failed: No medium found
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                KBRr5T-kBNg-UfqY-5kEE-snsd-eKl3-1dtUT9
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                14.84 GB
  Current LE             475
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                YMu5P9-nuwE-GbD6-9T9P-knzk-H1rQ-ccyzYX
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.00 GB
  Current LE             32
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1




9.扩容 /  磁盘空间
[root@test ~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
[root@test ~]# res
reset           resize          reslisa         restorecon      restore.static  
resetall        resize2fs       restore         restorecond     
[root@test ~]# resize2fs /dev/mapper/VolGroup00-LogVol0
VolGroup00-LogVol00  VolGroup00-LogVol01  
[root@test ~]# resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00 to 3891200 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 3891200 blocks long.


[root@test ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       15G  6.2G  7.5G  46% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                 250M     0  250M   0% /dev/shm


磁盘空间添加完成


阅读(792) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~