Linux formats the new hard drive and mounts and sets the boot mount automatically

Source: Internet
Author: User

Hard disk identification for Linux:

After 2.6 kernel, Linux will identify the hardware devices, under the/dev/to establish the appropriate device files. such as:

SDA represents the 1th SCSI hard drive

HDA represents the 1th IDE hard disk (that is, the master port connected to the 1th IDE interface)

The scd0 represents a 1th USB drive.

When a new hard drive is added, a corresponding device file is generated in the/dev directory. Cciss's hard drive is an exception, and its

The device files are in the/dev/cciss/directory. Generally use the "fdisk-l" command to list the hard drives currently connected in the system

Device and partition information. The new hard drive has no partition information, only the hard drive size information is displayed.

1. Shut down the server and add a new hard drive

2. Start server, log in as root user

3. View hard Drive information


disk/dev/sda:146.1 GB, 146163105792 bytes

255 heads, Sectors/track, 17769 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 104391 Linux

/dev/sda2 5112 40957717+ Linux

/dev/sda3 5113 5243 1052257+ Linux swap/


/DEV/SDA4 5244 17769 100615095 5 Extended

/dev/sda5 5244 17769 100615063+ Linux

disk/dev/sdb:291.3 GB, 291331192320 bytes

255 heads, Sectors/track, 17769 cylinders

Units = Cylinders of 16065 * 8225280 bytes

disk/dev/sdb1:291.3 GB, 291331192320 bytes

4. Create a new hard disk partition

Fdisk can use the M command to look at the internal command of the FDISK command;

A: command specifies the boot partition;

D: command to delete an existing partition;

L: command displays a list of partition ID numbers;

M: View fdisk command help;

N: command to create a new partition;

P: command to display the partition list;

T: Command modifies the partition's type ID number;

W: The command is to save changes to the partition table to make it work.


Command (M for help): N

Command Action

e extended//input E to create an extended partition

P primary partition (1-4)

Partion Number (1-4): 1

Command (M for help): W

Enter the n return, enter the P return, and then output 1 back to the car, all the way to return, the last input W return to save.

Check this out:


You can see the/DEV/SDB1 partition

5. Format the partition:


6. Create/data1 directory:


7. Mount Partition:


8. Configure the Power-on mount automatically

Because mount Mount fails after restarting the server, the partition information needs to be written to the/etc/fstab file for permanent mount:



Label=/data1/data1 ext3 Defaults 1 2

View Cat/etc/fstab

label=//ext3 Defaults 1 1

Label=/data/data ext3 Defaults 1 2

Label=/data1/data1 ext3 Defaults 1 2

Label=/boot/boot ext3 Defaults 1 2


Devpts/dev/pts devpts gid=5,mode=620 0 0

Sysfs/sys Sysfs Defaults 0 0

PROC/PROC proc Defaults 0 0

Label=swap-hda3 Swap Defaults 0 0

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.