Partitioning, formatting, and attaching hard disks on Linux VPS

Source: Internet
Author: User
Tags vps vps server

This is my experience in setting up my VPS in the past few days, my VPS system for the UBUNTU,VPS server in given your initial server on a disk is divided into a good zone, is the system disk, so we use the DF-HL command to see the hard disk when the hard drive is small, There is actually an extra piece of virtual disk that has no partitions, and this needs to be formatted and mounted on its own.
In this we mainly use a few main commands: fdisk (Partition command), MKE2FS (Format command), Mount (Mount command)
First step: Partition
Check the hard drive first and use the command:

The code is as follows:

Fdisk-l

disk/dev/xvda:8589 MB, 8589934592 bytes
255 heads, Sectors/track, 1044 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/XVDA1 * 1 104391 Linux
/dev/xvda2 1044 8281507+ 8e Linux LVM
disk/dev/xvdb:23.6 GB, 23622320128 bytes
255 heads, Sectors/track, 2871 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
We can see that the/DEV/XVDB capacity is 23.6G and there are no partitions, and then we partition and mount it
OK, now let's just type the command to partition the XVDB:

The code is as follows:

Fdisk/dev/xvdb

Entering fdisk command mode, enter M to view all command explanations. We're going to use the main n command to create a partition:

The code is as follows:

Command (M for help): N

Prompt appears:
Command Action
E Extended
P primary partition (1-4)
P
There are two command options: E (Create an extended partition), p (create the primary partition)
I chose P directly.
1th Partition in/dev/xvdb

The code is as follows:

Partition number (1-4): 1
Cylinder (1-2871, default 1): (Enter: Enter)
Using Default value 1
Last cylinder or +size or +sizem or +sizek (1-2871, Default 2871): (Enter: Enter)
Using Default Value 2871
Enter W Save exit

The code is as follows:

Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
With the above steps we have completed the/DEV/XVDB partition, and below we format and mount the partition
Step Two: Format
I use MKE2FS (command), this command supports more parameters, of course, you can use the MKFS This command is relatively simple.
If it's the MKFS command, that's it:

The code is as follows:

Mkfs-t EXT4/DEV/XVDB1
With the MKE2FS command, you can add an argument to see the format process (see if an error occurs)

The code is as follows:

Mke2fs-c-T EXT4/DEV/XVDB1
The third step: Mount the partition, we can use this partition only if we mount it.
The command is simple, it's mount.

The code is as follows:

Mount/dev/xvdb1/mnt
The meaning is to mount the partition to the MNT directory, of course, you can also choose a different directory, but if your directory is non-empty directory, mount can also be carried out, but the original directory of the files are not available.
When we are done, we can see through Df-hal that the new partition has been mounted to the directory/home1.
Another step, if you want to boot automatically mount, you need to edit/etc/fstab so that the partition on the boot automatically mount to your chosen directory

The code is as follows:

Vi/etc/fstab
Add after the last line:
The partition that needs to be mounted is mounted directory partition format parameters (default) The following two are set to 0 either

The code is as follows:

/dev/xvdb1/mnt EXT4 Defaults 0 0
Last reboot reboot.

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.