virtualBox裡的Ubuntu增加空間

來源:互聯網
上載者:User

      這幾天編譯核心基本上讓我處在崩潰邊緣,最大的問題就是空間不夠。當初給虛擬機器分配空間的時候不知道哪根筋不對才分了2G多,現在報應來了。有人說啦,空間不夠就精簡核心唄。我當然想過,可是對著網上精簡佈建的方法花一個小時調好配置,編譯通過之後完全進入不了新核心。甚至有一次到了輸入使用者名稱和密碼的時候滑鼠和鍵盤集體罷工!!!豈有此理!由於時間問題,精簡核心的方法暫且放放,但是以我的性格肯定不會罷休的,小樣,等有時間了再來削你!

 

      還有人說啦,空間不夠增加虛擬硬碟唄。pinggo,我也是這麼想的,當然也是這麼乾的。下面就說一下在virtualBox給Ubuntu增加虛擬硬碟的方法。

 

     首先在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     

    這樣就算完成了在虛擬機器下添加虛擬硬碟的全部步驟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.