首页 » Linux » 阅读文章

在VMware虚拟机上为linux添加新硬盘

2010-12-18 15:51 4815 0 发表评论
标签:

   相信很多刚入门的朋友总会遇到这样的情况,虚拟机初装的时候分配的硬盘空间太小,后面需要做测试的时候发现硬盘空间不足,才想起来去添加一块硬盘。虽然往上面关于添加硬盘的方法介绍有很多,今天借着自己的操作再记录一次,毕竟有些小细节要处理好。呵呵 废话不多说 进入正题。

一、创建虚拟硬盘

1、关闭你需要添加硬盘的虚拟机

2、选中虚拟机的标签卡,右键–setting–add–hardDisk,调整你需要创建的硬盘空间大小,这里我设置为30G。OK 保存退出。

3、可以看见Hardware中出现了一块新的硬盘Hard Disk 3 (IDE)

 

 

二、分区和格式化

1、首先启动虚拟机 执行

[root@test ~]# fdisk -l    查看你刚才创建的硬盘是否存在

 

2、可以看到 我创建的hdd 硬盘,接下来对hdd进行分区

[root@test ~]# fdisk /dev/hdd

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.
The number of cylinders for this disk is set to 66576.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n      ## 增加一个分区
Command action
e    extended
p    primary partition (1-4)
## 因为通常选择主分区,所以这里打一个p
p
Partition number (1-4): 2     ## 这里我设置为第二个分区(设置分区号时候只要1-4内没有被占用就可以)

First cylinder (1-66576, default 1):  ## 新分区起始的磁盘块数
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-66576, default 66576): 这里选择全部空间,直接回车即可
Using default value 66576

Command (m for help): p

Disk /dev/hdd: 32.2 GB, 32212254720 bytes
15 heads, 63 sectors/track, 66576 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdd2               1       66576    31457128+  83  Linux

3、把分区写进硬盘

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

4、对该硬盘进行格式,我这里是格式化成ext3
[root@test ~]# mkfs.ext3 /dev/hdd2

可以看到我刚添加的硬盘已经存在了

三、挂载硬盘

因为我要用这块硬盘来做yum源的仓储,所以我把它挂在/CentOS这个文件夹下

OK

搞定收工。

本文地址:http://www.jwzzsw.com/archives/653.html

文章作者:思悟
版权所有 © 转载时请以链接形式注明作者和原始出处!

评论 共0条 (RSS 2.0) 发表评论

  1. 暂无评论,快抢沙发吧。

发表评论

联系我 Contact Me

回到页首