VMware虚拟机Ubuntu增加硬盘空间
Android4.1源码出来,没事也想下载下来看一下,结果悲剧的发现虚拟机上给Ubuntu分配的硬盘空间太小了,就剩下2.7G。而在官方文档中:The source download is approximately 6GB in size,说明源代码大小在6G左右,只好为Vmware虚拟机中的ubuntu再挂载一个20G的硬盘。
(1) 增加虚拟机硬盘。
首先,打开Vmware里面VM里面的setting。如下图:
进入设置界面:
选择Hard Disk,点击下面Add:
点击next:选择Create a new virtual disk
然后再选择next,选择硬盘类型为SCSI。
继续next,设置硬盘大小:
继续:指定硬盘文件
就这样是先创建了一个20G的硬盘,但是ubuntu并不能识别它。你得格式化该硬盘,格完然后挂在ubuntu上告诉他启动的mount上这个新的分区。
(2)在Ubuntu里面格式化该硬盘,并重新mount在新建的文件夹。
在命令行里面:
a) #sudo fdisk -l
查看当前ubuntu磁盘的信息,发现新增加的硬盘(/dev/sdb)还没有分区
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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
Disk identifier: 0x00040a03
Device Boot Start End Blocks Id System
/dev/sda1 2048 2000895 999424 82 Linux swap / Solaris
/dev/sda2 * 2000896 3000319 499712 83 Linux
/dev/sda3 3000320 41940991 19470336 83 Linux
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 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
Disk identifier: 0x00000000
Disk /dev/sdb doesn‘t contain a valid partition table-----这就是刚刚新增加的硬盘
b) 对/dev/sdb进行分区 ,得到/dev/sdb1
bert@bert-vm:~$ sudo fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x204bffc4.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won‘t be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition‘s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-83886079, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-83886079, default 83886079):
Using default value 83886079
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks
c) 格式化新的分区/dev/sdb1
bert@bert-vm:~$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42 (29-Nov-2011)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10485504 blocks
524275 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
d) 将新建的分区挂载在指定的目录(比如创建/home/download目录)
mount /dev/sdb1 /home/download -t ext4 其中home/download替换为你要挂载的空文件夹就可以了。这样我们找到download这个文件夹,就会发现它有近20G的空间,挂载成功。
比如执行df -h会看到
bert@bert-vm:~$ df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 19G 8.6G 9.1G 49% /
udev 486M 4.0K 486M 1% /dev
tmpfs 198M 812K 197M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 495M 152K 495M 1% /run/shm
/dev/sda2 485M 47M 415M 11% /boot
/dev/sdb1 20G 733M 20G 2% /home/download
bert@bert-vm:~$
e) 为了避免每次重启之后都要重新挂载/dev/sdb1分区,我们可以直接修改/etc/fstab文件,最后一行增加如下内容:
/dev/sdb1 /home/download auto rw 0 0
保存退出,reboot之后
bert@bert-vm:~$ df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 19G 8.6G 9.1G 49% /
udev 486M 4.0K 486M 1% /dev
tmpfs 198M 816K 197M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 495M 152K 495M 1% /run/shm
/dev/sda2 485M 47M 415M 11% /boot
/dev/sdb1 20G 733M 20G 2% /home/download
bert@bert-vm:~$
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。