[linux VPS tutorial] CentOS 6.X XEN mounting hard disk tutorial

888u

Last update at :2023-12-30,Edit by888u

Generally speaking, XEN framework VPS basically requires you to mount the hard drive yourself. Some control panels have this function in the background, but some do not, and you need to load it yourself. Next, let’s talk about the loading method. This method is to directly expand the capacity to the system disk. It has advantages and disadvantages. (Hehe) The following is a certain XEN VPS as an example. Others can be copied, but you need to pay attention to some modifications. Xiao7 will also note it for everyone.

[task] Mounting is recommended to be performed under a brand new system. If the system already has data, it is recommended to back it up first to prevent data loss due to mounting errors. This method is suitable for CentOS 6.X series. [/task]

1. Check the current hard disk status

fdisk -1


[task] Among them, "Disk /dev/sdb: 42.9 GB" means that the second virtual hard disk has 42.9GB capacity, "/dev/mapper/vg_cloud-lv_root: 8128 MB" means that "/" is currently allocated 8128MB (in the first virtual disk). [/task]

2. Format the second disk as an LVM partition

Mount /dev/sdb (second disk) and add capacity to the "/" directory of the Linux system. You need to format the second disk as an LVM partition first

fdisk /dev/sdb

SSH execute the above command, and then do the following:

Command (m for help): n #New partition
Command action
   eextended
   p primary partition (1-4)
p #Set as primary partition
Partition number (1-4): 1 #Primary partition number
First cylinder (1-2610, default 1):1 #Start sector (directly default to press Enter)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):2610
Using default value 2610 #End sector (directly default to carriage return)
Command (m for help): t #Specify partition type
Selected partition 1 #Select partition No. 1
Hex code (type L to list codes): 8e #8e is LVM
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w #Save
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3. View volume group

vgdisplay

SSH execute the above command, view the current PV, and record the "VG Name": vg_cloud, as shown below.

4. Add volume group

a. Create the LVM just created as a PV

pvcreate /dev/sdb1

SSH execute the above command.

b.Add volume group

vgextend vg_cloud /dev/sdb1

SSH execute the above command, fill in the group name (Vg Name) and the corresponding drive number (/dev/sdb1), and press Enter to execute.

c. View free volume groups

vgdisplay

Execute the above command again and record the value in "Free PE / Size": 10238.

5.Expand disk

a.Expand LV size

lvresize -l +10238 /dev/mapper/vg_cloud-lv_root

SSH execute the above command, replace "+10238" with the corresponding value in "Free PE/Size", and replace "vg_cloud" with the name of "VG Name".

b.Reset the size (make it effective)

resize2fs /dev/mapper/vg_cloud-lv_root

SSH executes the above command, and the extended formatting takes effect.


There are relevant instructions behind each item, and they are marked on the pictures. You can just modify them according to your own VPS.

Recommended site search: 6 yuan per year cloud server, permanent free Linux server, com domain name price, foreign server rental price, check IP, large bandwidth server rental, overseas virtual host space, free space in the United States, domain name registration website rental space,

[linux VPS tutorial] CentOS 6.X XEN mounting hard disk tutorial

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码