zoukankan      html  css  js  c++  java
  • Linux下VMware扩展/根目录空间

    Linux下VMware扩展/根目录空间

    [root@data4 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/rootvg-lv01
                           99G   90G  3.4G  97% /       <==给根目录扩容400G硬盘
    tmpfs                 4.9G     0  4.9G   0% /dev/shm
    /dev/sda1             190M   39M  142M  22% /boot


    第一步、给VMware虚拟机增加一块400G磁盘

    第二步、使用Linux下的fdisk工具进行分区
    使用 fdisk 命令可以查看到刚刚新增的一块400G硬盘
    [root@data4 ~]# fdisk -l
     
    Disk /dev/sda: 100 GB, 536870912000 bytes
    255 heads, 63 sectors/track, 65270 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: 0x0003f73f
     
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          26      204800   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              26       13055   104651776   8e  Linux LVM
     
    Disk /dev/sdb: 400 GB, 429496729600 bytes
    255 heads, 63 sectors/track, 52216 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: 0x46d25589
     
    Disk /dev/mapper/rootvg-lv01: 107.1 GB, 107139301376 bytes
    255 heads, 63 sectors/track, 13025 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

    使用 fdisk 命令进行磁盘分区
    fdisk /dev/sdc
    n    
    p
    1
    回车
    回车
    w
    partprobe /dev/sdb
    mkfs -t ext4 /dev/sdb1

    查看分区情况
    [root@data4 ~]# fdisk -l
     
    Disk /dev/sda: 100 GB, 536870912000 bytes
    255 heads, 63 sectors/track, 65270 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: 0x0003f73f
     
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          26      204800   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              26       13055   104651776   8e  Linux LVM
     
    Disk /dev/sdb: 400 GB, 429496729600 bytes
    255 heads, 63 sectors/track, 52216 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: 0x46d25589
     
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1       52216   419424988+  83  Linux
     
    Disk /dev/mapper/rootvg-lv01: 107.1 GB, 107139301376 bytes
    255 heads, 63 sectors/track, 13025 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


    我们的新建分区/dev/sdb1,却不是LVM的。所以,接下来使用fdisk将其改成LVM的
    fdisk /dev/sdb
    Command (m for help): m 
    Command (m for help): t //改变分区系统id      
    Partition number (1-4): 3 //指定分区号
    Hex code (type L to list codes): 8e //指定要改成的id号,8e代表LVM。
    Command (m for help): w
    mkfs -t ext4 /dev/sdb1

    我们现在还不能用这个分区 , 因为我们没格式化。这时要重启系统就能够在 dev 下面看到 sdb1 ,如果不重启不能进行下面操作。
    重启后,在此查看fdisk -l
    [root@data4 ~]# fdisk -l
     
    Disk /dev/sda: 100 GB, 536870912000 bytes
    255 heads, 63 sectors/track, 65270 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: 0x0003f73f
     
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          26      204800   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              26       13055   104651776   8e  Linux LVM
     
    Disk /dev/sdb: 400 GB, 429496729600 bytes
    255 heads, 63 sectors/track, 52216 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: 0x46d25589
     
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1       52216   419424988+  8e  Linux LVM
     
    Disk /dev/mapper/rootvg-lv01: 535.6 GB, 535562289152 bytes
    255 heads, 63 sectors/track, 65111 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
    可以看到/dev/sdb1已支持LVM

    第三步、扩充根分区
    接着,使用vgextend 命令加到lvm组里面去,做如下操作:
    [root@data4 ~]# lvs
      LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv01 rootvg -wi-ao---- 99.78g

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

    [root@data4 ~]# vgextend rootvg /dev/sdb1
      Volume group "rootvg" successfully extended

    [root@data4 ~]# vgdisplay
      --- Volume group ---
      VG Name               rootvg
      System ID
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  3
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                1
      Open LV               1
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               499.75 GiB
      PE Size               32.00 MiB
      Total PE              15992
      Alloc PE / Size       3193 / 99.78 GiB
      Free  PE / Size       12799 / 399.97 GiB
      VG UUID               b6ceOL-4U9q-3DyS-p8VV-WKvC-dAEp-nuFws7
    主要查看Free PE / Size 255 / 399.97 GB,说明我们最多可以有399G的扩充空间

    最后,给根分区增加空间
    [root@data4 ~]# lvextend -L +399G /dev/rootvg/lv01 /dev/sdb1
      Size of logical volume rootvg/lv01 changed from 99.78 GiB (3193 extents) to 498.78 GiB (15961 extents).
      Logical volume lv01 successfully resized.

    使用e2fsck指令检查文件系统错误
    [root@data4 ~]# e2fsck -f /dev/mapper/rootvg-lv01

    resize2fs指令被用来增大或者收缩未加载的“ext2/ext3”文件系统的大小
    [root@data4 ~]# resize2fs /dev/mapper/rootvg-lv01
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/mapper/rootvg-lv01 is mounted on /; on-line resizing required
    old desc_blocks = 7, new_desc_blocks = 32
    Performing an on-line resize of /dev/mapper/rootvg-lv01 to 130752512 (4k) blocks.     <==需要耐心等待一段时间
    The filesystem on /dev/mapper/rootvg-lv01 is now 130752512 blocks long.

    再次使用df -f命令查看/根目录以及成功扩展了400G容量
    [root@data4 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/rootvg-lv01
                          491G   90G  377G  20% /
    tmpfs                 4.9G     0  4.9G   0% /dev/shm
    /dev/sda1             190M   39M  142M  22% /boot



    参考文献:
    实战Linux下VMware虚拟机根目录空间扩充 http://blog.csdn.net/snlying/article/details/6184428
    VMware 虚拟机(linux)增加根目录磁盘空间 http://zhongxw.blog.51cto.com/3429597/787219/





  • 相关阅读:
    【WCF--初入江湖】04 WCF通信模式
    【WCF--初入江湖】03 配置服务
    c++输出左右对齐设置
    setw()函数
    clion更改大括号的位置
    emacs org-mode 中文手册精简版(纯小白)
    c++ string 类型 大小写转换 
    C++中string类型的find 函数
    string类型 C++
    统计单词数---单词与空格
  • 原文地址:https://www.cnblogs.com/hello-sky/p/7717753.html
Copyright © 2011-2022 走看看