安裝新硬碟

出自Ubuntu中文

目錄

[編輯] 安裝新硬碟

原文出處:官方WIKI

原文作者:

授權許可:

翻譯人員:sanebaby

校正人員:purewind

貢獻人員:

適用版本: 文章狀態:翻譯完成



[編輯] Introduction(說明)

本文將說明在添加了新的磁碟后如何配置Ubuntu使其可以訪問。我們假定磁碟已經被物理安裝,且已經被BIOS檢測到。

這裏需要了解基本的命令行的用法。

[編輯] Find drive info(找到硬碟信息)

找出系統標示的磁碟的 盤符/編號:

sudo lshw -C disk

IconsPage?action=AttachFile&do=get&target=IconExample48.png

這有一個輸出樣本:

**-disk
description: ATA Disk
product: IC25N040ATCS04-0
vendor: Hitachi
physical id: 0
bus info: ide@0.0
logical name: /dev/hda
version: CA4OA71A
serial: CSH405DCLSHK6B
size: 37GB
capacity: 37GB

[編輯] Set up drive(設置硬碟)

如果你的磁碟上已經有數據存在,請跳至"Set mount point"(設定載入點) 。否則您需要決定把該硬碟作為一個大分區使用還是分為幾個小的分區。您將用 fdisk 來完成這項工作。例如我將使用/dev/hdd1;

sudo fdisk /dev/hdd

這個磁碟的柱面數為77557。這沒有任何錯誤,但是大於1024可能會在一些特定的設置中引起問題:

  • 啟動過程中運行的軟體(如:老版本的LILO)
  • 其它作業系統中的引導和分區軟體(如:DOS FDISK,OS/2 FDISK)
Command (m for help): m <enter>
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)
Command (m for help):n <enter>
Command action
e   extended
p   primary partition (1-4)
p <enter>
Partition number (1-4):
1 <enter>
Command (m for help):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
user@myubuntubox:~ $

[編輯] Format disk(格式化磁碟)

您可以像這樣格式化磁碟(我將磁碟格式化為ext3格式)

sudo mke2fs -j /dev/hdd1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4889248 inodes, 9772174 blocks
488608 blocks (5.00%) reserved for the super user
First data block=0
299 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632,
2654208, 4096000, 7962624

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
user@myubuntubox:~ $

[編輯] Modify reserved space (optional)(修改保留空間-可選)

當您格式化磁碟時,為了保證作業系統在磁碟己滿的情況下仍能寫入數據,5%的磁碟空間將保留給管理員。然而,對於只用來存放數據的磁碟並不需要。您可以用「tune2fs」命令調整保留空間的百分比,像這樣:

sudo tune2fs -m 1 /dev/hdd1

上面的例子保留了1%的空間--如果需要您可以修改此數字。

{i} 使用這條命令不會影響磁碟上的數據。您可以在任何含有數據的磁碟上使用該命令。

[編輯] Set mount point(設定掛載點)

接下來設定您的掛載點:

sudo mkdir /backup

and mount it:
掛載:

sudo mount /dev/hdd1 /backup

[編輯] Set to mount at boot(設定為啟動掛載)

接下來添加一條內容到 /etc/fstab ,用已存在的內容作為參照。現在您可以使用如下命令來掛載或缷載您的新磁碟:

sudo mount /backup

{i} 這裏有一個針對fstab的好指南。

缷載磁碟

sudo umount /backup <enter>

好了 :)

[編輯] Need help?(需要幫助? )

IconsPage?action=AttachFile&do=get&target=IconHelp.png

如果您在運行過程中遇到了問題或需要更多的幫助,請在wiki中搜索或到 http://ubuntuforums.org 尋求幫助。