Vmware添加磁盘的方法:扩展磁盘
这篇文章介绍了一下如何在vmare下添加或扩展磁盘并使之有效。
场景
创建linux时分配磁盘空间随着使用的增加,使用率逐渐升高,此时需要在添加或者扩展一下磁盘。
比如:此linux(centos 7.3)的磁盘为20g,目前已经使用到接近80%
[root@mail ~]# cat /etc/redhat-release centos linux release 7.3.1611 (core) [root@mail ~]# df filesystem 1k-blocks used available use% mounted on /dev/mapper/cl_angular-root 17811456 13985948 3825508 79% / devtmpfs 1521180 0 1521180 0% /dev tmpfs 1532160 0 1532160 0% /dev/shm tmpfs 1532160 8776 1523384 1% /run tmpfs 1532160 0 1532160 0% /sys/fs/cgroup /dev/sda1 1038336 123500 914836 12% /boot tmpfs 306432 0 306432 0% /run/user/0 [root@mail ~]#
扩展磁盘或者添加磁盘
vmware下有两种方式:
- 添加磁盘
- 扩展磁盘
注意:扩展磁盘需要在此虚拟机停止的状态下进行,同时扩展的数字是扩展后的预期大小,比如事前为20g,希望扩展10g,应该输入30。这篇文章使用扩展磁盘的方式。
确认状态
扩展后,重新启动linux,发现df状态没有变化
[root@mail ~]# df filesystem 1k-blocks used available use% mounted on /dev/mapper/cl_angular-root 17811456 13985948 3825508 79% / devtmpfs 1521180 0 1521180 0% /dev tmpfs 1532160 0 1532160 0% /dev/shm tmpfs 1532160 8776 1523384 1% /run tmpfs 1532160 0 1532160 0% /sys/fs/cgroup /dev/sda1 1038336 123500 914836 12% /boot tmpfs 306432 0 306432 0% /run/user/0 [root@mail ~]#
使用fdisk确认磁盘空间是否已经扩展
[root@mail ~]# fdisk -l disk /dev/sda: 32.2 gb, 32212254720 bytes, 62914560 sectors units = sectors of 1 * 512 = 512 bytes sector size (logical/physical): 512 bytes / 512 bytes i/o size (minimum/optimal): 512 bytes / 512 bytes disk label type: dos disk identifier: 0x0005ba89 device boot start end blocks id system /dev/sda1 * 2048 2099199 1048576 83 linux /dev/sda2 2099200 41943039 19921920 8e linux lvm disk /dev/mapper/cl_angular-root: 18.2 gb, 18249416704 bytes, 35643392 sectors units = sectors of 1 * 512 = 512 bytes sector size (logical/physical): 512 bytes / 512 bytes i/o size (minimum/optimal): 512 bytes / 512 bytes disk /dev/mapper/cl_angular-swap: 2147 mb, 2147483648 bytes, 4194304 sectors units = sectors of 1 * 512 = 512 bytes sector size (logical/physical): 512 bytes / 512 bytes i/o size (minimum/optimal): 512 bytes / 512 bytes [root@mail ~]#
可以看到“disk /dev/sda: 32.2 gb”,已经扩展了10g空间。
扩展分区
[root@mail ~]# fdisk /dev/sda welcome to fdisk (util-linux 2.23.2). changes will remain in memory only, until you decide to write them. be careful before using the write command. command (m for help): n partition type: p primary (2 primary, 0 extended, 2 free) e extended select (default p): p partition number (3,4, default 3): first sector (41943040-62914559, default 41943040): using default value 41943040 last sector, +sectors or +size{k,m,g} (41943040-62914559, default 62914559): using default value 62914559 partition 3 of type linux and of size 10 gib is set command (m for help): t partition number (1-3, default 3): 3 hex code (type l to list all codes): l 0 empty 24 nec dos 81 minix / old lin bf solaris 1 fat12 27 hidden ntfs win 82 linux swap / so c1 drdos/sec (fat- 2 xenix root 39 plan 9 83 linux c4 drdos/sec (fat- 3 xenix usr 3c partitionmagic 84 os/2 hidden c: c6 drdos/sec (fat- 4 fat16 <32m 40 venix 80286 85 linux extended c7 syrinx 5 extended 41 ppc prep boot 86 ntfs volume set da non-fs data 6 fat16 42 sfs 87 ntfs volume set db cp/m / ctos / . 7 hpfs/ntfs/exfat 4d qnx4.x 88 linux plaintext de dell utility 8 aix 4e qnx4.x 2nd part 8e linux lvm df bootit 9 aix bootable 4f qnx4.x 3rd part 93 amoeba e1 dos access a os/2 boot manag 50 ontrack dm 94 amoeba bbt e3 dos r/o b w95 fat32 51 ontrack dm6 aux 9f bsd/os e4 speedstor c w95 fat32 (lba) 52 cp/m a0 ibm thinkpad hi eb beos fs e w95 fat16 (lba) 53 ontrack dm6 aux a5 freebsd ee gpt f w95 ext'd (lba) 54 ontrackdm6 a6 openbsd ef efi (fat-12/16/ 10 opus 55 ez-drive a7 nextstep f0 linux/pa-risc b 11 hidden fat12 56 golden bow a8 darwin ufs f1 speedstor 12 compaq diagnost 5c priam edisk a9 netbsd f4 speedstor 14 hidden fat16 <3 61 speedstor ab darwin boot f2 dos secondary 16 hidden fat16 63 gnu hurd or sys af hfs / hfs+ fb vmware vmfs 17 hidden hpfs/ntf 64 novell netware b7 bsdi fs fc vmware vmkcore 18 ast smartsleep 65 novell netware b8 bsdi swap fd linux raid auto 1b hidden w95 fat3 70 disksecure mult bb boot wizard hid fe lanstep 1c hidden w95 fat3 75 pc/ix be solaris boot ff bbt 1e hidden w95 fat1 80 old minix hex code (type l to list all codes): 8e changed type of partition 'linux' to 'linux lvm' command (m for help): w the partition table has been altered! calling ioctl() to re-read partition table. warning: re-reading the partition table failed with error 16: device or resource busy. 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. [root@mail ~]#
执行 partprobe或者重启
执行 partprobe命令用于将磁盘分区表变化信息通知内核,并请求操作系统重新加载分区表,可以避免必须重新启动的问题,这里我们reboot一下。
分区确认
通过fdisk可以确认到已经添加了sda3
[root@mail ~]# fdisk -l disk /dev/sda: 32.2 gb, 32212254720 bytes, 62914560 sectors units = sectors of 1 * 512 = 512 bytes sector size (logical/physical): 512 bytes / 512 bytes i/o size (minimum/optimal): 512 bytes / 512 bytes disk label type: dos disk identifier: 0x0005ba89 device boot start end blocks id system /dev/sda1 * 2048 2099199 1048576 83 linux /dev/sda2 2099200 41943039 19921920 8e linux lvm /dev/sda3 41943040 62914559 10485760 8e linux lvm disk /dev/mapper/cl_angular-root: 18.2 gb, 18249416704 bytes, 35643392 sectors units = sectors of 1 * 512 = 512 bytes sector size (logical/physical): 512 bytes / 512 bytes i/o size (minimum/optimal): 512 bytes / 512 bytes disk /dev/mapper/cl_angular-swap: 2147 mb, 2147483648 bytes, 4194304 sectors units = sectors of 1 * 512 = 512 bytes sector size (logical/physical): 512 bytes / 512 bytes i/o size (minimum/optimal): 512 bytes / 512 bytes [root@mail ~]#
扩展vg
基本lvm知识,进行vg扩展,不再赘述。
[root@mail ~]# pvcreate /dev/sda3 physical volume "/dev/sda3" successfully created. [root@mail ~]# vgs vg #pv #lv #sn attr vsize vfree cl_angular 1 2 0 wz--n- 19.00g 0 [root@mail ~]# vgextend cl_angular /dev/sda3 volume group "cl_angular" successfully extended [root@mail ~]# vgs vg #pv #lv #sn attr vsize vfree cl_angular 2 2 0 wz--n- 28.99g 10.00g [root@mail ~]#
扩展lv
可以将此lv全部添加或者部分添加,我们这里全部添加。
[root@mail ~]# lvs lv vg attr lsize pool origin data% meta% move log cpy%sync convert root cl_angular -wi-ao---- 17.00g swap cl_angular -wi-ao---- 2.00g [root@mail ~]# lvextend /dev/cl_angular/root /dev/sda3 size of logical volume cl_angular/root changed from 17.00 gib (4351 extents) to 26.99 gib (6910 extents). logical volume cl_angular/root successfully resized. [root@mail ~]# lvs lv vg attr lsize pool origin data% meta% move log cpy%sync convert root cl_angular -wi-ao---- 26.99g swap cl_angular -wi-ao---- 2.00g [root@mail ~]#
df状态确认
此时df状态还没有变化
[root@mail ~]# df filesystem 1k-blocks used available use% mounted on /dev/mapper/cl_angular-root 17811456 13986168 3825288 79% / devtmpfs 1521180 0 1521180 0% /dev tmpfs 1532160 0 1532160 0% /dev/shm tmpfs 1532160 8808 1523352 1% /run tmpfs 1532160 0 1532160 0% /sys/fs/cgroup /dev/sda1 1038336 123500 914836 12% /boot tmpfs 306432 0 306432 0% /run/user/0 [root@mail ~]#
xfs_growfs
使用xfs_growfs可以将xfs文件系统进行online方式的扩展,它会将data block进行调整。
[root@mail ~]# xfs_growfs /dev/mapper/cl_angular-root meta-data=/dev/mapper/cl_angular-root isize=512 agcount=4, agsize=1113856 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=4455424, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 4455424 to 7075840 [root@mail ~]#
再次确认df状态, 添加的10g空间已经有效,使用率也降到了50%。
[root@mail ~]# df filesystem 1k-blocks used available use% mounted on /dev/mapper/cl_angular-root 28293120 13986252 14306868 50% / devtmpfs 1521180 0 1521180 0% /dev tmpfs 1532160 0 1532160 0% /dev/shm tmpfs 1532160 8808 1523352 1% /run tmpfs 1532160 0 1532160 0% /sys/fs/cgroup /dev/sda1 1038336 123500 914836 12% /boot tmpfs 306432 0 306432 0% /run/user/0 [root@mail ~]#
小结
这篇文章介绍了如何vmware下如何扩展磁盘,其实后面的命令均为lvm操作,基本上在linux或者unix的卷操作上大体类似。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接
推荐阅读
-
Linux下独立添加PHP扩展模块mbstring的方法
-
Win10怎样查看磁盘安装了哪些应用?Win10查看已安装应用的方法
-
在Linux中使用Smartctl监控磁盘性能的方法
-
IBM system X3250 M4 配置RAID磁盘阵列的方法
-
如何将磁盘从FAT格式转换为NTFS格式的方法步骤
-
Win10怎么合并磁盘分区?win10系统电脑硬盘分区合并的方法
-
linux下使用 du查看某个文件或目录占用磁盘空间的大小方法
-
Win7虚拟磁盘如何使用?Win7使用虚拟磁盘的方法
-
linux系统磁盘分区及把磁盘挂载到系统中的方法
-
win7系统开机提示因为磁盘管理控制台视图不是最新状态的两种解决方法图文教程