哈尔滨企业网站模板建站,网络公司经营范围包括哪些,帆软网站开发,网业版给VMWare虚拟机根目录扩容#xff0c;简单有效#xff01;_迷倒万千少女的Csir的博客-CSDN博客
https://blog.csdn.net/m0_64206944/article/details/131453844?spm1001.2014.3001.5506
上述链接融合参考下面文章 VMware Linux(Centos)虚拟机扩容根目录磁盘空间
centosli…给VMWare虚拟机根目录扩容简单有效_迷倒万千少女的Csir的博客-CSDN博客
https://blog.csdn.net/m0_64206944/article/details/131453844?spm1001.2014.3001.5506
上述链接融合参考下面文章 VMware Linux(Centos)虚拟机扩容根目录磁盘空间
centoslinuxvmwarewar 1:编辑虚拟机设置点击[硬盘]选择[扩展] 填写大小: image image
点击扩展后VMware提示磁盘已经成功扩展。 image
完成扩展后需从客户机操作系统内部对磁盘【重新分区】和【扩展文件系统】 2:启动虚拟机操作系统Centos查看磁盘情况: 1 # fdisk -l
显示如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 可以看见分区情况如下: 1 2 3 4 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: 输入指令 1 # fdisk /dev/sda 根据命令提示创建分区: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 WARNING: DOS-compatible mode is deprecated. Its 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.
再查看分区情况 1 # fdisk -l
情况如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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
可以看见现在的分区情况如下: 1 2 3 4 5 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:重启操作系统 1 # reboot
5:格式化新分区ext3 1 # mkfs -t ext3 /dev/sda3
显示情况如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 mke2fs 1.41.12 (17-May-2010) 文件系统标签 操作系统:Linux 块大小4096 (log2) 分块大小4096 (log2) Stride0 blocks, Stripe width0 blocks 655360 inodes, 2620937 blocks 131046 blocks (5.00%) reserved for the super user 第一个数据块0 Maximum filesystem blocks2684354560 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使用,输入指令 1 # lvs
显示如下 1 2 3 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
输入指令: 1 # pvcreate /dev/sda3
显示如下: 1 Physical volume /dev/sda3 successfully created
7:向卷组中添加物理卷来增加容量。 输入df -h 查看lvm组名 1 # df -h 1 2 3 4 Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_rxf-lv_root 18G 18G 112M 100% / tmpfs 931M 4.0K 931M 1% /dev/shm /dev/sda1 485M 35M 425M 8% /boot
其中vg_rxf为根所在组名. 输入指令增加卷组的容量 1 # vgextend vg_rxf /dev/sda3 1 Volume group vg_rxf successfully extended
8:查看可以扩展的空间大小: 1 vgdisplay 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 --- Volume group --- VG Name vg_rxf 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 29.50 GiB PE Size 4.00 MiB Total PE 7553 Alloc PE / Size 4994 / 19.51 GiB Free PE / Size 2559 / 10.00 GiB VG UUID KFyuD1-cj5n-cukx-z1Zf-Gg2T-IQLT-v6BD4N
Free PE / Size 就是可以提供分配的自由空间最多10.00 GiB在扩展时输入小于该值 9:扩充磁盘空间 1 # lvextend -L9G /dev/mapper/vg_rxf-lv_root /dev/sda3 1 2 Extending logical volume lv_root to 26.57 GiB Logical volume lv_root successfully resized
10:使用e2fsck指令查看检测文件系统错误 1 # e2fsck -a /dev/mapper/vg_rxf-lv_root 1 2 /dev/mapper/vg_rxf-lv_root is mounted. e2fsck: 无法继续, 中止.
11:使用resize2fs指令来增大或者搜索未加载的ext2/ext3文件系统的大小此处可能出现问题没办法增大扩容空间 1 resize2fs /dev/mapper/vg_rxf-lv_root 1 2 3 4 Filesystem at /dev/mapper/vg_rxf-lv_root is mounted on /; on-line resizing required old desc_blocks 2, new_desc_blocks 2 Performing an on-line resize of /dev/mapper/vg_rxf-lv_root to 6965248 (4k) blocks. The filesystem on /dev/mapper/vg_rxf-lv_root is now 6965248 blocks long.
11-1如果11步出现问题因为我的centos7的某些分区用的是xfs的文件系统使用df -T查看即可知道 1 2 3 4 5 6 7 8 9 10 [rootvnode1 ~]# df -T 文件系统 类型 1K-块 已用 可用 已用% 挂载点 /dev/mapper/centos-root xfs 37173520 5574340 31599180 15% / devtmpfs devtmpfs 3987400 0 3987400 0% /dev tmpfs tmpfs 3997856 0 3997856 0% /dev/shm tmpfs tmpfs 3997856 8628 3989228 1% /run tmpfs tmpfs 3997856 0 3997856 0% /sys/fs/cgroup /dev/sda1 xfs 508588 127152 381436 26% /boot tmpfs tmpfs 799572 0 799572 0% run/user/0 [rootvnode1 ~]#
将resize2fs替换为xfs_growfs重新执行一遍即可如下 1 [rootvnode1 ~]# xfs_growfs /dev/mapper/vg_rxf-lv_root
12:查看扩展空间后的结果: 1 # df -h 1 2 3 4 Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_rxf-lv_root 27G 18G 8.9G 66% / tmpfs 931M 4.0K 931M 1% /dev/shm /dev/sda1 485M 35M 425M 8% /boot
可以看见大功告成。 转载https://www.jianshu.com/p/578816f4e9b8 备注转载的地方有不对的地方已经在此文进行了修改看这一篇就够了