Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Disk space expansion of linux virtual machine

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Mount physical storage and add new disks to extended space

Then restart the machine and go to webbios to set the raid of the new storage (do not touch the raid of the old storage, otherwise the data will be lost). Note that after setting up the machine, use fdisk to partition the new storage.

]# fdisk -l

fdisk /dev/sdb #Operate on the second hard disk

Command (m for help): n #Add a new partition

Command action

e extended

p primary partition (1-4)

p #Select "Add Primary Partition"

Partition number (1-4):1 #selected as partition number 1

First cylinder (1-65270, default 1): #Enter directly, the new partition starts from sector 1 of the hard disk

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-65270, default 65270): #Enter directly, the new partition ends at the end of the hard disk, that is, the whole hard disk is divided into only one partition, which is also the main partition.

Using default value 65270

Command (m for help): t #Select partition type

Selected partition 1

Hex code (type L to list codes): 83 #Select partition type 83 (linux type)

Command (m for help): w #Save to hard disk

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

]# fdisk -l #Check the hard disk mount again and find that the new hard disk is ready

Device Boot Start End Blocks Id System

/dev/sda1 * 1 64 512000 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 64 3917 30944256 8e Linux LVM

/dev/sda3 3917 133674 1042279125 83 Linux

2. The new partition/dev/sda3 exists, so perform a reboot

[root@JQ-AQSB-04 ~]# pvscan #View allocatable space

PV /dev/sda2 VG VolGroup lvm2 [29.51 GiB / 6.51 GiB free]

Total: 1 [29.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 0 [0 ]

## 3. Add the newly added volume to the specified disk

[root@JQ-AQSB-04 dev]# ls |grep sda3 #See if it is in the logical volume If it is not, enter the/dev directory ls to see if there is a sda3 volume

sda3

[root@JQ-AQSB-04 dev]# vgs #View Scalable Space Discovery sda3 Not Shown

VG #PV #LV #SN Attr VSize VFree

VolGroup 1 6 0 wz--n- 29.51g 6.51g

[root@JQ-AQSB-04 dev]# pvscan #View Scalable Space

PV /dev/sda2 VG VolGroup lvm2 [29.51 GiB / 6.51 GiB free]

Total: 1 [29.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 0 [0 ]

4, add new partition extension space sda3

[root@JQ-AQSB-04 dev]# pvcreate /dev/sda3 #Add new partition extension sda3

Physical volume "/dev/sda3" successfully created

[root@JQ-AQSB-04 dev]# pvscan #View Scalable Space Discovery sda3 already displayed

PV /dev/sda2 VG VolGroup lvm2 [29.51 GiB / 6.51 GiB free]

PV /dev/sda3 lvm2 [993.99 GiB]

[root@JQ-AQSB-04 dev]# pvcreate /dev/sda3

[root@JQ-AQSB-04 dev]# vgextend VolGroup /dev/sda3 #Add a new extension volume

Volume group "VolGroup" successfully extended

vgextend command before execution

[root@JQ-AQSB-04 dev]# vgdisplay

--- Volume group ---

VG Name VolGroup

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 7

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 6

Open LV 6

Max PV 0

Cur PV 1

Act PV 1

VG Size 29.51 GiB

PE Size 4.00 MiB

Total PE 7554

Alloc PE / Size 5888 / 23.00 GiB

Free PE / Size 1666 / 6.51 GiB

VG UUID oKMt1Q-GlFT-xZrr-TtgM-zi6a-cxLx-8b29sA

vgextend command after execution

[root@JQ-AQSB-04 dev]# vgdisplay

--- Volume group ---

VG Name VolGroup

System ID

Format lvm2

Metadata Areas 2

Metadata Sequence No 8

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 6

Open LV 6

Max PV 0

Cur PV 2

Act PV 2

VG Size 1023.50 GiB

PE Size 4.00 MiB

Total PE 262016

Alloc PE / Size 5888 / 23.00 GiB

Free PE / Size 256128 / 1000.50 GiB

VG UUID oKMt1Q-GlFT-xZrr-TtgM-zi6a-cxLx-8b29sA

[root@JQ-AQSB-04 dev]# vgs #Scalable Space

VG #PV #LV #SN Attr VSize VFree

VolGroup 2 6 0 wz--n- 1023.50g 1000.50g

[root@JQ-AQSB-04 dev]# df -lh

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-LogVol01 4.0G 449M 3.3G 12% /

tmpfs 48G 0 48G 0% /dev/shm

/dev/sda1 485M 39M 421M 9% /boot

/dev/mapper/VolGroup-LogVol04 4.0G 1.9G 1.9G 50% /home

/dev/mapper/VolGroup-LogVol05 4.0G 136M 3.7G 4% /opt

/dev/mapper/VolGroup-LogVol02 4.0G 3.2G 632M 84% /usr

/dev/mapper/VolGroup-LogVol03 4.0G 413M 3.4G 11% /var

[root@JQ-AQSB-04 dev]# lvextend -L +1000G /dev/mapper/VolGroup-LogVol04 #Add a new volume to the specified directory

Extending logical volume LogVol04 to 1004.00 GiB

Logical volume LogVol04 successfully resized

[root@JQ-AQSB-04 dev]# resize2fs /dev/mapper/VolGroup-LogVol04 #format new extended partition

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/VolGroup-LogVol04 is mounted on /home; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 63

Performing an on-line resize of /dev/mapper/VolGroup-LogVol04 to 263192576 (4k) blocks.

The filesystem on /dev/mapper/VolGroup-LogVol04 is now 263192576 blocks long.

[root@JQ-AQSB-04 dev]# timed out waiting for input: auto-logout

[wangguan@JQ-AQSB-04 ~]$ timed out waiting for input: auto-logout

Connection to 10.10.121.26 closed.

Show after adding

[wangguan@JQ-AQSB-04 ~]$ df -lh

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-LogVol01 4.0G 449M 3.3G 12% /

tmpfs 48G 0 48G 0% /dev/shm

/dev/sda1 485M 39M 421M 9% /boot

/dev/mapper/VolGroup-LogVol04 989G 1.9G 937G 1% /home

/dev/mapper/VolGroup-LogVol05 4.0G 136M 3.7G 4% /opt

/dev/mapper/VolGroup-LogVol02 4.0G 3.2G 632M 84% /usr

/dev/mapper/VolGroup-LogVol03 4.0G 413M 3.4G 11% /var

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report