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.