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磁盘
747908-20171023170153473-645128585.png

第二步、使用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.1 2 (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/





转载于:https://www.cnblogs.com/hello-sky/p/7717753.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值