Ubuntu Linux 硬碟資料分割配置詳解

來源:互聯網
上載者:User

 

 

 

怎麼給Ubuntu合理的分個區呢?以前安裝Linux都是使用自動分配磁碟{
function onclick()
{

}
}" onmouseover="function onmouseover()
{
function onmouseover()
{
if(typeof(showTitle)!='undefined'){this.title='';window.clearTimeout(hideTO);showTitle(event, this, 5,'');}
}
}" onmouseout="function onmouseout()
{
function onmouseout()
{
if(typeof(showTitle)!='undefined'){mouseIsOverLayer = false; mouseOverWhileLoad = false; hideTO = window.setTimeout('checkIfMouseOverLayer()',500);}
}
}" href="http://action.utops.cc/click.jsp?adsId=82&adsLeagueId=5&adsUserId=188&siteId=657&siteLeagueId=5&siteUserId=564&scId=2&adsType=2&prices=0.8&checkCode=b7e9d86563d12e19dfbdb3123c922bfb_122.226.213.12&click=1&url=http%3A//campaign.rubiconworld.com.cn/Rubicon.html%23/Conquer&v=0&keyword=%u7A7A%u95F4&s=http%3A//www.linuxidc.com/Linux/2007-10/8131.htm&rn=557296---2010-6-13-19:51:5" target="_blank">空間,{
function onclick()
{

}
}" onmouseover="function onmouseover()
{
function onmouseover()
{
if(typeof(showTitle)!='undefined'){this.title='';window.clearTimeout(hideTO);showTitle(event, this, 0,'');}
}
}" onmouseout="function onmouseout()
{
function onmouseout()
{
if(typeof(showTitle)!='undefined'){mouseIsOverLayer = false; mouseOverWhileLoad = false; hideTO = window.setTimeout('checkIfMouseOverLayer()',500);}
}
}" href="http://action.utops.cc/click.jsp?adsId=428&adsLeagueId=5&adsUserId=1&siteId=657&siteLeagueId=5&siteUserId=564&scId=2&adsType=98&prices=1.51&checkCode=1afed04f041a20763e20afd6fb4c84be_122.226.213.12&click=1&url=http%3A//www.totole.com.cn&v=0&keyword=%u611F%u89C9&s=http%3A//www.linuxidc.com/Linux/2007-10/8131.htm&rn=167100---2010-6-13-19:51:5" target="_blank">感覺這樣不太專業,於是乎在百度和GOOGLE中找了一通,看到一篇不錯的。。鬱悶的是並 沒有發現文中所說的擴充分區設定(選項中只看到主要磁碟分割和邏輯分區,我的理解是他會自動將這些邏輯分區列入擴充分區,不知對否?)。也沒有看到掛載swap 的選項(我是自己手動填寫的)

一、Linux 分區概念

首先介紹一下linux中的分區概念,這個可是把一開始學習的我害苦了。在 Linux 中規定,每{
function onclick()
{

}
}" onmouseover="function onmouseover()
{
function onmouseover()
{
if(typeof(showTitle)!='undefined'){this.title='';window.clearTimeout(hideTO);showTitle(event, this, 2,'');}
}
}" onmouseout="function onmouseout()
{
function onmouseout()
{
if(typeof(showTitle)!='undefined'){mouseIsOverLayer = false; mouseOverWhileLoad = false; hideTO = window.setTimeout('checkIfMouseOverLayer()',500);}
}
}" href="http://action.utops.cc/click.jsp?adsId=426&adsLeagueId=5&adsUserId=1&siteId=657&siteLeagueId=5&siteUserId=564&scId=2&adsType=98&prices=1.51&checkCode=ae7a61e980922caa789ff11c81e27996_122.226.213.12&click=1&url=http%3A//www.totole.com.cn&v=0&keyword=%u4E00%u4E2A&s=http%3A//www.linuxidc.com/Linux/2007-10/8131.htm&rn=302962---2010-6-13-19:51:5" target="_blank">一個硬碟裝置最多能有 4 個主要磁碟分割(其中包含擴充分區)構成,任何一個擴充分區都要佔用一個主要磁碟分割號碼,也{
function onclick()
{

}
}" onmouseover="function onmouseover()
{
function onmouseover()
{
if(typeof(showTitle)!='undefined'){this.title='';window.clearTimeout(hideTO);showTitle(event, this, 3,'');}
}
}" onmouseout="function onmouseout()
{
function onmouseout()
{
if(typeof(showTitle)!='undefined'){mouseIsOverLayer = false; mouseOverWhileLoad = false; hideTO = window.setTimeout('checkIfMouseOverLayer()',500);}
}
}" href="http://action.utops.cc/click.jsp?adsId=412&adsLeagueId=5&adsUserId=1&siteId=657&siteLeagueId=5&siteUserId=564&scId=2&adsType=98&prices=1.51&checkCode=37bce613ff4c1791ea20ca05d521f748_122.226.213.12&click=1&url=http%3A//www.foho.cc/totole/index.html&v=0&keyword=%u5C31%u662F&s=http%3A//www.linuxidc.com/Linux/2007-10/8131.htm&rn=61866---2010-6-13-19:51:5" target="_blank">就是在一個硬碟中,主要磁碟分割和擴充分區一共最多是 4 個。對於早期的 DOS 和 Windows(Windows 2000 以前的版本),系統只承認一個主要磁碟分割,可以通過在擴充分區上增加邏輯盤符(邏輯分區)的方法,進一步地細化分區。

主要磁碟分割的作用就是電腦用來進行啟動作業系統的,因此每一個作業系統的啟動,或者稱作是引導程式,都應該存放在主要磁碟分割上。這就是主要磁碟分割和擴充分區及邏輯分區 的最大區別。我們在指定安裝引導 Linux 的 bootloader 的時候,都要指定在主要磁碟分割上,就是最好的例證。

Linux 規定了主要磁碟分割(或者擴充分區)佔用 1 至 16 號碼中的前 4 個號碼。以第一個 IDE 硬碟為例說明,主要磁碟分割(或者擴充分區)佔用了 hda1、hda2、hda3、hda4,而邏輯分區佔用了 hda5 到 hda16 等 12 個號碼。因此,Linux 下面每一個硬碟總共最多有 16 個分區。

對於邏輯分區,Linux 規定它們必須建立在擴充分區上(在 DOS 和 Windows 系統上也是如此規定),而不是主要磁碟分割上。因此,我們可以看到擴充分區能夠提供更加靈活的分區模式,但不能用來作為作業系統的引導。

以前對這些概念不熟,分區上走了很多彎路。那麼,到底什麼樣是一個好的分區{
function onclick()
{

}
}" onmouseover="function onmouseover()
{
function onmouseover()
{
if(typeof(showTitle)!='undefined'){this.title='';window.clearTimeout(hideTO);showTitle(event, this, 4,'');}
}
}" onmouseout="function onmouseout()
{
function onmouseout()
{
if(typeof(showTitle)!='undefined'){mouseIsOverLayer = false; mouseOverWhileLoad = false; hideTO = window.setTimeout('checkIfMouseOverLayer()',500);}
}
}" href="http://action.utops.cc/click.jsp?adsId=250&adsLeagueId=5&adsUserId=188&siteId=657&siteLeagueId=5&siteUserId=564&scId=2&adsType=2&prices=0.8&checkCode=3f195a44aff673827d16b372fce75881_122.226.213.12&click=1&url=http%3A//eshopping.ganso.com.cn/index.php%3Fmain_page%3Dindex%26cPath%3D23%26zenid%3D35fs71rcmjliagpbmpobrp41f7&v=0&keyword=%u65B9%u6848&s=http%3A//www.linuxidc.com/Linux/2007-10/8131.htm&rn=622981---2010-6-13-19:51:5" target="_blank">方案,我認為見仁見智,我是這樣分的。原則上/ 和/home基本上最好是要單獨掛載兩個分區,因為home可以看成是windows中的my document,自己設定檔多的話home要大一些。/小一點無所謂,據說至少2G,我也沒有實驗過。其他的諸如/tmp和/var由於活動檔案特別 多,為了避免他們的檔案片段對其他區的影響,最好他們掛一個區。最後/opt主要安裝大型軟體,如果有多餘的分區就給他掛一個吧。

  

1 在live CD的{
function onclick()
{

}
}" onmouseover="function onmouseover()
{
function onmouseover()
{
if(typeof(showTitle)!='undefined'){this.title='';window.clearTimeout(hideTO);showTitle(event, this, 1,'');}
}
}" onmouseout="function onmouseout()
{
function onmouseout()
{
if(typeof(showTitle)!='undefined'){mouseIsOverLayer = false; mouseOverWhileLoad = false; hideTO = window.setTimeout('checkIfMouseOverLayer()',500);}
}
}" href="http://action.utops.cc/click.jsp?adsId=250&adsLeagueId=5&adsUserId=188&siteId=657&siteLeagueId=5&siteUserId=564&scId=2&adsType=2&prices=1.33&checkCode=573d00e05a34d5d78cc73f0101f74fbc_122.226.213.12&click=1&url=http%3A//eshopping.ganso.com.cn/index.php%3Fmain_page%3Dindex%26cPath%3D23%26zenid%3D35fs71rcmjliagpbmpobrp41f7&v=0&keyword=%u73AF%u5883&s=http%3A//www.linuxidc.com/Linux/2007-10/8131p3.htm&rn=963708---2010-6-13-19:49:49" target="_blank">環境中,在終端下直接用sudo fdisk /dev/xxx

來分區,然後w儲存後reboot,之後再進安裝工具,手工編輯註冊表時它認得的就是你編輯的分區表,不

用修改直接下一步即可。

2 你也可以同樣用livecd的fdisk分好區後,用光碟片上的livecd

installer程式,在命令列下安裝。不過這個安裝程式只需要你掛載/和swap。那麼其他分區怎麼辦呢?

 

可以先在分好,也可以安裝完系統再分。如果將其他分區掛載到希望的目錄下?舉個例子。如果你想把/

home/user掛載到新的sda8分區下,可以這樣做:

首先,將/dev/sda8 mount到 /mnt/sda8中。如果沒有這個目錄就自己mkdir。

然後,cp -R /home/user/* /mnt/sda8/user ,和cp -R /home/user/.* /mnt/sda8/user

最後修改/etc/fstab,增加一行/dev/sda8  /home ext3  defaults  0  2(參數自己確定)即可。

二、開始分區

ok, 我就這樣看,首先分{
function onclick()
{

}
}" onmouseover="function onmouseover()
{
function onmouseover()
{
if(typeof(showTitle)!='undefined'){this.title='';window.clearTimeout(hideTO);showTitle(event, this, 1,'');}
}
}" onmouseout="function onmouseout()
{
function onmouseout()
{
if(typeof(showTitle)!='undefined'){mouseIsOverLayer = false; mouseOverWhileLoad = false; hideTO = window.setTimeout('checkIfMouseOverLayer()',500);}
}
}" href="http://action.utops.cc/click.jsp?adsId=426&adsLeagueId=5&adsUserId=1&siteId=657&siteLeagueId=5&siteUserId=564&scId=2&adsType=98&prices=1.51&checkCode=21dfe5f395a2be4c57bb349f8ea59973_122.226.213.12&click=1&url=http%3A//www.totole.com.cn&v=0&keyword=%u4E00%u4E2A&s=http%3A//www.linuxidc.com/Linux/2007-10/8131p2.htm&rn=648174---2010-6-13-19:51:21" target="_blank">一個100M的主要磁碟分割出來,掛載boot。grub啟動時需要的檔案都在/ b o o t 目錄。這樣就算工作分區出了問題,只要這個分區沒有問題,同樣可以啟動。因此最好的辦法就是專門為根檔案分一個區,大小一般最多64M,我為了保險給了 100M。

之後的分區全部以擴充分區形式存在,擴充分區下很多邏輯分區。

首先建立一個交換分區,大小是無力記憶體的一倍到兩倍大。如果你的記憶體和我一樣是1G,就劃1G好了。事實上基本用不到這麼大。分區格式記著改成linux-swap。

 

然後建立一個盡量大的分區,給/usr,因為這裡存放有大部分的系統軟體,包括X Server等圖形介面程式。我分了20G。

接下來建立/home的掛載分區。考慮到我的工作文檔比較多,原始碼和程式也經常放到這裡,所以給了10G。

其他的諸如tmp,var等來說,單使用者工作機是不用考慮的。當然不知道我的機器以後會不會有伺服器應用,我還是給var分了2G的空間。

其他空間就全部掛載給/。雖然一般2G就夠了,但是多多益善麼。

注意:很多時候,如果你使用了Ubuntu光碟片內建的安裝工具分區,會出現很多問題。如果遇到問題過不去,推薦兩個辦法:

1 在live CD的{

}" onmouseover="function onmouseover()
{
if(typeof(showTitle)!='undefined'){this.title='';window.clearTimeout(hideTO);showTitle(event, this, 1,'');}
}" onmouseout="function onmouseout()
{
if(typeof(showTitle)!='undefined'){mouseIsOverLayer = false; mouseOverWhileLoad = false; hideTO = window.setTimeout('checkIfMouseOverLayer()',500);}
}" href="http://action.utops.cc/click.jsp?adsId=250&adsLeagueId=5&adsUserId=188&siteId=657&siteLeagueId=5&siteUserId=564&scId=2&adsType=2&prices=1.33&checkCode=573d00e05a34d5d78cc73f0101f74fbc_122.226.213.11&click=1&url=http%3A//eshopping.ganso.com.cn/index.php%3Fmain_page%3Dindex%26cPath%3D23%26zenid%3D35fs71rcmjliagpbmpobrp41f7&v=0&keyword=%u73AF%u5883&s=http%3A//www.linuxidc.com/Linux/2007-10/8131p3.htm&rn=447505---2010-6-13-20:21:19" target="_blank">環境中,在終端下直接用sudo fdisk /dev/xxx

來分區,然後w儲存後reboot,之後再進安裝工具,手工編輯註冊表時它認得的就是你編輯的分區表,不

用修改直接下一步即可。

2 你也可以同樣用livecd的fdisk分好區後,用光碟片上的livecd

installer程式,在命令列下安裝。不過這個安裝程式只需要你掛載/和swap。那麼其他分區怎麼辦呢?

 

可以先在分好,也可以安裝完系統再分。如果將其他分區掛載到希望的目錄下?舉個例子。如果你想把/

home/user掛載到新的sda8分區下,可以這樣做:

首先,將/dev/sda8 mount到 /mnt/sda8中。如果沒有這個目錄就自己mkdir。

然後,cp -R /home/user/* /mnt/sda8/user ,和cp -R /home/user/.* /mnt/sda8/user

最後修改/etc/fstab,增加一行/dev/sda8  /home ext3  defaults  0  2(參數自己確定)即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.