个人工具

“UbuntuHelp:InstallingANewHardDrive/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
用GParted分区
Command Line Partitioning
第64行: 第64行:
 
6) 最后点击"应用"或是从菜单"编辑"->"应该",系统会将你做出的分区操作一条一条执行至完,并格式化好新建的分区.
 
6) 最后点击"应用"或是从菜单"编辑"->"应该",系统会将你做出的分区操作一条一条执行至完,并格式化好新建的分区.
  
=== Command Line Partitioning ===
+
=== 通过命令进行分区操作 ===
You'll be using "fdisk" to accomplish this. Refer back to the logical name you noted from earlier. For illustration, I'll use /dev/hdd, and assume that you want a single partition on the disk, occupying all the free space.
+
这里将在介绍使用"fdisk"来完成分区操作.同样以前面所得到的"logical name"为例.我在这里将使用相对应的"/dev/hdd"进行示例.并假设你要将所有的空间划分为一个分区.
  
If the number of cylinders in the disk is larger than 1024 (and large hard drives always have more), it could, in certain setups, cause problems with:
+
如果你的硬盘柱面超1024(现在的硬盘容量较大,柱面基本都超过这个数值).可能会遇到一些问题,而引发这些问题的原因主要有:
#### software that runs at boot time (e.g., old versions of LILO)
+
#### 在系统启动过程中运行的程序,比如版本较低的LILO引导程序
#### booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
+
#### 其他一些系统的引导程序和分区管理程序,比如DOS和OS/2系统下的FDISK
Otherwise, this will not negatively affect you. 
+
其他就没什么大的问题了
  
1) Initiate fdisk with the following command:
+
1)运行下面的指令来启动'''fdisk'''
 
   <pre><nowiki>
 
   <pre><nowiki>
 
   sudo fdisk /dev/hdd  
 
   sudo fdisk /dev/hdd  
 
   </nowiki></pre>
 
   </nowiki></pre>
  
2) Fdisk will display the following menu:
+
2)'''fdisk'''启动后将会列出下面的菜单:
 
   <pre><nowiki>
 
   <pre><nowiki>
 
   Command (m for help): m <enter>
 
   Command (m for help): m <enter>
第102行: 第102行:
  
  
3) We want to add a new partition.  Type "n" and press enter.
+
3)按下'''n'''来新建一个分区
 
<pre><nowiki>
 
<pre><nowiki>
 
   Command action
 
   Command action
第109行: 第109行:
 
</nowiki></pre>
 
</nowiki></pre>
  
4) We want a primary partition.  Enter "p" and enter.
+
4)按'''p''',建立一个主分区,而按下'''e'''则会建立一个扩展分区
 
<pre><nowiki>
 
<pre><nowiki>
 
   Partition number (1-4):
 
   Partition number (1-4):
 
</nowiki></pre>
 
</nowiki></pre>
  
5) Since this will be the only partition on the drive, number 1.  Enter "1" and enter.  
+
5)我们只想建立一个分区,所以在这里就输入'''1'''  
 
<pre><nowiki>
 
<pre><nowiki>
 
   Command (m for help):
 
   Command (m for help):
 
</nowiki></pre>
 
</nowiki></pre>
  
6) Now that the partition is entered, choose option "w" to write the partition table to the disk.  Type "w" and enter.
+
6)这时建立分区的请求就进入队列中了,输入'''w'''则会将队列中的所有操作提交执行,我们输入'''w'''
 
<pre><nowiki>
 
<pre><nowiki>
 
   The partition table has been altered!
 
   The partition table has been altered!
 
</nowiki></pre>
 
</nowiki></pre>
  
7) If all went well, you now have a properly partitioned hard drive that's ready to be formatted.
+
7)如果分区操作运行得顺利,你现在就已经得到一个等待格式化的分区了.
  
==== Format the Partition via Command Line ====
+
==== 通过命令格式化分区 ====
To format the disk as ext3 filesystem (best for use under Ubuntu):
+
如果想将分区格式化成EXT3格式(Ubuntu下推荐使用),只需执行下面的命令:
 
<pre><nowiki>
 
<pre><nowiki>
 
   sudo mke2fs -j /dev/hdd1
 
   sudo mke2fs -j /dev/hdd1
 
</nowiki></pre>
 
</nowiki></pre>
 
+
注意:请将'''/dev/hdd1'''更改为你的硬盘分区所对应的路径.
Substitute "/dev/hdd1" with your own drive's path.
+
  
 
== Modify reserved space (optional) ==
 
== Modify reserved space (optional) ==

2007年5月18日 (五) 16:07的版本


前言

安装新硬盘这种事情并不会经常,发生同样它也并不复杂.本文将向你说明如何在现有的Ubuntu系统下安装一个新硬盘,并为它设置好分区然后使用它.在动手之前,你需要先考虑下面三个关于新硬盘使用方面的问题:

  • 该硬盘是否只会在Ubuntu下使用?
  • 该硬盘是否要被Ubuntu和windows两类系统使用?
  • 你打算如何分区,是全部空间作一个个分区还是分成数个小分区?

友情提示

仅在Ubuntu环境下使用的硬盘可以考虑划分成EXT3文件系统.若要在Ubuntu和Windows两种环境下使用则应格式化成FAT32文件系统.如果你以前从未接触过“文件系统”“硬盘分区”这些,那在进行接下去的操作之前,我建议你先查阅一些与这类话题有关的资料.

查询硬盘参数

我们假设你的硬盘已经正确安装到你的计算机上,并且在BIOS中已经可以检测到它.

打开端终输入下面的指令即可查询到系统为你新安装的硬盘所指派的路径及其他相关信息:

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: [email protected]
       logical name: /dev/hdd
       version: CA4OA71A
       serial: CSH405DCLSHK6B
       size: 37GB
       capacity: 37GB
  

记录下"logical name"那段的信息,我们在后面的操作中将会用到它.

为硬盘分区

如果你先前已经在这块硬盘上建立了分区并已经往里面存储了数据,那请跳过本段文字前往"挂载点".如果硬盘是空白的且未进行格式化,那你需要完成下面的两件事:

  • 通过终端命令操作完成硬盘的格式化,或安装gparted图形分区软件完成对硬盘的分区和格式化
  • 制定好分区方案,比如是一个分区还是多个分区

用GParted分区

如果你的菜单系统 > 管理 >'中不存在 GNOME Partition Editor这项, 说明你尚未安装GParted.你可以通过"添加/删除程序" 或是 "新力得"安装它,安装完成之后请启动它继续下面的操作

你可以从程序窗体右上角的下拉列表中选择对哪个硬盘进行分区或格式化操作,从中选择我们在前面所记录下的"logical name"相吻合的那个硬盘.系统在数秒内将会重新刷新并显示当前选择硬盘的分区列表信息.假设你的硬盘是一块全新的硬盘,里面尚无任何分区信息,那此时在程序窗体中应该可以看到一块白色的长条形,下面的操作将会把整个硬盘划分为一个分区...

1) 右击白长的长条,在弹出的菜单中选择"新建"

2) 在"新分区大小"系统自动填入了最大的可利用空间,接受系统的默认值即将所有空间划分为一个分区

3) 选择"建立主分区"

4) 接下去就是选择要建立的文件系统类别了,仅在Ubuntu环境下使用的硬盘可以考虑划分成EXT3文件系统.若要在Ubuntu和Windows两种环境下使用则应格式化成FAT32文件系统.如果你对文件系统知之甚少,就去WIKI或论坛上搜索相关资料.

5) 点击"添加",系统将自动刷新新的分区结构.

6) 最后点击"应用"或是从菜单"编辑"->"应该",系统会将你做出的分区操作一条一条执行至完,并格式化好新建的分区.

通过命令进行分区操作

这里将在介绍使用"fdisk"来完成分区操作.同样以前面所得到的"logical name"为例.我在这里将使用相对应的"/dev/hdd"进行示例.并假设你要将所有的空间划分为一个分区.

如果你的硬盘柱面超1024(现在的硬盘容量较大,柱面基本都超过这个数值).可能会遇到一些问题,而引发这些问题的原因主要有:

        1. 在系统启动过程中运行的程序,比如版本较低的LILO引导程序
        2. 其他一些系统的引导程序和分区管理程序,比如DOS和OS/2系统下的FDISK

其他就没什么大的问题了

1)运行下面的指令来启动fdisk

  sudo fdisk /dev/hdd 
  

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):


3)按下n来新建一个分区

  Command action
   e   extended
   p   primary partition (1-4)

4)按p,建立一个主分区,而按下e则会建立一个扩展分区

  Partition number (1-4):

5)我们只想建立一个分区,所以在这里就输入1

  Command (m for help):

6)这时建立分区的请求就进入队列中了,输入w则会将队列中的所有操作提交执行,我们输入w

  The partition table has been altered!

7)如果分区操作运行得顺利,你现在就已经得到一个等待格式化的分区了.

通过命令格式化分区

如果想将分区格式化成EXT3格式(Ubuntu下推荐使用),只需执行下面的命令:

  sudo mke2fs -j /dev/hdd1

注意:请将/dev/hdd1更改为你的硬盘分区所对应的路径.

Modify reserved space (optional)

When formatting the drive, 5% of the drive's total space is reserved for the super-user (Root) so that the operating system can still write to the disk even if it is full. However, for disks that only contain data, this is not necessary.

You can ajust the percentage of reserved space with the "tune2fs" command, like this:

 sudo tune2fs -m 1 /dev/hdd1

This example reserves 1% of space - change this number if you wish.

 {i} Using this command does not change any existing data on the drive. You can use it on a drive which already contains data.

Create a Mount Point

Now that the drive is partitioned and formatted, you need to choose a mount point. This will be the location from which you will access the drive in the future. I would recommend using a mount point with "/media." For this example, we'll use the path "/media/mynewdrive"

  sudo mkdir /media/mynewdrive
  

Now we can mount the drive to the mount point.

  sudo mount /dev/hdd1 /media/mynewdrive
  

If all goes well, you should be able to use your drive at the mount point you chose.

Mount the Drive

You can choose to have the drive mounted automatically each time you boot the computer, or manually only when you need to use it.

Automatic Mount at Boot

You'll need to edit /etc/fstab:

  gksudo gedit /etc/fstab
  

Add this line to the end:

  /dev/hdd1    /media/mynewdrive   ext3    defaults     0	 2
  
 The "2" at the end instructs your system to run a quick file system check on the hard drive at every boot. Changing it to "0" will skip this. Run 'man fstab' for more info here.

You can now run "sudo mount -a" (or reboot the computer) to have the changes take effect.

If you want to allow a normal user to create files on this drive, you can either give this user ownership of the top directory of the drive filesystem: (replace USERNAME with the username)

  sudo chown -R USERNAME:USERNAME /media/mynewdrive
  

or in a more flexible way, practical if you have several users, allow for instance the users in the plugdev group (usually those who are meant to be able to mount removable disks, desktop users) to create files and sub-directories on the disk:

  sudo chgrp plugdev /media/mynewdrive
  sudo chmod g+w /media/mynewdrive
  sudo chmod +t /media/mynewdrive
  

The last "chmod +t" adds the sticky bit, so that people can only delete their own files and sub-directories in a directory, even if they have write permissions to it (see man chmod).


Manually Mount

Alternatively, you may want to manually mount the drive every time you need it.

For manual mounting, use the following command:

sudo mount /dev/hdd1 /media/mynewdrive 

When you are finished with the drive, you can unmount it using:

sudo umount /media/mynewdrive

That's it :)

Need Additional Help?

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

 If you run into problems or need more help, search the wiki or forums at http://ubuntuforums.org.  If you cannot find what you are looking for, simply ask for help.