如何增加虚拟机ubuntu的硬盘

  • 来源: 互联网 作者: 李祥敬   2010-01-18/16:13
  • 一前言:我们刚开始在虚拟机上安装ubuntu的时候,总是舍不得分配太多的硬盘空间。但用着用着时间久了硬盘就不够了。一种最笨的方法就是重装系统,但却费时费神。如果能够在不重装系统的情况下增加硬盘就好了。下面就来实现它。

    二.

    1.首先把ubuntu shutdown.

    2.在VMware里点击菜单VM——>Settings

    3.在Hardware里面单击底下的Add按钮,然后选择Hard Disk——>Next——>Next——>Disk size(GB)是新增硬盘的大小——>Next——>Finish——>Ok. 这样在VMware的Devices里就多了一个Hard Disk 2。

    三,接下来就是进入ubuntu,把新的硬盘mount进去了。

    1.

    root@sparkle-desktop:~# fdisk -l

    Disk /dev/sda: 17.1 GB, 17179869184 bytes

    255 heads, 63 sectors/track, 2088 cylinders

    Units = cylinders of 16065 * 512 = 8225280 bytes

    Disk identifier: 0x000af2a2

    Device Boot Start End Blocks Id System

    /dev/sda1 * 1 993 7976241 83 Linux

    /dev/sda2 994 1044 409657+ 5 Extended

    /dev/sda5 994 1044 409626 82 Linux swap / Solaris

    Disk /dev/sdb: 8589 MB, 8589934592 bytes

    255 heads, 63 sectors/track, 1044 cylinders

    Units = cylinders of 16065 * 512 = 8225280 bytes

    Disk identifier: 0x00000000

    Disk /dev/sdb doesn't contain a valid partition table

    可以看到多了一个 /dev/sdb

    2.

    下面是格式化成ext3文件系统

    root@sparkle-desktop:~# mkfs -t ext3 /dev/sdb

    mke2fs 1.40.8 (13-Mar-2008)

    /dev/sdb is entire device, not just one partition!

    Proceed anyway? (y,n) y //把整个新硬件格式化,不分区。

    Filesystem label=

    OS type: Linux

    Block size=4096 (log=2)

    Fragment size=4096 (log=2)

    524288 inodes, 2097152 blocks

    104857 blocks (5.00%) reserved for the super user

    First data block=0

    Maximum filesystem blocks=2147483648

    64 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

    Writing inode tables: done

    Creating journal (32768 blocks): done

    Writing superblocks and filesystem accounting information: done

    This filesystem will be automatically checked every 26 mounts or

    180 days, whichever comes first. Use tune2fs -c or -i to override.

    root@sparkle-desktop:~#

    3.

    root@sparkle-desktop:~# cd /home

    root@sparkle-desktop:/home# mkdir work

    root@sparkle-desktop:/home# mount /dev/sdb work //把硬盘mount到work目录。

    root@sparkle-desktop:/home# cd work

    root@sparkle-desktop:/home/work# ls

    lost+found

    4.

    用df命令查看一下挂载情况

    root@sparkle-desktop:~# df

    Filesystem 1K-blocks Used Available Use% Mounted on

    /dev/sda1 7913216 7803524 0 100% /

    varrun 257788 240 257548 1% /var/run

    varlock 257788 0 257788 0% /var/lock

    udev 257788 48 257740 1% /dev

    devshm 257788 44 257744 1% /dev/shm

    lrm 257788 39760 218028 16% /lib/modules/2.6.24-19-generic/volatile

    /dev/sdb 8322488 149632 7753428 2% /home/work

    gvfs-fuse-daemon 7913216 7803524 0 100% /root/.gvfs

    看到/dev/sdb 8322488 149632 7753428 2% /home/work

    一项, 可见成功了。

    5.实现启动自动挂载。

    root@sparkle-desktop:~# gedit /etc/fstab

    根据下面的格式

    #

    我们自己添加:

    /dev/sdb /home/work ext3 defaults 0 0

    重启,这样就完成了增加硬盘的全部步骤了。


    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多