洛杉矶MC机房 高速低价18元起

尊云,给你尊贵体验!

vmware虚拟机centos扩展/root根分区大小

提示:如果官网是英文页面,建议使用谷歌浏览器能同步翻译页面。点击下载【谷歌浏览器最新绿色便携版】
注意:部分文章发布时间较长,可能存在未知因素,购买时建议在本站搜索商家名称,先充分了解商家动态。
交流:唯一投稿QQ80059284、唯一投稿邮箱:admin@bkvps.com、网友交流QQ群号640669696。

1:编辑虚拟机设置,点击[硬盘],选择[扩展] 填写大小:

 

vmware虚拟机centos扩展/root根分区大小插图

1.jpg

vmware虚拟机centos扩展/root根分区大小插图(1)

2.jpg

 

点击扩展后VMware提示磁盘已经成功扩展。

 

vmware虚拟机centos扩展/root根分区大小插图(2)

3.png

完成扩展后,需从客户机操作系统内部对磁盘【重新分区】和【扩展文件系统】

2:启动虚拟机操作系统Centos,查看磁盘情况:

# fdisk -l

显示如下:

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x00094582

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496   8e  Linux LVM

Disk /dev/mapper/vg_rxf-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 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


Disk /dev/mapper/vg_rxf-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 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

可以看见分区情况如下:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496   8e  Linux LVM

3:创建分区sda3:
输入指令

# fdisk /dev/sda

根据命令提示创建分区:

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  #输入n表示创建新分区
Command action
   e   extended
   p   primary partition (1-4)
p       #输入p
Partition number (1-4): 3 #输入3,表示sda3,前面已经有2个了
First cylinder (2611-3916, default 2611): #回车,默认值
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916):   #回车,默认值
Using default value 3916

Command (m for help): w #输入w保存,退出
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

再查看分区情况

# fdisk -l

情况如下:

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x00094582

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496   8e  Linux LVM
/dev/sda3            2611        3916    10483750   83  Linux

Disk /dev/mapper/vg_rxf-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 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


Disk /dev/mapper/vg_rxf-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 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

可以看见现在的分区情况如下:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496   8e  Linux LVM
/dev/sda3            2611        3916    10483750   83  Linux

这时分区已经变成3个了,但是还没有挂载,还不能用。
4:重启操作系统

# reboot

5:格式化新分区ext3

# mkfs -t ext3 /dev/sda3

显示情况如下:

mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2620937 blocks
131046 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

6:将物理硬盘分区初始化为物理卷,以便LVM使用,输入指令

# lvs

显示如下:

  LV      VG     Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root vg_rxf -wi-ao---- 17.57g                                             
  lv_swap vg_rxf -wi-ao----  1.94g  

输入指令:

# pvcreate /dev/sda3

显示如下:

  Physical volume "/dev/sda3" successfully created

添加新LVM到已有的LVM组,实现扩容

lvm                       进入lvm管理

lvm>pvcreate /dev/sda3             这是初始化刚才的分区3

lvm>vgextend centos /dev/sda3     将初始化过的分区加入到虚拟卷组centos (卷和卷组的命令可以通过 vgdisplay )

lvm>vgdisplay -v或者vgdisplay查看free PE /Site

lvm>lvextend -l+1000G /dev/mapper/centos-root  扩展已有卷的容量(6143 是通过vgdisplay查看free PE /Site的大小)

lvm>pvdisplay 查看卷容量,这时你会看到一个很大的卷了

lvm>quit  退出

&&&&& 把/home内容备份,然后将/home文件系统所在的逻辑卷删除,扩大/root文件系统,新建/home ,恢复/home内容

1.查看分区

df -h

2.备份home分区文件

tar cvf /tmp/home.tar /home

3.卸载/home,如果无法卸载,先终止使用/home文件系统的进程

fuser -km /home/ 
umount /home

4.删除/home所在的lv

lvremove /dev/mapper/centos-home

5.扩展/root所在的lv,增加800G

lvextend -L +800G /dev/mapper/centos-root

6.扩展/root文件系统

xfs_growfs /dev/mapper/centos-root

7.重新创建home lv

lvcreate -L 73G -n /dev/mapper/centos-home

8. 创建文件系统

mkfs.xfs /dev/mapper/centos-home

9.挂载home

mount /dev/mapper/centos-home

10.home文件恢复

tar xvf /tmp/home. 
tar -C /home/ 
cd /home/home/ mv * ../

 收藏 (0) 打赏

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

未经允许不得转载:贝壳主机网 » vmware虚拟机centos扩展/root根分区大小

分享到: 生成海报
香港/美国/国内高速VPS
切换注册

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

切换登录

注册

我们将发送一封验证邮件至你的邮箱, 请正确填写以完成账号注册和激活