`
coolerbaosi
  • 浏览: 721718 次
文章分类
社区版块
存档分类
最新评论

虚拟机 ubuntu里添加第二块硬盘之实例与分析

 
阅读更多

一:图形界面创建硬盘

1.双击“Sun xVMVirtualBox”图标,进入一个界面。

2.在界面的左上方点击设置(有齿轮状的小图标)。

3.进入标题为“Ubuntu -设置“的界面,在界面上点击左上方的硬盘(有盘状图标),紧接着在同一界面的右方显示硬盘设置界面,并可以在右上方看到”+,此时点击”+“,然后按照安装引导安装硬盘(特别要提示的是最好把所要添加的硬盘和第一个硬盘放在同一个文件夹里,便于以后管理,命名方式如:secondDisk.vdi.

4.安装完后,此时仅是给虚拟机建了第二个硬盘,还要把建好的硬盘加载到虚拟机器,需在虚拟机终端执行命令。

二:终端命令加载硬盘

root@ting:~#ls -l /dev/sd*

crw-rw-rw- 1 root tty 2, 61 2010-07-08 16:57 /dev/ptysd

crw-rw-rw- 1 root tty 3, 61 2010-07-08 16:57 /dev/ttysd

root@ting:~#sudo fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSFdisklabel

Building a new DOS disklabel with disk identifier 0x9b0befd0.

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 2843.

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 becorrected by w(rite) Command (m for help):m

Commandaction

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

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4):1

Firstcylinder (1-2843, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2843, default 2843):

Using default value 2843 Command (m for help):w

Thepartition table has been altered! Calling ioctl() to re-read partitiontable.

Syncing disks.

root@ting:~#sudo mkfs /dev/sdb1

mke2fs1.41.3 (12-Oct-2008)

Filesystem label=

OStype: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

1428000 inodes, 5709091 blocks

285454 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=0

175block groups

32768 blocks per group, 32768 fragments per group

8160 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000 Writing inode tables:done

Writingsuperblocks and filesystem accounting information: done This filesystem will beautomatically checked every 36 mounts or

180 days, whichever comes first. Use tune2fs -c or -i tooverride.root@ting:~#mkdir /root/usr/disk

root@ting:~#mount/dev/sdb1 /root/usr/disk

*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~~*~*~*~*~*~*~*~*~*

refer to:http://www.pczpg.com/a/2010/0528/10012.html

virtualbox虚拟机 ubuntu中下添加硬盘实例

2010-05-28 13:22:57作者:佚名来源:浏览次数:77

原来创建的16g大小不够用,添加虚拟硬盘,第二个ide通道,slave从通道

原来创建的16g大小不够用,添加虚拟硬盘,第二个ide通道,slave从通道

一、使用Virtual PC创建一块虚拟硬盘,一般是动态容量,大小根据实际需要就行。然后选择Ubuntu虚拟机,设置。VirtualPC4个虚拟的硬盘接口,除了一个给光驱使用,还剩下3个可以给硬盘,也就是说VirtualPC最多支持挂3个虚拟硬盘。这里我们把硬盘挂在第二个接口上。

二、启动虚拟机,进入Ubuntu后打开终端,键入下列命令:“$ls -l /dev/sd*”。不出意外,你能看到“/dev/sdb”,这个就是我们前面添加的硬盘。

三、接下来就是给硬盘分区了,我们使用“$sudo fdisk /dev/sdb”,输入密码后,我们进入fdisk操作界面“Command(m for help):”。我一般是整个硬盘一个分区,于是键入“n”,创建一个新的分区;然后“p”表示创建主分区;接下来选择主分区号,第一个分区就选“1”(一个硬盘最多能划分成4个主分区)。再接下来连续敲两个回车,按默认值设定分区的柱面起始范围,即所有存贮空间都分配给前面创建的分区;最后键入“w”写分区信息。

四、格式化,格式化比较简单,一条命令就搞定“$sudo mkfs /dev/sdb1”,注意,我们这里的sdb后面多了一个“1”,这表示我们前一步创建的那个主分区。

五、挂载硬盘到目录,例如使用“$mount /dev/sdb1 /home/user/disk”,就可以了,当然你得首先创建“/home/user/disk”这个目录。

六、如果希望每次系统启动都能自动挂载硬盘,则还需要修改“/etc/fstab”。使用vi或者gedit添加以下一行“/dev/sdb1 /home/user/diskext2 defaults 0 0”。这一行一共六个参数,依次是“文件系统所在设备;挂载点;文件系统类型;挂载参数,大多数系统使用"defaults"就可以满足需要;后两个一个是转储,一个是启动顺序,如果没有转储需求,也不是系统启动盘都设置成0就可以了。

经过以上步骤,新添加的硬盘就能正常使用了。不同的系统添加新硬盘的方法大致一样,无非就是有些硬盘是/dev/hdX,有些是/dev/sdXX表示abc

自动挂载

1.先挂硬盘命令:mount

2.得到uuid :ls -all /dev/disk/by-uuid

  1. /Etc/fstab添加

UUID=e4ccc2d4-f11f-43e1-ae67-00b594019da6/dev/sdb1/home/liufei/disk ext2defaults 0 0

源文档 <http://yangtingpretty.blog.163.com/blog/static/18057748620106810201126/>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics