Aliyun host CentOS System how to mount and extend multiple hard disks (non-directory mount) steps

Source: Internet
Author: User
Tags bind extend centos aliyun

Note recently bought a Aliyun host (also heard good only to buy), the operating system is CentOS, and later bought a new hard disk, in the new hard disk how to mount and expand a lot of time, fortunately operation, and now the operation of the steps recorded to share to everyone.

The new Aliyun host default hard drive is not mounted, if it is mounted that no mount the default hard drive, you can directly look at the Aliyun to the tutorial. But I feel the hard drive is not enough, and then bought a hard disk, and do not want to mount a separate directory, want to expand the existing hard disk, or to mount the only hard drive and want to set aside after the expansion of the hard drive, then the tutorial with Aliyun is not.

Toss a half-day, finally mount success, but such operations do not suggest you directly toss in the system under the disk! Otherwise, you'll be sorry!

1. Aliyun CentOS System 6 series seems to have not installed LVM2, need to install LVM2, Internet search tutorials, their own installed, 5.4 32-bit has been mounted LVM2, so do not need this step

2. If you have already mounted a hard drive with a tutorial given by Aliyun, you can back up the data in this disk (data security, don't forget this step because you want to format it) and then bind

#umount-A

Then edit the startup item

#vi/dev/fstab

Remove the starter that was added to the previous/dev/xvdb1/mnt ext3 defaults 0 0.

and then save

And then use FDISK to delete the partitions. Suppose you were binding/dev/xvdb1.

#fdisk/dev/xvdb

#d

#wq

And then you use Fdisk-l.

See, is it found that XVDB1 has been untied

3. If you are the first time to mount, or do not want to toss the Aliyun has been used by the official method to mount, you omit the above process

#fdisk-L

Let's say you see two disks that haven't been mounted yet.

/dev/xvdb

/dev/xvdc

Process/dev/xvdb First, enter in the following order

#fdisk/dev/xvdb

#n

#p

#1

#t

#8e

#wq

And then handle the/DEV/XVDC the same way.

#fdisk/DEV/XVDC

#n

#p

#1

#t

#8e

#wq

If you don't have the second piece, you don't have to.

4. And then use Fdisk-l to see if there are/dev/xvdb1/dev/xvdc1 these two partitions

Create physical volumes for each of the two partitions below

#pvcreate/DEV/XVDB1

#pvcreate/DEV/XVDC1

If you don't have/DEV/XVDC1, just want to add xvdb1 capacity later, please automatically ignore the steps on XVDC1

5. Then create the volume group

#vgcreate MYGROUP/DEV/XVDB1

MyGroup is the volume group name.

6. Activate Volume group

#vgchange-ay MyGroup

Remember MyGroup is your own volume group name, activate the volume group is lazy to restart the VPS

7. Extended Volume Group

Vgextend MYGROUP/DEV/XVDC1

If not, please ignore this step directly

8. Creating logical Volumes

#vgdisplay MyGroup | grep "Total PE"

First use the above command to get

Total PE 15357

15357 is the logical number of the volume group

#lvcreate-l15357 mygroup-n Wwwroot

Wwwroot is the volume name of the logical volume.

8. Format logical Volumes

# "Mkfs.ext3/dev/mygroup/wwwroot

9. Create a directory you want to bind, such as/www (say WDCP The default use is/www)

Mkdir/www

10. Add Startup Item

Echo '/dev/mygroup/wwwroot/www ext3 defaults 0 0 ' >>/etc/fstab

11. Mount

Mount-a

12. Finally, with Df-hal to see, is it already successful?

With this approach, if you want to expand this partition again later, it's also easy to

Suppose you use Fdisk-l to see/DEV/XVDD is your new hard drive, you need to expand to the previous partition

#fdisk/DEV/XVDD

#n

#p

#1

#t

#8e

#wq

#reboot reboot

Get/dev/xvdd1, and then

#/pvcreate/dev/xvdd1

#vgextend MYGROUP/DEV/XVDD1

#vgdisplay MyGroup | grep "Total PE"

This command gets the total PE number totals PE 10240

#lvresize-l10240/dev/mygroup/wwwroot

#resize2fs/dev/mygroup/wwwroot

Have a cup of tea and run Df-hal, see if it works.

digression, Aliyun CentOS system disk does not use LVM2 partition, so can not expand/DEV/HDA1 disk, if your site is very promising, do not specify the database file to the system disk, if you are a very promising picture station, also do not put the site on the system disk, Also do not use Aliyun given the official mount mode, or the time will not be no gap increase capacity, the eggs hurt.

But once you've seen a solution to someone on a website, is to completely clone the system disk to a disk, and then change the starting mode, the original system and replication system of the startup files to be changed (all changed to the secondary disk to start), and then restart, and then let the secondary disk function as the main system to use, Then use the LVM2 partition the original system disk, after the finished, once again, the system in the secondary disk cloned to the original system disk, again change the two system startup files (all changed to the original disk to start), after the reboot, the system disk becomes LVM2 partition, you can expand capacity, and then you can put the secondary disk system files deleted, How to toss how to toss.

Forget where to see, toss two times did not succeed, Aliyun reload system restart are too slow, do not want to toss.

Overall, Aliyun host is still good, do not consider their own backup problems, the operation is also stable, is a little expensive broadband.

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.