CentOS Linux plus HDD, partition and set auto mount

Source: Internet
Author: User

SDA indicates a 1th SCSI drive
HDA represents the 1th IDE hard disk (that is, connected to the master port on the 1th IDE interface)
SCD0 indicates 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, it's
The device files are in the/dev/cciss/directory. General use of the "fdisk-l" command to list the hard drives currently connected in the system
Device and partition information. The new hard disk does not have partition information, only the hard disk size information is displayed.

1. Turn off the server plus the new hard drive

2. Start the server and log in as root

3. View hard Drive information

Fdisk-l

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/
Solaris
/DEV/SDA4 5244 17769 100615095 5 Extended
/dev/sda5 5244 17769 100615063+-up 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 see the internal commands of the FDISK command;
A: The command specifies the boot partition;
D: command to delete an existing partition;
L: command displays a list of partition ID numbers;
M: View the fdisk command help;
N: command to create a new partition;
P: command displays a list of partitions;
T: Command modifies the type ID number of the partition;
W: The command is to save changes to the partition table to make it work.

Fdisk/dev/sdb

Command (M for help): N
Command Action
E Extended//Enter E to create an extended partition
P primary partition (1-4)
P
Partion Number (1-4): 1
Command (M for help): W

Input n Enter, and then enter P return, and then output 1 return to the car, all the way back, and finally enter the W to save.
Take a look:

Fdisk-l

You can see the/DEV/SDB1 partition

5. Format the partition:

Mkfs.ext3/dev/sdb1

6. Create the/DATA1 directory:

Mkdir/data1

7. Mount the partition:

Mount/dev/sdb1/data1

8. Configure Boot Auto Mount
Because mount Mount fails after restarting the server, it is necessary to write the partition information to the/etc/fstab file so that it is permanently mounted:

E2label/dev/hda6

First look at the label on which you want to mount the hard disk partition

/homee2label/dev/hda6 hom1

Because the system already has a/home label, so here to re-set the/dev/hda6 label to Home1

Vi/etc/fstab

Join:

Label=home1            /data1                   ext3     defaults         1 2

Note the red home1 left no/.
View Cat/etc/fstab
label=//ext3 Defaults 1 1
Label=/data/data ext3 Defaults 1 2
Label=home1/data1 ext3 Defaults 1 2
Label=/boot/boot ext3 Defaults 1 2
TMPFS/DEV/SHM TMPFS Defaults 0 0
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 swap defaults 0 0

After modifying the/etc/fstab file, run the mount-a command to verify that the configuration is correct
Otherwise, the wrong configuration of the Fstab file causes the system not to start properly. If the system does not start properly, entering the root password into repair mode, the key step is to re-mount/(Mount-n-o remount,rw/).
Without this step, the file system is read-only, which prevents the configuration file from being modified and saved, fixing the problem.

9. Rebooting the system

Related Article

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: info-contact@alibabacloud.com 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.