首先在virtualBox设置里,设置->介质->添加->选add hard disk,在弹出的对话框里选择新建,点击下一步,选择动态扩展,点击下一步,选择大小,点击下一步,完成。
接下来就要在Ubuntu里做相关设置。
进入终端模式
输入sudo fdisk /dev/sdb
会提示
The number of cylinders for this disk is set to 1365.
Command (m for help):
按m看help
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)
按n创建分区,按p是查看分区
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e是创建扩展分区
p是创建主分区
按p
p
Partition number (1-4): 1
First cylinder (1-1044, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): 1044
Command (m for help): w
按w保存退出
格式化开始,我选择的是ext3格式
sudo mkfs -t ext3 /dev/sdb1
然后我把这个硬盘挂在~/src下就可以了
cd ~/src
sudo mkdir sdb1
sudo mount /dev/sdb1 ~/src/sdb1
sudo df
df命令是查看的意思
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda1 3842376 2822092 825096 78% /
tmpfs 190020 0 190020 0% /lib/init/rw
varrun 190020 120 189900 1% /var/run
varlock 190020 0 190020 0% /var/lock
udev 190020 152 189868 1% /dev
tmpfs 190020 76 189944 1% /dev/shm
lrm 190020 2392 187628 2% /lib/modules/2.6.28-11-generic/volatile
/dev/sda5 2885780 117632 2621560 5% /home
/dev/sdb1 10792216 709508 9534492 7% /home/longzaitianguo/src/sdb1
share 20482840 15891500 4591340 78% /mnt/share
(注:这里的share是我的Ubuntu和主机win7的共享文件夹)
然后启动自动挂载
sudo gedit /etc/fstab
会看到如下文字
# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' 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>
proc /proc proc defaults 0 0
# / was on /dev/sda1 during installation
UUID=b7806e98-1a61-48b2-b7c5-466626880479 / ext3 relatime,errors=remount-ro 0 1
# /home was on /dev/sda5 during installation
UUID=94b20c91-2102-4544-8563-683a970b7677 /home ext3 relatime 0 2
# swap was on /dev/sda6 during installation
UUID=9a87d794-1296-4167-aa52-d7e496f8f5a3 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
依葫芦画瓢,添加
/dev/sdb1 ~/src/sdb1 ext3 defaults 0 0
这样就算完成了在虚拟机下添加虚拟硬盘的全部步骤
由于犯2了,把Home 挂载了。文件都找不到了,系统也很慢,1G内存还是很吃力呀。还是等考完研再折腾吧!重新做ubuntu