特殊:Badtitle/NS100:InstallingANewHardDrive/zh
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/InstallingANewHardDrive }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/af | • {{#if: UbuntuHelp:InstallingANewHardDrive|Afrikaans| [[::InstallingANewHardDrive/zh/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/ar | • {{#if: UbuntuHelp:InstallingANewHardDrive|العربية| [[::InstallingANewHardDrive/zh/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/az | • {{#if: UbuntuHelp:InstallingANewHardDrive|azərbaycanca| [[::InstallingANewHardDrive/zh/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/bcc | • {{#if: UbuntuHelp:InstallingANewHardDrive|جهلسری بلوچی| [[::InstallingANewHardDrive/zh/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/bg | • {{#if: UbuntuHelp:InstallingANewHardDrive|български| [[::InstallingANewHardDrive/zh/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/br | • {{#if: UbuntuHelp:InstallingANewHardDrive|brezhoneg| [[::InstallingANewHardDrive/zh/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/ca | • {{#if: UbuntuHelp:InstallingANewHardDrive|català| [[::InstallingANewHardDrive/zh/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/cs | • {{#if: UbuntuHelp:InstallingANewHardDrive|čeština| [[::InstallingANewHardDrive/zh/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/de | • {{#if: UbuntuHelp:InstallingANewHardDrive|Deutsch| [[::InstallingANewHardDrive/zh/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/el | • {{#if: UbuntuHelp:InstallingANewHardDrive|Ελληνικά| [[::InstallingANewHardDrive/zh/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/es | • {{#if: UbuntuHelp:InstallingANewHardDrive|español| [[::InstallingANewHardDrive/zh/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/fa | • {{#if: UbuntuHelp:InstallingANewHardDrive|فارسی| [[::InstallingANewHardDrive/zh/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/fi | • {{#if: UbuntuHelp:InstallingANewHardDrive|suomi| [[::InstallingANewHardDrive/zh/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/fr | • {{#if: UbuntuHelp:InstallingANewHardDrive|français| [[::InstallingANewHardDrive/zh/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/gu | • {{#if: UbuntuHelp:InstallingANewHardDrive|ગુજરાતી| [[::InstallingANewHardDrive/zh/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/he | • {{#if: UbuntuHelp:InstallingANewHardDrive|עברית| [[::InstallingANewHardDrive/zh/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/hu | • {{#if: UbuntuHelp:InstallingANewHardDrive|magyar| [[::InstallingANewHardDrive/zh/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/id | • {{#if: UbuntuHelp:InstallingANewHardDrive|Bahasa Indonesia| [[::InstallingANewHardDrive/zh/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/it | • {{#if: UbuntuHelp:InstallingANewHardDrive|italiano| [[::InstallingANewHardDrive/zh/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/ja | • {{#if: UbuntuHelp:InstallingANewHardDrive|日本語| [[::InstallingANewHardDrive/zh/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/ko | • {{#if: UbuntuHelp:InstallingANewHardDrive|한국어| [[::InstallingANewHardDrive/zh/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/ksh | • {{#if: UbuntuHelp:InstallingANewHardDrive|Ripoarisch| [[::InstallingANewHardDrive/zh/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/mr | • {{#if: UbuntuHelp:InstallingANewHardDrive|मराठी| [[::InstallingANewHardDrive/zh/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/ms | • {{#if: UbuntuHelp:InstallingANewHardDrive|Bahasa Melayu| [[::InstallingANewHardDrive/zh/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/nl | • {{#if: UbuntuHelp:InstallingANewHardDrive|Nederlands| [[::InstallingANewHardDrive/zh/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/no | • {{#if: UbuntuHelp:InstallingANewHardDrive|norsk| [[::InstallingANewHardDrive/zh/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/oc | • {{#if: UbuntuHelp:InstallingANewHardDrive|occitan| [[::InstallingANewHardDrive/zh/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/pl | • {{#if: UbuntuHelp:InstallingANewHardDrive|polski| [[::InstallingANewHardDrive/zh/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/pt | • {{#if: UbuntuHelp:InstallingANewHardDrive|português| [[::InstallingANewHardDrive/zh/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/ro | • {{#if: UbuntuHelp:InstallingANewHardDrive|română| [[::InstallingANewHardDrive/zh/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/ru | • {{#if: UbuntuHelp:InstallingANewHardDrive|русский| [[::InstallingANewHardDrive/zh/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/si | • {{#if: UbuntuHelp:InstallingANewHardDrive|සිංහල| [[::InstallingANewHardDrive/zh/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/sq | • {{#if: UbuntuHelp:InstallingANewHardDrive|shqip| [[::InstallingANewHardDrive/zh/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/sr | • {{#if: UbuntuHelp:InstallingANewHardDrive|српски / srpski| [[::InstallingANewHardDrive/zh/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/sv | • {{#if: UbuntuHelp:InstallingANewHardDrive|svenska| [[::InstallingANewHardDrive/zh/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/th | • {{#if: UbuntuHelp:InstallingANewHardDrive|ไทย| [[::InstallingANewHardDrive/zh/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/tr | • {{#if: UbuntuHelp:InstallingANewHardDrive|Türkçe| [[::InstallingANewHardDrive/zh/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/vi | • {{#if: UbuntuHelp:InstallingANewHardDrive|Tiếng Việt| [[::InstallingANewHardDrive/zh/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/yue | • {{#if: UbuntuHelp:InstallingANewHardDrive|粵語| [[::InstallingANewHardDrive/zh/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/zh | • {{#if: UbuntuHelp:InstallingANewHardDrive|中文| [[::InstallingANewHardDrive/zh/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/zh-hans | • {{#if: UbuntuHelp:InstallingANewHardDrive|中文(简体)| [[::InstallingANewHardDrive/zh/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:InstallingANewHardDrive | UbuntuHelp:InstallingANewHardDrive | {{#if: | :}}InstallingANewHardDrive/zh}}/zh-hant | • {{#if: UbuntuHelp:InstallingANewHardDrive|中文(繁體)| [[::InstallingANewHardDrive/zh/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:InstallingANewHardDrive|:InstallingANewHardDrive/zh|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :InstallingANewHardDrive/zh/zh | | {{#ifexist: InstallingANewHardDrive/zh/zh | | {{#ifeq: {{#titleparts:InstallingANewHardDrive/zh|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:InstallingANewHardDrive/zh|1|-1|}} | zh | | }}
前言
安装新硬盘这种事情并不会经常,发生同样它也并不复杂.本文将向你说明如何在现有的Ubuntu系统下安装一个新硬盘,并为它设置好分区然后使用它.在动手之前,你需要先考虑下面三个关于新硬盘使用方面的问题:
- Will the drive be used only with Ubuntu?
- Will the drive need to be accessible from both Ubuntu and Windows?
- How do you want to divide the free space? As a single partition, or as several?
A Note about Filesystems:
Drives that are going to be used only under Ubuntu should be formatted using the ext3 filesystem. For sharing between Ubuntu and Windows, I would recommend the FAT32 filesystem. If you are new to filesystems and partitioning, please do some preliminary research on the two before you attempt this procedure.
Determine Drive Information
We assume that the hard drive is physically installed and detected by the BIOS.
To determine the path that your system has assigned to the new hard drive, open a terminal and run:
sudo lshw -C disk
This should produce output similar to this sample:
**-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
Be sure to note the "logical name." We'll be using this later.
Partition the Disk
If you have already formatted the drive and it contains data, skip this step and move on to "Mount Point." If the drive is still blank and unformatted, then you have two options: formatting the drive using the command line, or installing "gparted" for a graphical approach. Decide whether you want the drive to contain one single partition, or if you want to divide the space up between two or more partitions.
Partitioning with GParted
If System > Administration > GNOME Partition Editor is not available, install "GParted" using "Add/Remove Software" or "Synaptic." Open Gparted and let's get started.
In the top-right corner of the window, choose your new hard drive from the drop-down list, referring back to the "logical name" from earlier. The window should refresh and show you a representation of the new drive. Assuming that the drive has yet to have been used, a white bar will run across the window. Use these steps to partition the drive with a single partition...
1) Right-click on the white bar and choose "New."
2) For "New Size" the number should be the maximum allowable, to fill the entire disk.
3) Choose "Primary Partition"
4) Now decide on a filesystem. Use "ext3" if the drive will only be used with Ubuntu. For file-sharing between Ubuntu and Windows, you should use "fat32." If you are unsure, search around the wiki and forums for advice.
5) Now click Add to compute the partition. The graphical display should update to show a new partition covering the entire disk.
6) To finish, click "Apply," or Edit > Apply. The disk will then be partitioned and formatted.
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.
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:
- software that runs at boot time (e.g., old versions of LILO)
- booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Otherwise, this will not negatively affect you.
1) Initiate fdisk with the following command:
sudo fdisk /dev/hdd
2) Fdisk will display the following menu:
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) We want to add a new partition. Type "n" and press enter.
Command action e extended p primary partition (1-4)
4) We want a primary partition. Enter "p" and enter.
Partition number (1-4):
5) Since this will be the only partition on the drive, number 1. Enter "1" and enter.
Command (m for help):
6) Now that the partition is entered, choose option "w" to write the partition table to the disk. Type "w" and enter.
The partition table has been altered!
7) If all went well, you now have a properly partitioned hard drive that's ready to be formatted.
Format the Partition via Command Line
To format the disk as ext3 filesystem (best for use under Ubuntu):
sudo mke2fs -j /dev/hdd1
Substitute "/dev/hdd1" with your own drive's path.
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?
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.