虚拟机ubuntu增加磁盘

虚拟机软件vmware,系统ubuntu 16.04

系统存储空间不够用了,需要扩充一下,记录一下操作步骤。

先关掉虚拟机系统,打开虚拟机设置--硬件--选中“硬盘”--点击右侧的“扩展”按钮,输入想要的空间大小,点“确定”,启动虚拟机。

进入虚拟机后,打开终端,使用fdisk查看分区信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
robot@ubuntu:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
 
Command (m for help): p
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 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
Disklabel type: dos
Disk identifier: 0x7c03249e
 
Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 81885183 81883136   39G 83 Linux
/dev/sda2       81887230 83884031  1996802  975M  5 Extended
/dev/sda5       81887232 83884031  1996800  975M 82 Linux swap / Solaris

  因sda1的起始和终止与后面的sda2相连,故删除重建分区还是原大小。所以选择了新建一个分区(参数均采用默认):

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
Command (m for help): n
Partition type
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p):
 
Using default response p.
Partition number (3,4, default 3):
First sector (83884032-125829119, default 83884032):
Last sector, +sectors or +size{K,M,G,T,P} (83884032-125829119, default 125829119):
 
Created a new partition 3 of type 'Linux' and of size 20 GiB.
 
Command (m for help): p
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 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
Disklabel type: dos
Disk identifier: 0x7c03249e
 
Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1           2048  81887229 81885182   39G 83 Linux
/dev/sda2       81887230  83884031  1996802  975M  5 Extended
/dev/sda3       83884032 125829119 41945088   20G 83 Linux
/dev/sda5       81887232  83884031  1996800  975M 82 Linux swap / Solaris

  给新分区创建文件系统:

1
2
3
4
5
6
7
8
9
10
11
12
sudo mkfs.ext4 /dev/sda3
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 5242880 4k blocks and 1313280 inodes
Filesystem UUID: e5f39deb-a714-48df-bf8e-67ef0a7d5948
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000
 
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

  

挂载新分区

1
2
3
4
5
6
7
8
9
10
11
12
robot@ubuntu:~$ sudo mount /dev/sda3 /mnt/ssd1
robot@ubuntu:~$ df
Filesystem     1K-blocks     Used Available Use% Mounted on
udev             1494984        0   1494984   0% /dev
tmpfs             304952     5096    299856   2% /run
/dev/sda1       40168028 33301852   4802716  88% /
tmpfs            1524748      188   1524560   1% /dev/shm
tmpfs               5120        4      5116   1% /run/lock
tmpfs            1524748        0   1524748   0% /sys/fs/cgroup
tmpfs             304952       28    304924   1% /run/user/108
tmpfs             304952        0    304952   0% /run/user/1000
/dev/sda3       20510716    44992  19400768   1% /mnt/ssd1

  

修改fstab,实现开机自动挂载

使用blkid查看分区UUID,并修改fstab文件(最后加一行:UUID=e5f39deb-a714-48df-bf8e-67ef0a7d5948 /mnt/ssd1               ext4    defaults 0       2)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
robot@ubuntu:~$ sudo blkid
/dev/sda1: UUID="05e3875f-b01d-4aac-89dd-f81f2e8b9855" TYPE="ext4" PARTUUID="7c03249e-01"
/dev/sda3: UUID="e5f39deb-a714-48df-bf8e-67ef0a7d5948" TYPE="ext4" PARTUUID="7c03249e-03"
/dev/sda5: UUID="2a5c42cc-859d-4491-a06d-814d6b88b06e" TYPE="swap" PARTUUID="7c03249e-05"
 
robot@ubuntu:~$ sudo vi /etc/fstab
robot@ubuntu:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=05e3875f-b01d-4aac-89dd-f81f2e8b9855 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=2a5c42cc-859d-4491-a06d-814d6b88b06e none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
UUID=e5f39deb-a714-48df-bf8e-67ef0a7d5948 /mnt/ssd1               ext4    defaults 0       2

  这样就扩展了一个新分区。

 

感谢链接:

https://blog.csdn.net/qq_35724582/article/details/135150889

https://www.yisu.com/ask/65087426.html

posted @   strongbug1  阅读(162)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」
点击右上角即可分享
微信分享提示