Linux notes on 2-esxi for the root directory expansion based on the LVM-based Centos7

Source: Internet
Author: User
Tags uuid

=======

Concept: The default CentOS is said to be LVM-based

LVM:LVM is the short name for Logical Disk volume management (Logical Volume Manager), which is a mechanism for managing disk partitions in a Linux environment.

LVM more detailed instructions can be ordered here: http://www.cnblogs.com/mchina/p/linux-centos-logical-volume-manager-lvm.html

Fdisk command Usage http://blog.sina.com.cn/s/blog_66b448620100ibay.html

View disk space, root directory is too small, want to increase the disk

Change the size of the disk on vsphere and restart it.

[Email protected] ~]# DF-LH
Filesystem Size used Avail use% mounted on
/dev/mapper/centos-root 30G 23G 7.1G 76%/
Devtmpfs 5.8G 0 5.8G 0%/dev
Tmpfs 5.8G 0 5.8G 0%/dev/shm
Tmpfs 5.8G 8.9M 5.8G 1%/run
Tmpfs 5.8G 0 5.8G 0%/sys/fs/cgroup
/DEV/SDA1 497M 155M 343M 32%/boot
Tmpfs 1.2G 0 1.2G 0%/run/user/0

One. View the lower LV

[Email protected] ~]# Lvdisplay
---Logical volume---
LV Path/dev/centos/swap
LV Name Swap
VG Name CentOS
LV UUID TRGEFC-4MXG-BKS6-SYWT-IE3O-DEA3-WC0EDQ
LV Write Access Read/write
LV Creation Host, time localhost, 2016-07-26 17:38:31 +0800
LV Status Available
# open 2
LV Size 2.02 GiB
Current LE 516
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 8192
Block Device 253:0

---Logical volume---
LV Path/dev/centos/root
LV Name Root
VG Name CentOS
LV UUID Mrmrqv-mdkz-zjbq-cvdp-nmey-hwjk-xfcceo
LV Write Access Read/write
LV Creation Host, time localhost, 2016-07-26 17:38:31 +0800
LV Status Available
# open 1
LV Size 66.49 GiB
Current LE 17022
Segments 2
Allocation inherit
Read ahead Sectors Auto
-Currently set to 8192
Block Device 253:1

Second: Check the number of hard drives and partition of the machine


[Email protected] ~]# fdisk-l

disk/dev/sda:75.2 GB, 75161927680 bytes, 146800640 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk IDENTIFIER:0X000CFB48

Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 1026047 512000 Linux
/dev/sda2 1026048 67108863 33041408 8e Linux LVM


disk/dev/mapper/centos-swap:2164 MB, 2164260864 bytes, 4227072 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes


disk/dev/mapper/centos-root:31.7 GB, 31666995200 bytes, 61849600 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes

If there is a disk/DEV/SDA, there are two partitions. 33G is used, indicating that there are still unpartitioned

Three:/DEV/SDA partition, do this time forget, probably the following, if you enter the partition number, can be postponed.

[Email protected] ~]$ FDISK/DEV/SDACommand (M for help): W
The partition table has been altered!

Calling IOCTL () to re-read partition table.

Warning:re-reading the partition table failed with error 16:device or resource busy.
The kernel still uses the old table. The new table is being used at
The next reboot or after you run Partprobe (8) or KPARTX (8)
Syncing disks. This is the last step. this time [[email protected] ~]# Fdisk-l can see a lot of partitions/dev/sda3 67108864 146800639 39845888 the Linux but Ls/dev|gre P Sda3 is still not visible because there is no formatting four: formatted partition [[email protected] dev]# mkfs-t Ext3/dev/sda3
MKE2FS 1.42.9 (28-dec-2013)
Filesystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2490368 inodes, 9961472 blocks
498073 blocks (5.00%) reserved for the Super user
First Data block=0
Maximum filesystem blocks=4294967296
304 Block Groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624

Allocating group Tables:done
Writing Inode Tables:done
Creating Journal (32768 blocks): Done
Writing Superblocks and filesystem accounting Information:
done [[email protected] dev]# LVS
LV VG Attr lsize Pool Origin data% meta% Move Log cpy%sync Convert
Root Centos-wi-ao----29.49g
Swap Centos-wi-ao----2.02g Five, create physical volume [[email protected] dev]# Pvcreate/dev/sda3
Warning:ext3 Signature detected On/dev/sda3 at offset 1080. Wipe it? [y/n]: ^c interrupted ...

Aborted wiping of ext3.
1 existing signature left on the device.
Aborting Pvcreate On/dev/sda3.
[Email protected] dev]# Pvcreate/dev/sda3
Warning:ext3 Signature detected On/dev/sda3 at offset 1080. Wipe it? [y/n]:
Warning:ext3 Signature detected On/dev/sda3 at offset 1080. Wipe it? [y/n]: Y
Wiping ext3 Signature On/dev/sda3.
Physical volume "/dev/sda3" successfully created six. 1. Look under the name [[email protected] dev]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/centos-root 30G 23G 7.1G 76%/
Devtmpfs 5.8G 0 5.8G 0%/dev
Tmpfs 5.8G 0 5.8G 0%/dev/shm
Tmpfs 5.8G 8.9M 5.8G 1%/run
Tmpfs 5.8G 0 5.8G 0%/sys/fs/cgroup
/DEV/SDA1 497M 155M 343M 32%/boot
Tmpfs 1.2G 0 1.2G 0%/run/user/0 2. Increase the volume group space [[email protected] dev]# vgextend/dev/mapper/centos- Root/dev/sda3 "Note here Oh, the name of the volume group is-before the"
Invalid Volume group name centos/root.
Run ' Vgextend--help ' for more information.
[Email protected] dev]# Vgextend/dev/mapper/centos/dev/sda3
Volume Group "CentOS" successfully extended well, the volume group has been expanded. 3, view the next volume group [[email protected] dev]# Vgdisplay
---Volume Group---
VG Name CentOS
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
ACT PV 2
VG Size 69.50 GiB
PE Size 4.00 MiB
Total PE 17793
Alloc pe/size 8066/31.51 GiB assigned
Free pe/size 9727/38.00 GiB Idle
VG UUID 8IYW2C-AQVR-C0EB-NRF4-V9Q7-ZEYH-PXRRQB can see that there is a free PE can be allocated to LV Seven, six expansion of the VG, you can use the free space in the VG to expand the LV, [[EM AIL protected] dev]# sudo lvextend-l +37g/dev/mapper/centos-root/dev/sda3 "Note the name Oh, now there is LV, CentOS is LG name"
Size of logical volume Centos/root changed from 29.49 Gib (7550 extents) to 66.49 Gib (17022 extents).
Logical volume root successfully resized. 81. Check the correctness of the file system [[email protected] dev]# e2fsck-f/dev/mapper/centos-root
E2fsck 1.42.9 (28-dec-2013)
/dev/mapper/centos-root is mounted.
E2fsck:cannot continue, aborting. 2. Redefine the size, do not understand the hair has always been wrong [[email protected] dev]# Resize2fs/dev/mapper/centos-root
RESIZE2FS 1.42.9 (28-dec-2013)
Resize2fs:bad magic number in Super-block and trying to open/dev/mapper/centos-root
Couldn ' t find valid filesystem superblock.

3. Take another pose, one more time.

[Email protected] dev]# Xfs_growfs/dev/mapper/centos-root
Meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=1932800 blks
= sectsz=512 attr=2, projid32bit=1
= Crc=0 finobt=0
data = bsize=4096 blocks=7731200, imaxpct=25
= Sunit=0 swidth=0 blks
Naming =version 2 bsize=4096 ascii-ci=0 ftype=0
Log =internal bsize=4096 blocks=3775, version=2
= sectsz=512 sunit=0 Blks, lazy-count=1
Realtime =none extsz=4096 blocks=0, rtextents=0
Data blocks changed from 7731200 to 17430528

4. See that the root directory has been expanded

[Email protected] dev]# DF-LH
Filesystem Size used Avail use% mounted on
/dev/mapper/centos-root 67G 23G 45G 34%/
Devtmpfs 5.8G 0 5.8G 0%/dev
Tmpfs 5.8G 0 5.8G 0%/dev/shm
Tmpfs 5.8G 8.9M 5.8G 1%/run
Tmpfs 5.8G 0 5.8G 0%/sys/fs/cgroup
/DEV/SDA1 497M 155M 343M 32%/boot
Tmpfs 1.2G 0 1.2G 0%/run/user/0

Linux notes on 2-esxi for the root directory expansion based on the LVM-based Centos7

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.