CentOS磁碟擴容lvm

來源:互聯網
上載者:User

CentOS磁碟擴容lvm 安裝的Centos的LVM空間減少的很快,沒多久就不夠用了,好多人使用的是Gparted擴容,命令列不好用,圖形介面的Gparted在CentOS6.4上面找不到;有人使用Gparted-Live盤,感覺非常的麻煩,其實Linux本身提供了強大而又簡單的擴容工具,非常的容易: 0:當前磁碟情況: [root@CentOS ~]# df -hFilesystem                                            Size  Used Avail Use% Mounted on/dev/mapper/vg_centos-lv_root                 5.5G  4.9G  375M  93% /tmpfs                                                    499M  320K  498M   1% /dev/shm/dev/sda1                                              485M   56M  404M  13% /boottmpfs                                                    499M     0  499M   0% /tmp/ram 1:查看要添加的硬碟,顯示是/dev/sdb: [root@CentOS ~]# fdisk -l Disk /dev/sda: 8589 MB, 8589934592 bytes255 heads, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000d0b56    Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          64      512000   83  LinuxPartition 1 does not end on cylinder boundary./dev/sda2              64        1045     7875584   8e  Linux LVM Disk /dev/sdb: 8589 MB, 8589934592 bytes255 heads, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000 .....: 2:初始化準備新增的磁碟: [root@CentOS ~]# pvcreate /dev/sdb  Physical volume "/dev/sdb" successfully created  3:把新增的磁碟添加到LVM: [root@CentOS ~]# vgextend vg_centos /dev/sdb  Volume group "vg_centos" successfully extended  4:查看增加磁碟後的LVM: [root@CentOS ~]# vgdisplay -v vg_centos    Using volume group(s) on command line    Finding volume group "vg_centos"  --- Volume group ---  VG Name               vg_centos  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.50 GiB  PE Size               4.00 MiB  Total PE              3969  Alloc PE / Size       1922 / 7.51 GiB  Free  PE / Size       2047 / 8.00 GiB //這裡顯示還有多少空間可用,就是新增的磁碟空間  VG UUID               6sYdCf-fA3g-Tyjz-lwfr-2hxP-lnFx-eVaMWj     --- Logical volume ---  LV Path                /dev/vg_centos/lv_root  LV Name                lv_root  VG Name                vg_centos  LV UUID                jjByYP-BlFO-O70G-eYd9-Eupx-wqgS-AB2NNT  LV Write Access        read/write  LV Creation host, time CentOS.Host1, 2013-08-01 11:33:27 +0800  LV Status              available  # open                 1  LV Size                5.54 GiB  Current LE             1418  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     256  Block device           253:0     --- Logical volume ---  LV Path                /dev/vg_centos/lv_swap  LV Name                lv_swap  VG Name                vg_centos  LV UUID                eT8hdT-CbSj-5Kjx-1lyo-2Ru6-nB5o-fJ0HKU  LV Write Access        read/write  LV Creation host, time CentOS.Host1, 2013-08-01 11:33:29 +0800  LV Status              available  # open                 1  LV Size                1.97 GiB  Current LE             504  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     256  Block device           253:1     --- Physical volumes ---  PV Name               /dev/sda2       PV UUID               mEQ0cK-I0ja-45yS-fRqy-19Ds-0dr7-1CNFcx  PV Status             allocatable  Total PE / Free PE    1922 / 0     PV Name               /dev/sdb       PV UUID               03e2Sl-hFVn-NrNr-eHfB-LeuY-D9P0-rSbv0P  PV Status             allocatable  Total PE / Free PE    2047 / 2047  5:擴大邏輯卷(像windows擴大邏輯卷一樣): [root@CentOS ~]# lvextend -L +7.9G /dev/vg_centos/lv_root  Rounding size to boundary between physical extents: 7.90 GiB  Extending logical volume lv_root to 13.44 GiB  Logical volume lv_root successfully resized  6:查看擴容後的LVM [root@CentOS ~]# vgdisplay -v vg_centos    Using volume group(s) on command line    Finding volume group "vg_centos"  --- Volume group ---  VG Name               vg_centos  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               15.50 GiB  PE Size               4.00 MiB  Total PE              3969  Alloc PE / Size       3945 / 15.41 GiB  Free  PE / Size       24 / 96.00 MiB  VG UUID               6sYdCf-fA3g-Tyjz-lwfr-2hxP-lnFx-eVaMWj     --- Logical volume ---  LV Path                /dev/vg_centos/lv_root  LV Name                lv_root  VG Name                vg_centos  LV UUID                jjByYP-BlFO-O70G-eYd9-Eupx-wqgS-AB2NNT  LV Write Access        read/write  LV Creation host, time CentOS.Host1, 2013-08-01 11:33:27 +0800  LV Status              available  # open                 1  LV Size                13.44 GiB  Current LE             3441  Segments               2  Allocation             inherit  Read ahead sectors     auto  - currently set to     256  Block device           253:0     --- Logical volume ---  LV Path                /dev/vg_centos/lv_swap  LV Name                lv_swap  VG Name                vg_centos  LV UUID                eT8hdT-CbSj-5Kjx-1lyo-2Ru6-nB5o-fJ0HKU  LV Write Access        read/write  LV Creation host, time CentOS.Host1, 2013-08-01 11:33:29 +0800  LV Status              available  # open                 1  LV Size                1.97 GiB  Current LE             504  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     256  Block device           253:1     --- Physical volumes ---  PV Name               /dev/sda2       PV UUID               mEQ0cK-I0ja-45yS-fRqy-19Ds-0dr7-1CNFcx  PV Status             allocatable  Total PE / Free PE    1922 / 0     PV Name               /dev/sdb       PV UUID               03e2Sl-hFVn-NrNr-eHfB-LeuY-D9P0-rSbv0P  PV Status             allocatable  Total PE / Free PE    2047 / 24 6:檔案系統擴容(注意,這點必須做,因為上面只是空間擴容) [root@CentOS ~]# resize2fs /dev/vg_centos/lv_rootresize2fs 1.41.12 (17-May-2010)Filesystem at /dev/vg_centos/lv_root is mounted on /; on-line resizing requiredold desc_blocks = 1, new_desc_blocks = 1Performing an on-line resize of /dev/vg_centos/lv_root to 3523584 (4k) blocks.The filesystem on /dev/vg_centos/lv_root is now 3523584 blocks long. 7:查看最後磁碟情況[root@CentOS ~]# df -hFilesystem                                            Size  Used Avail Use% Mounted on/dev/mapper/vg_centos-lv_root                 14G  5.0G  7.7G  40% /tmpfs                                                    499M  320K  498M   1% /dev/shm/dev/sda1                                              485M   56M  404M  13% /boottmpfs                                                    499M     0  499M   0% /tmp/ram 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.