博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS6.9 ARM虚拟机扩容系统磁盘
阅读量:4641 次
发布时间:2019-06-09

本文共 3853 字,大约阅读时间需要 12 分钟。

 

由于扩容磁盘的操作非同小可,一旦哪一步出现问题,就会导致分区损坏,数据丢失等一系列严重的问题,因此建议:在进行虚拟机分区扩容之前,一定要备份重要数据文件,并且先在测试机上验证以下步骤,再应用于您的生产机器。如果虚拟机的磁盘不够用了,建议附加新磁盘进行使用,不到万不得已一般不要扩容磁盘分区。

 

操作系统环境:

[root@hlmcent69n1 ~]# cat /etc/redhat-release

CentOS release 6.9 (Final)

 

1.关闭虚拟机

备注:扩容磁盘需要关闭虚拟机,否则无法调整磁盘的大小

 

2.调整磁盘的大小(示例中将原来的30GB调整为了100GB)

 

 

3.等待跟新完成,启动虚拟机,查看到整块磁盘已经变为100G,但/dev/sda1分区还是30G

 

 

4.使用命令:fdisk /dev/sda,重新划分分区/dev/sda1

[root@hlmcent69n1 ~]# fdisk /dev/sdaWARNING: 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): p    ##查看目前的分区信息Disk /dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005498f   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1        3917    31456256   83  LinuxCommand (m for help): u    ##默认以柱面的形式显示,运行该参数后会以扇区的形式显示Changing display/entry units to sectorsCommand (m for help): pDisk /dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005498f   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048    62914559    31456256   83  Linux##记录该标黄的start值Command (m for help): d    ##将原来的/dev/sda1分区删除Selected partition 1Command (m for help): pDisk /dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005498f   Device Boot      Start         End      Blocks   Id  SystemCommand (m for help): n    ##重新创建分区Command action   e   extended   p   primary partition (1-4)pPartition number (1-4): 1First sector (63-209715199, default 63): 2048    ##该值需要与上述标黄的start值相同Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): Using default value 209715199Command (m for help): pDisk /dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005498f   Device Boot      Start         End      Blocks   Id  System/dev/sda1            2048   209715199   104856576   83  LinuxCommand (m for help): a    ##激活分区Partition number (1-4): 1Command (m for help): p    ##再次查看分区,确认已激活,激活后Boot对应的值为*Disk /dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005498f   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048   209715199   104856576   83  LinuxCommand (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 atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.

 

5.使用fdisk –l查看/dev/sda1已经变为了100G,但使用df –h查看/dev/sda1还是30G

 

 

6.此时拉伸文件系统的话,输出信息类似如下,拉伸没有生效。需要重启电脑以便重读分区表后,才能成功拉伸文件系统。备注:可以使用“blkid”命令查看分区的文件系统

 

 

7.重启电脑后,重新使用命令:resize2fs,拉伸Ext4的文件系统,可以看到成功拉伸文件系统

 

 

 8.重新查看,发现/dev/sda1成功拉伸为了100G,并且之前的数据文件仍然存在并可正常使用。

 

 

转载于:https://www.cnblogs.com/stonehe/p/8615336.html

你可能感兴趣的文章
关于python做人工智能的一个网页(很牛逼)
查看>>
判断控件的CGRect是否重合,获取控件的最大XY值
查看>>
POJ-1128 Frame Stacking
查看>>
异常体系
查看>>
String.format(转)
查看>>
解决 CS0006 未能找到元数据文件
查看>>
HDU 5131.Song Jiang's rank list (2014ACM/ICPC亚洲区广州站-重现赛)
查看>>
mysql搭建主从数据库
查看>>
新的一年,新的开始
查看>>
python模块struct
查看>>
图像的灰度级和动态范围(转)
查看>>
C# MODBUS协议 上位机(转)
查看>>
CSS box-shadow 属性
查看>>
vue:图片切换动态显示
查看>>
备忘录
查看>>
软件工程个人作业02
查看>>
pip install 问题
查看>>
vue-router导航守卫,限制页面访问权限
查看>>
2019 Multi-University Training Contest 1 - 1012 - NTT
查看>>
浏览器调试淘宝首页看到有趣的招聘信息
查看>>