Linux VPS hard disk mounting command details

Source: Internet
Author: User

I have read a lot about how to attach a hard disk to VPS in the past, but it feels complicated. Today I am going to find a friend of mine to learn how to attach a hard disk to VPS. I will introduce it to you in a few steps.

Note:

1. Attach the hard disk before installing other software or environment;
2. If data already exists before mounting, pay attention to backup;
3. The partition name and hard disk name mentioned in this article are for reference only. The actual environment may vary.

Step 1: run the "fdisk-l" command to view the hard disk status.:


We can see that we have two hard disks, and the second one is/Dev/vdb1, Size around 96 GB, formatted and partitioned.
Note: If the message "Disk/dev/vdb doesn't contain a valid partition table" is displayed, this hard Disk is not partitioned. You must format the hard Disk and format it as an EXT3 log file system, command: "mkfs. ext3/dev/vdb1 ".Step 2: mount the hard disk
Before mounting, create a mount directory to be mounted on the server or use an existing Directory such as home.
Mount the disk to the home directory and run the mount command: "mount/dev/vdb1/home"


Mount the file to home. You can change the directory after it. Note that the mount may delete the original file.

How to create a new directory?
You can create a myhome directory under the root directory.
By default, the command to jump to the root directory is: cd ..
Run the following command to create a directory: mkdir/myhome.

After mounting, enter "df-h" to view the mounting status, as shown below:


You can see that/dev/vdb1 is successfully mounted to the/home directory.Step 3: Set the disk to be automatically mounted upon startup:
Enter the following command in SSH (Note: Modify/home to the directory you actually mount ):
Echo "/dev/vdb1/home ext3 defaults 1 2">/etc/fstab
After modifying the/etc/fstab file, run the mount-a command to verify whether the configuration is correct. If no prompt is displayed after the command is executed, the configuration is successful.

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.