虚拟机vmware 下Centos 系统磁盘扩容


操作步骤 先在VMware 管理界面扩充磁盘容量, 启动系统 查看当前磁盘/dev/sda3已经占用90% 新扩充的磁盘还没生效 [root@localhost ~]# 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): d               # 删除分区,记住千万不要保存,不要使用 w 命令 Partition number (1-3, default 3): 3 我要扩容的是根分区, 根分区在/dev/sda3 所以这里选的3 Partition 3 is deleted   Command (m for help): n  #新建一个分区 Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p # 选择主分区,e 代表扩展分区 Using default response p Partition number (3,4, default 3):  # 默认敲击回车 First sector (4810752-104857599, default 4810752): # 默认敲击回车 Using default value 4810752 Last sector, +sectors or +size{K,M,G} (4810752-104857599, default 104857599): Using default value 104857599 Partition 3 of type Linux and of size 47.7 GiB is set   Command (m for help): p   Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000be86f   Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris /dev/sda3 4810752 104857599 50023424 83 Linux   Command (m for help): w   # 保存刚才创建的新分区 分区创建完成, lsblk 发现分区并没有变化 执行下面两条命令 [root@localhost ~]# partprobe # 如果无效请重启 [root@localhost ~]# xfs_growfs /dev/sda1 # xfs 同步文件系统 [root@localhost ~]# df -h ##扩容成功,查看原来数据都在 Filesystem Size Used Avail Use% Mounted on devtmpfs 895M 0 895M 0% /dev tmpfs 910M 0 910M 0% /dev/shm tmpfs 910M 11M 900M 2% /run tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/sda3 48G 16G 32G 34% /  

相关