首页 > 系统相关 >Ubuntu---扩展虚拟机磁盘容量

Ubuntu---扩展虚拟机磁盘容量

时间:2022-11-18 13:23:57浏览次数:70  
标签:4096 虚拟机 partition bytes dev --- Ubuntu tmpfs 0%

转载:https://hughsite.com/post/linux-fdisk-extend-partition.html

第一步. 虚拟机的虚拟磁盘扩容

virtualbox虚拟机扩容指令:管理员身份运行控制台执行指令: VBoxManage modifyhd "C:UsersXXXVirtualBox VMsWin_XP.vdi" --resize 512000  512000表示重新分配的大小(512G)

 

 

第二步.修改分区大小

进入系统,修改分区大小。

1.查看当前的挂载点:

root@us1804:~$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  924M     0  924M   0% /dev
tmpfs          tmpfs     191M   11M  181M   6% /run
/dev/sda2      ext4       49G   25G   22G  53% /
tmpfs          tmpfs     953M     0  953M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     953M     0  953M   0% /sys/fs/cgroup
/dev/loop0     squashfs   91M   91M     0 100% /snap/core/6350
tmpfs          tmpfs     191M     0  191M   0% /run/user/1000

2.查看分区信息:

root@us1804:~$ fdisk -l
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 6EB98689-A74E-4AE2-B170-7E527EC91CCD

Device     Start       End   Sectors Size Type
/dev/sda1   2048      4095      2048   1M BIOS boot
/dev/sda2   4096 104855551 104851456  50G Linux filesystem

3.修改虚拟硬盘分区大小:

root@us1804:~$ fdisk /dev/sda

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m #查看命令说明

Help:

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): d #先删除分区
Partition number (1,2, default 2): 2 #sda2,分区号是 2

Partition 2 has been deleted.

Command (m for help): n #新建分区,选择主分区就行,p
Partition number (2-128, default 2): 2 #sda2,分区号还是 2
First sector (4096-419430366, default 4096):  #磁盘开始位置,默认回车就行
Last sector, +sectors or +size{K,M,G,T,P} (4096-419430366, default 419430366):  #分配的磁盘大小,全部分配,默认回车就行

Created a new partition 2 of type 'Linux filesystem' and of size 200 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: Y #如果旧的分区有签名信息,移除

The signature will be removed by a write command.

Command (m for help): p #查看新分区信息,可以看到,200G 已经完全分配
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 40301CF6-FD50-414E-8CB2-4BC129149EA7

Device     Start       End   Sectors  Size Type
/dev/sda1   2048      4095      2048    1M BIOS boot
/dev/sda2   4096 419430366 419426271  200G Linux filesystem

Filesystem/RAID signature on partition 2 will be wiped.

Command (m for help): w #保存新分区
The partition table has been altered.
Syncing disks.

4.接下来重启虚拟机 reboot,重启之后更新文件系统大小:

root@us1804:~$ resize2fs /dev/sda2
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 25
The filesystem on /dev/sda2 is now 52428283 (4k) blocks long.

5.查看新分区信息:

root@us1804:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            924M     0  924M   0% /dev
tmpfs           191M   11M  181M   6% /run
/dev/sda2       197G   25G  164G  14% /
tmpfs           953M     0  953M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           953M     0  953M   0% /sys/fs/cgroup
/dev/loop0       91M   91M     0 100% /snap/core/6350
tmpfs           191M     0  191M   0% /run/user/1000

 

标签:4096,虚拟机,partition,bytes,dev,---,Ubuntu,tmpfs,0%
From: https://www.cnblogs.com/linxisuo/p/16902887.html

相关文章

  • aws-成本分析
    https://docs.aws.amazon.com/zh_cn/awsaccountbilling/latest/aboutv2/aws-tags.htmlhttps://docs.aws.amazon.com/zh_cn/awsaccountbilling/latest/aboutv2/activate-bu......
  • ceph-学习
    https://bbs.huaweicloud.com/blogs/357515#::text=%E6%9F%A5%E7%9C%8Bpg%E7%9A%84%E6%95%B0%E9%87%8F%20%5Broot%40ceph-node-1%20%5D%23%20ceph%20osd%20pool%20get%20ce......
  • spring-security 跨域配置
    跨域问题是实际应用开发中一个非常常见的需求,在Spring框架中对于跨域问题的处理方案有好几种,引入了SpringSecurity之后,跨域问题的处理方案又增加了。1.什么是CORSCORS(C......
  • React-hooks+TypeScript最佳实战
    ReactHooks什么是HooksReact一直都提倡使用函数组件,但是有时候需要使用state或者其他一些功能时,只能使用类组件,因为函数组件没有实例,没有生命周期函数,只有类组件才......
  • git clone 指定 ssh-key 文件
    环境&软件macOS问题gitclone不是默认ssh-key,无法克隆解决方法用ssh-add命令将对应的私钥加入到缓存//ssh-add自定义名称//例子ssh-addid_ed255......
  • How to Install Minikube on Ubuntu 20.04
    安装容器运行时1、若您安装过docker,需要先删掉,之后再安装依赖sudoapt-getremovedockerdocker-enginedocker.iosudoapt-getinstallapt-transport-httpsca-certi......
  • activiti流程引擎-流程部署
    这是对于activiti如何部署流程的一篇博客,希望可以帮助到刚学习activiti的小伙伴。定义:将流程设计器的流程部署到activiti数据库表中即是流程的部署如何去做这件事情呢......
  • python笔记76-types.FunctionType 动态创建函数
    前言types.FunctionType创建函数有2种方式:从已有函数的基础上,创建一个新函数从一个compile构建的函数对象上,创建一个新函数FunctionType使用FunctionType可以用......
  • P3527 [POI2011]MET-Meteors
    P3527[POI2011]MET-Meteors目录P3527[POI2011]MET-Meteors题意正文主席树code:整体二分拆分区间code:题意给定一段1-m的区间,n个国家,每个位置属于一个国家每个国家有......
  • CVE-2016-5734 复现
    CVE-2016-5734漏洞简介phpMyAdmin4.0.x—4.6.2远程代码执行漏洞(CVE-2016-5734)phpMyAdmin是一套开源的、基于Web的MySQL数据库管理工具。在其查找并替换字符串功能中,将......