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

How to add a disk to the root directory for centos7

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "centos7 how to add disks to the root directory". In daily operation, I believe many people have doubts about how to add disks to the root directory in centos7. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to add disks to the root directory by centos7". Next, please follow the editor to study!

Using vg to expand root Partition in centos7

1. Create pv

Fdisk / dev/sdb

Enter n to increase the partition

Enter p type to set to: primary partition

Enter 1 partition number to set to 1

Enter is the default size

Enter is the default size

Enter w to exit

two。 Adding pv to vg is equivalent to expanding the size of vg.

Extend vg, using the vgextend command

[root@localhost ~] # vgextend centos / dev/sdb1

Volume group "centos" successfully extended

The name of the vg followed by the vgextend name command, followed by the location of the disk

3. We have successfully expanded the vg volume and check it out again with vgs

[root@localhost ~] # vgs

VG # PV # LV # SN Attr VSize VFree

Centos 2 20 wz--n- 39.50g 20.04g

[root@localhost ~] # lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

Root centos-wi-ao---- 17.47g

Swap centos-wi-ao---- 2.00g

Although we have extended vg, lv has not expanded yet.

4. Extend lv, using the lvextend command

[root@localhost] # lvextend-L + 20g / dev/mapper/centos-root

Size of logical volume centos/root changed from 17.47 GiB (4472 extents) to 37.47 GiB

(9592 extents)

Logical volume root successfully resized.

-L

Specify how much space to expand into the lv, followed by / dev/mapper/centos-root is the file location of the specified extension, which can be seen in df-h

View lv size

[root@localhost ~] # lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

Root centos-wi-ao---- 37.47g

Swap centos-wi-ao---- 2.00g

Check whether there is any change in df-h

[root@localhost] # df-h

File system capacity used available used% mount point

/ dev/mapper/centos-root 18G 1.1G 17G 6% /

Devtmpfs 479m 0 479m 0% / dev

Tmpfs 489m 0 489m 0% / dev/shm

Tmpfs 489M 6.7m 483m 2% / run

Tmpfs 489m 0 489m 0% / sys/fs/cgroup

/ dev/sda1 497M 125m 373m 25% / boot

Tmpfs 98m 0 98m 0% / run/user/0

No change.

Then we will use the [root@localhost ~] # xfs_growfs / dev/mapper/centos-root command to make the system reread the size.

[root@localhost ~] # xfs_growfs / dev/mapper/centos-root

Meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=1144832 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

Data = bsize=4096 blocks=4579328, imaxpct=25

= sunit=0 swidth=0 blks

Naming = version 2 bsize=4096 ascii-ci=0 ftype=0

Log = internal bsize=4096 blocks=2560, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

Realtime = none extsz=4096 blocks=0, rtextents=0

Data blocks changed from 4579328 to 9822208

Then use df-h to view

[root@localhost] # df-h

File system capacity used available used% mount point

/ dev/mapper/centos-root 38G 1.1G 37G 3% /

Devtmpfs 479m 0 479m 0% / dev

Tmpfs 489m 0 489m 0% / dev/shm

Tmpfs 489M 6.7m 483m 2% / run

Tmpfs 489m 0 489m 0% / sys/fs/cgroup

/ dev/sda1 497M 125m 373m 25% / boot

Tmpfs 98m 0 98m 0% / run/user/0

At this point, we have successfully expanded.

Note: we can produce our own vg groups and generate lv in the new vg

Vgcreate creates a new vg group

Lvcreate creates a new lv in the new vg, but specifies the name of the vg

Vgreduce removes pv from vg. If there is only one pv in vg, use vgremove directly.

At this point, the study on "how to add centos7 to the root directory" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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