VM虚拟机中Linux扩展磁盘空间的方法

上传人:宝路 文档编号:3287343 上传时间:2017-08-01 格式:DOCX 页数:8 大小:707.60KB
返回 下载 相关 举报
VM虚拟机中Linux扩展磁盘空间的方法_第1页
第1页 / 共8页
VM虚拟机中Linux扩展磁盘空间的方法_第2页
第2页 / 共8页
VM虚拟机中Linux扩展磁盘空间的方法_第3页
第3页 / 共8页
VM虚拟机中Linux扩展磁盘空间的方法_第4页
第4页 / 共8页
VM虚拟机中Linux扩展磁盘空间的方法_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《VM虚拟机中Linux扩展磁盘空间的方法》由会员分享,可在线阅读,更多相关《VM虚拟机中Linux扩展磁盘空间的方法(8页珍藏版)》请在金锄头文库上搜索。

1、Vm 虚拟机下 Linux 扩展原有磁盘空间1、 打开 VMWare 软件,展开需要扩展的 linux 服务器如图所示,我们将扩展 centos7_03,它的硬盘只有 20GB2、 点击“硬盘” ,弹出框中再选择“实用工具”在弹出菜单中,选择“扩展”在弹出框中,输入最大磁盘大小,这里输入 50GB,原来为 20GB,即扩展 30GB 的硬盘空间。确定之后,我们可以看到硬盘,容易确实变成 50GB;但是 30G 新增加的空间还不能立即使用,需要重新分区和格式化。需注意以下几点: linux 只能扩展磁盘容量而不能减小, 所填写的容量为总容量,即包含已分区的磁盘, 扩展容量时不能有快照哟,大家可以

2、先把快照删除掉。3、 启动 Linux,查看系统分区,并创建分区 sda3,命令如下:红色字体命令,#后为注释rootlocalhost # fdisk -lDisk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosD

3、isk identifier: 0x0003fd36Device Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83 Linux/dev/sda2 1026048 41943039 20458496 8e Linux LVMDisk /dev/mapper/centos-root: 18.8 GB, 18756927488 bytes, 36634624 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512

4、bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes #我的电脑有 2 个分区-sda1 sda

5、2rootlocalhost # fdisk /dev/sdaWelcome 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 extendedSelect (default p): pPartition nu

6、mber (3,4, default 3): 3First sector (41943040-104857599, default 41943040): #回车即可Using default value 41943040Last sector, +sectors or +sizeK,M,G (41943040-104857599, default 104857599): #回车即可Using default value 104857599Partition 3 of type Linux and of size 30 GiB is setCommand (m for help): wThe p

7、artition 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 atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.

8、再次查看是否生成新的分区rootlocalhost # fdisk -lDisk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0005525aDevice Boot Start

9、 End Blocks Id System/dev/sda1 * 2048 1026047 512000 83 Linux/dev/sda2 1026048 41943039 20458496 8e Linux LVM/dev/sda3 41943040 104857599 31457280 83 LinuxDisk /dev/mapper/centos-root: 18.8 GB, 18756927488 bytes, 36634624 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 5

10、12 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes4、 如上面所示,我们已经有三个分区,

11、最后一个分区即是我们扩展的磁盘/dev/sda3,下面我们将进行格式化分区,建立 ext4 文件系统rootlocalhost # mkfs -t ext4 /dev/sda3mke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks1966080 inodes, 7864320 blocks393216 blocks (5.00%) reserved for th

12、e super userFirst data block=0Maximum filesystem blocks=2155872256240 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000Allocating group tables: done Wr

13、iting inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done 但是格式化的时候,可能会报错:rootdb1 /# mkfs -t ext4 /dev/sda4mke2fs 1.39 (29-May-2006)Could not stat /dev/sda4 - No such file or directoryThe device apparently does not exist; did you spe

14、cify it correctly?解决方法:执行下 partprobe 命令partprobe 包含在 parted 的 rpm 软件包中。partprobe 可以修改 kernel 中分区表,使 kernel 重新读取分区表。 因此,使用该命令就可以创建分区并且在不重新启动机器的情况下系统能够识别这些分区5、 创建挂载点,并在根目录下创建 data 文件夹,并挂载在这rootlocalhost # mkdir /datarootlocalhost # mount /dev/sda3 /datarootlocalhost # df -hFilesystem Size Used Avail U

15、se% Mounted on/dev/mapper/centos-root 18G 13G 5.1G 72% /devtmpfs 1.9G 0 1.9G 0% /devtmpfs 1.9G 84K 1.9G 1% /dev/shmtmpfs 1.9G 9.0M 1.9G 1% /runtmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup/dev/sda1 497M 159M 339M 32% /boottmpfs 379M 16K 379M 1% /run/user/42tmpfs 379M 0 379M 0% /run/user/0/dev/sda3 30G 45M 28G 1% /data#此为新增的磁盘空间6、最后设置服务器自动

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 事务文书

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号