概述
Ubuntu默认是20GB,空间太小不够用了。
第一步:关闭虚拟机Ubuntu,打开设置->硬件->硬盘,(关机后【扩展】就是可以点击的了)
第二步:开机设置。
ctrl+alt+T:打开terminal,蓝色字体为输入的命令,黄色字体为评注
ubuntu@ubuntu:~$ sudo fdisk /dev/sda
[sudo] password for ubuntu:
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.
首先应该看一下menu,列举了所有的命令,这里用到的p就是“打印分区表”功能。
Command (m for help): p
Disk /dev/sda: 50 GiB, 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
Disklabel type: dos
Disk identifier: 0x8000a0e1
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39845887 39843840 19G 83 Linux
/dev/sda2 39845888 104857599 65011712 31G 5 Extended
/dev/sda5 39847936 41940991 2093056 1022M 83 Linux
原始配置一般是sda1为boot,19G//sda2接着39845888划分1000M左右//最后sda5为swap,大小1000M左右。
这是改过一次后的效果了,无脑配置swap了,sda5和sda2共用了一块重复的空间,再次过来修改,先把错误的sda2删除。
ubuntu@ubuntu:~$ sudo mkfs -t ext4 /dev/sda2
mke2fs 1.42.13 (17-May-2015)
Found a dos partition table in /dev/sda2
Proceed anyway? (y,n) y
mkfs.ext4: inode_size (128) * inodes_count (0) too big for a
filesystem with 0 blocks, specify higher inode_ratio (-i)
or lower inode count (-N).
以上是错误后果,以下是错误操作示例。
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): e
Partition number (2-4, default 2): 2
First sector (39845888-104857599, default 39845888):
Last sector, +sectors or +size{K,M,G,T,P} (39845888-104857599, default 104857599):
Created a new partition 2 of type 'Extended' and of size 31 GiB.
Command (m for help): n
All space for primary partitions is in use.
Adding logical partition 5
First sector (39847936-104857599, default 39847936):
Last sector, +sectors or +size{K,M,G,T,P} (39847936-104857599, default 104857599): 41940991
Created a new partition 5 of type 'Linux' and of size 1022 MiB.
这样做虽然当时是没什么问题,但是格式化和挂载都不能成功,不再丢人了,开始修正。
Command (m for help): d
Partition number (1,2, default 2): 2
d即为delete,删除。
Partition 2 has been deleted.
在删除2后,sda5会自动被删除,新建一个分区,new命令
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (39845888-104857599, default 39845888):41940992
Last sector, +sectors or +size{K,M,G,T,P} (39845888-104857599, default 104857599):
Created a new partition 2 of type 'Linux' and of size 30 GiB.
为了不重复分区,直接从swap后开始划分。
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (39845888-104857599, default 39847936):
Last sector, +sectors or +size{K,M,G,T,P} (39845888-104857599, default 104857599): 41940991
Created a new partition 3 of type 'Linux' and of size 1003.5 MiB.
t命令修改类型
Command (m for help): t
Partition number (1,2,3, default 3): 3
Partition type (type L to list all types): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
Partition type (type L to list all types): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
再检查一下结果
Command (m for help): p
Disk /dev/sda: 50 GiB, 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
Disklabel type: dos
Disk identifier: 0x8000a0e1
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39845887 39843840 19G 83 Linux
/dev/sda2 41900992 104857599 62956608 30G 83 Linux
/dev/sda3 39845888 41900991 2055104 1003.5M 82 Linux swap / Solaris
w命令写入分区表改动,保存退出
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
ubuntu@ubuntu:~$ sudo partprobe
[sudo] password for ubuntu:
挂载到系统目录
ubuntu@ubuntu:~$ sudo mount /dev/sda2 /home/ubuntu/lab
mount: wrong fs type, bad option, bad superblock on /dev/sda2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
这是没有格式化的原因
ubuntu@ubuntu:~$ sudo mkfs -t ext4 /dev/sda2
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 7869576 4k blocks and 1970416 inodes
Filesystem UUID: 78b902e9-64ed-430b-8aac-0dae62910145
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
ubuntu@ubuntu:~$ sudo mount /dev/sda2 /home/ubuntu/lab
没有输出就是挂载成功了,挂载的位置最好是一个空文件夹,最后不要忘记给用户读写磁盘的权限
ubuntu@ubuntu:~$ sudo setfacl -R -m u:ubuntu:rwx /home/ubuntu/lab
为什么要配置swap?
Swap空间的作用可简单描述为:当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当前运行的程序使用。那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被释放的空间被临时保存到Swap空间中,等到那些程序要运行时,再从Swap中恢复保存的数据到内存中。这样,系统总是在物理内存不够时,才进行Swap交换。其实,Swap的调整对Linux服务器,特别是Web服务器的性能至关重要。通过调整Swap,有时可以越过系统性能瓶颈,节省系统升级费用。
原链接:https://blog.csdn.net/mengxingyuanlove/article/details/50992657
最后
以上就是自觉发箍为你收集整理的VMware虚拟机Ubuntu扩容的全部内容,希望文章能够帮你解决VMware虚拟机Ubuntu扩容所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复