Add a new hard drive in Ubuntu

Source: Internet
Author: User
Tags gparted


Installing a new hard disk this kind of thing doesn't happen very often, and it's not complicated. This article will show you how to install a new hard drive under an existing Ubuntu system, and then use it to set up a partition for it. Before you start, you need to consider the following three questions about the use of new drives:

    • Will the hard drive only be used under Ubuntu?
    • Is the hard drive being used by Ubuntu and Windows two types of systems?
    • How do you plan to partition, which is all the space for partitioning or dividing into several small partitions?

Friendly Tips

Hard drives that are only used in Ubuntu environments can be considered as EXT3 file systems. To use in Ubuntu and Windows two environments, you should format the FAT32 file system. If you've never been in touch with the file system, hard disk partition before, before doing the next operation, I suggest you check out some information related to this topic first.

[Edit] Query hard disk parameters

We assume that your hard drive is properly installed on your computer and that it can be detected in the BIOS.

Open end Input The following instructions to query the system for your newly installed hard drive to assign the path and other related information:

sudo lshw-c disk

The system should output a message similar to the following:

Description:ata Disk
Physical id:0
Bus info: [email protected]
Logical Name:/DEV/HDD

Record the "Logical name" section of the information, we will use it in the subsequent operations.

[edit] Partition the hard disk

If you have already created a partition on this hard drive and stored the data in it, skip this paragraph to the mount point. If the hard disk is blank and not formatted, then you need to do two things:

    • Format the hard disk by Terminal command operation, or install the GParted graphics partition software to complete the partition and format the hard disk
    • Make a partition scheme, such as a partition or multiple partitions.
[edit] partition with GParted

If the GNOME Partition Editor does not exist in your menu system > Management > , you have not installed gparted. You can install it via Add/Remove Programs or new force After the installation is complete, start it to continue with the following actions

You can choose which hard disk to partition or format from the drop-down list in the upper-right corner of the program form, and select the "logical name" that we recorded earlier Match the hard drive. The system will refresh and display the partition list information for the currently selected drive in seconds. Suppose your hard disk is a brand new hard disk, there is no partition information, then in the program form should be able to see a white bar, the following operation will be the entire hard disk divided into a partition ...

1) Right-click on the white long strip and select "New" in the popup menu.

2) The "New Partition Size" system automatically fills in the largest available space, accepting the system's default values to divide all the space into one partition

3) Select "Make Primary Partition"

4) Next is to choose the type of file system to be established, only in the Ubuntu environment to use the hard disk can be considered divided into EXT3 file system. To use in Ubuntu and Windows two environments, you should format the FAT32 file system. If you know little about the filesystem, Go to the wiki or forum to search for relevant information.

5) Click "Add", the system will automatically refresh the new partition structure.

6) Finally click "Apply" or from the menu "edit", "should", the system will be the partition you make the operation of one line to finish, and format the new partition.

[Edit] partition operation by command

Here you will use "Fdisk" to complete the partitioning operation. Also take the "logical name" as the previous example. I'll use the corresponding "/DEV/HDD" example here. and suppose you want to divide all the space into one partition.

If your hard disk is over 1024 (the hard disk now has a large capacity, the cylinder basically exceeds this value). Some problems may arise, and the main reasons for these problems are:

          1. Programs that run during system startup, such as a lower version of the LILO boot program
          2. Other system boot programs and partition management programs, such as Fdisk under DOS and OS/2 systems

There's no big problem with anything else.

1) Run the following command to start fdisk


2) afterfdisk starts, the following menu will be listed:

  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) Press n to create a new partition

  Command Action
E Extended
P Primary partition (1-4)

4) Press Pto create a primary partition, while pressing e will create an extended partition

  Partition number (1-4):

5) We only want to create a partition, so here we enter 1

  Command (M for help):

6) The request to establish the partition enters the queue, and the input W will commit all operations in the queue, we enter W

  The partition table has been altered!

7) If the partition operation runs smoothly, you now have a partition waiting to be formatted.

[Edit] format partitions by command

If you want to format the partition into EXT3 format (recommended for Ubuntu), simply execute the following command:

  sudo mke2fs-j/dev/hdd1

Note: Change the /dev/hdd1 to the path that corresponds to your hard disk partition.

[Edit] Change system reserve space (optional)

When we format the hard disk, the system will automatically retain 5% of the space for the super User (root) to use, so that the operating system in the hard disk space has been "used" when the Root account can still write data to the hard disk, of course, for a simple disk for data storage, this mechanism is not necessary.

You can adjust the ratio of system reserved space by the "TUNE2FS" command, as shown in the following example:

sudo tune2fs-m 1/dev/hdd1

In this example, change the percentage of reserved space to 1%, which you can set according to your actual needs.

{i} This command does not have any effect on the existing data on the hard disk, so you can safely do this on a hard disk that already has data saved.
[Edit] Set up mount point

Now that we have finished partitioning and formatting the hard disk, to use your new partition, you must set up a mount point for it, which is the point at which you will access the partition at a later time. I recommend that you hang this type of partition under /media , and I'll give you an example of how to hang the new partition under the/media/mynewdrive directory.

The first is to create a mount directory:

  sudo mkdir/media/mynewdrive

Now we can hook the partition down to the directory created above.

  sudo mount/dev/hdd1/media/mynewdrive

Without an accident, you can go into this directory and start using the new partition.

The translator raises: Now the mount command can automatically recognize the format of the hard disk partition, it is not necessary to add the specified file system class parameters.

[Edit] Mount partition

You can choose to automatically mount a partition on each boot system, or you can choose to mount it manually when you need to use the partition.

[Edit] Let partition boot automatically mount

You need to modify/etc/fstab:

  Gksudo Gedit/etc/fstab

Join this line:

  /DEV/HDD1    /media/mynewdrive   ext3    defaults     0 2

The addition of 2 means that the partition will be detected quickly when the system boots, if you do not want to do so, you can change it to 0 Skip boot detection. You can run man fstab To read more information about Fstab.

After you modify it, execute the sudo mount-a or reboot the system to attach the newly added partition.

If you want other users to be able to read and write to the partition, you need to give the user the appropriate permissions, see the following command (replace USERNAME with your user account)

  sudo chown-r username:username/media/mynewdrive

When you have multiple users in your system and are in Plugdev (usually the users in this group have permission to mount and use a mobile storage device) , you can grant these users permission to use the new partition at the same time by authorizing the group:

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

The last line of "chmod +t" is a restriction, so that each user can only delete files or directories that he or she has created, even if he has permission to write to a file that is not his creation. (For more information, see Man chmod)

[Edit] Manually mount/unmount partitions

There may be times when you're more inclined to mount/unmount partitions manually when you need them.

The commands for manually mounting partitions are as follows:

After you run out of time, you can uninstall the partition by using the following command:

sudo umount/media/mynewdrive

Add a new hard drive in Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

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.