How to mount a new hard disk in Linux

Source: Internet
Author: User
To improve server availability, a backup server can be replaced online at any time and restored to 23.59 of the previous night. The system disk space of the backup server is insufficient. In addition, a 1 TB hard disk is added as the storage and used to synchronize the hard disk with the file server. To improve server availability, a backup server can be replaced online at any time and restored to 23.59 of the previous night. The system disk space of the backup server is insufficient. In addition, a 1 TB hard disk is added as the storage and used to synchronize the hard disk with the file server. The procedure is as follows:

Mount a new hard disk in linux and automatically mount it at startup

Linux hard disk recognition:

After 2.6 kernel, linux will create the corresponding device file under/dev/on the recognized hardware device. For example:

Sda represents 1st SCSI hard disks. # V, z B,} 2 F7 U' |

Hda indicates 1st IDE Hard Disks (that is, they are connected to the Master port of 1st IDE interfaces)

1st USB optical drives.

After a new hard disk is added, the corresponding device files are generated in the/dev directory. The cciss hard disk is an exception.

The device file is in the/dev/cciss/directory. "fdisk-l" is generally used"CommandList the hard disks currently connected to the system.

Device and partition information. If the new hard disk does not have partition information, only the disk size information is displayed.

1. Disable the server and add a new hard disk.

2. Start the server and log on as the root user.

3. View hard disk Information

# Fdisk-l

Disk/dev/sda: 146.1 GB, 146163105792 bytes

255 heads, 63 sectors/track, 17769 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/sda1*1 13 104391 83 Linux

/Dev/sda2 14 5112 40957717 + 83 Linux

/Dev/sda3 5113 5243 1052257 + 82 Linux swap/

Solaris

/Dev/sda4 5244 17769 100615095 5 Extended

/Dev/sda5 5244 17769 100615063 + 83 Linux

Disk/dev/sdb: 291.3 GB, 291331192320 bytes

255 heads, 63 sectors/track, 17769 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Disk/dev/sdb1: 291.3 GB, 291331192320 bytes

4. Create a New Hard Disk Partition

Fdisk can use the m command to view the internal command of the fdisk command;

A: The command specifies the start partition;

D: Command to delete an existing partition;

L: The command displays the list of partition ID numbers;

M: view the fdisk Command help;

N: Create a New partition;

P: Command to display the partition list;

T: Command to modify the ID number of the partition type;

W: The command is used to modify and save the partition table.

# Fdisk/dev/sdb

Command (m for help): n

Command action

E extended // input e to create an extended partition

P primary partition (1-4)

P

Partion number (1-4): 1

Command (m for help): w

Enter n to press enter, then p to press enter, then 1 to press enter, all the way to press enter, and finally enter w to press enter to save.

Note: If you select e extension partition, the format cannot be ext3 file system.

Check it out:

Fdisk-l

The/dev/sdb1 partition is displayed.

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 Automatic mounting upon startup

Because mount mounting fails after the server is restarted, you need to write the partition information to the/etc/fstab file for permanent mounting (wan ):

[Root @ mysql ~] # E2label/dev/hda6 first check the labl of the hard disk partition to be mounted

/Home

[Root @ mysql ~] # E2label/dev/hda6 home1 because the system already has a/home label, you need to set the/dev/hda6 label to home1 again.

Vi/etc/fstab

Join:

LABEL = home1/data1 ext3 defaults 1 2

Note that there is no/on the left of red home1 /.

View cat/etc/fstab

LABEL = // ext3 defaults 1 1

LABEL =/data ext3 defaults 1 2

LABEL = home1/data1 ext3 defaults 1 2

LABEL =/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 defaults 0 0

LABEL = SWAP-hda3 swap defaults 0 0

After modifying the/etc/fstab file, run the mount-a command to verify whether the configuration is correct. Otherwise, the system cannot start properly due to misconfiguration of the fstab file. If the system cannot be started normally, enter the root password to enter the repair mode. The key step is to re-mount/(mount-n-o remount, rw /). If you do not perform this operation, the file system is read-only. As a result, you cannot modify the configuration file and save it.

9. restart 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.