วิธีการปรับขนาดพื้นที่ของ LINUX

สิ่งที่ท่านจะได้เรียนรู้ต่อไปนี่คือจะเป็นของ Centos 7   สำหรับ Linux ตัวอื่น ใช้เป็นแหล่งอ้างอิงได้ครับ

New Solution

 

First Step

Extend partition

First you need find out what partition name with

# fdisk -l
after that system command line will output like something
        /dev/xvda

First you need to find number of disk

eg. /dev/xvda2 

( or /dev/xvda3 )

 

2 = your number of disk.

then go next step

 

# parted --version

if return value with "parted (GNU parted) 3" OR Upper

# echo '-1' | parted ---pretend-input-tty /dev/xvda resizepart {Your number of disk}

eg. 

# echo 'Fix' | parted ---pretend-input-tty /dev/xvda resizepart 2
# echo -1 | parted ---pretend-input-tty /dev/xvda resizepart 2

then go Second step

 

If below 3 OR your version 2.X

# parted /dev/xvda resize {You number of disk} -1

 

 

Second Step

Update kernel in-memory partition table

After changing your partition table, run the following command to update the kernel in-memory partition table:

# partx -u /dev/xvda
if have error something please use
# partprobe /dev/xvda

Resize physical volume

Resize the PV to recognize the extra space

# pvresize /dev/xvda2

Find your Disk Logic Name

# lvdisplay -C -o "lv_path,lv_dm_path,lv_kernel_minor"

 

It should display something like this

some partition has "Swap Space"

Path                 DMPath                      KMin
  /dev/cl_host115/root /dev/mapper/cl_host115-root    0


Select DMPath that not contain "Swap"
Then
DMPath = /dev/mapper/cl_host115-root

# lvextend -r {DMPath} /dev/xvda2
eg.

# lvextend -r /dev/mapper/cl_host115-root /dev/xvda2

Finish extended your partition.

Old Solution

You can do this without rebooting in CentOS 7. Assuming your disk is /dev/xvda and standard RHEL/CentOS partitioning:

Extend partition

First you need find out what partition name with

# fdisk -l
after that system command line will output like something
        /dev/xvda

then go next step
   

insert your partition name in first step like this
# fdisk /dev/xvda

Enter p to print your initial partition table.

Enter d (delete) followed by 2 to delete the existing partition definition (partition 1 is usually /boot and partition 2 is usually the root partition).

Enter n (new) followed by p (primary) followed by 2 to re-create partition number 2 and enter to accept the start block and enter again to accept the end block which is defaulted to the end of the disk.

Enter t (type) then 2 then 8e to change the new partition type to "Linux LVM".

Enter p to print your new partition table and make sure the start block matches what was in the initial partition table printed above.

Enter w to write the partition table to disk. You will see an error about Device or resource busy which you can ignore.

Update kernel in-memory partition table

After changing your partition table, run the following command to update the kernel in-memory partition table:

# partx -u /dev/xvda
if have error something please use
# partprobe /dev/xvda

Resize physical volume

Resize the PV to recognize the extra space

# pvresize /dev/xvda2

Resize LV and filesystem

in this step before start please send command : pvs
you will see disk name like : centos_thankcloud

then use this name in next step.



In this command centos is the PV, root is the LV and /dev/xvda2 is the partition that was extended. Use pvs and lvs commands to see your physical and logical volume names if you don't know them. The -r option in this command resizes the filesystem appropriately so you don't have to call resize2fs or xfs_growfs separately.

# lvextend -r centos_thankcloud/root /dev/xvda2
  • 0 Користувачі, які знайшли це корисним
Ця відповідь Вам допомогла?

Схожі статті

วิธีการปรับขนาดพื้นที่ของ Windows Server

เมื่อท่านอยู่ใน remote destop ใน VPS ของท่านเรียบร้อยแล้ว 1. คลิกขวาบน Start แล้วคลิก...

วิธีการปรับขนาดพื้นที่ของ Windows Server

เมื่อท่านอยู่ใน remote destop ใน VPS ของท่านเรียบร้อยแล้ว 1. คลิกขวาบน Start แล้วคลิก...

How to Install Python 3.6 on Ubuntu & LinuxMint

Python 3.6.10 is the latest stable version at the time of writing of tutorial. This Python...

[Linux] How to make Swap Partition

[HDD] We recommends to 2 Gig of ram, and 4 Gig of swap.The more ram the better, but much more...

เงื่อนไขและข้อตกลงการใช้บริการ (Terms of Service)

THANK.CLOUD มีนโยบาย ในการคุ้มครองสิทธิส่วนบุคคลของผู้ใช้บริการทุกท่าน โดยข้อมูลต่าง ๆ...