本文共 19135 字,大约阅读时间需要 63 分钟。
一次很折腾的扩容,记录一下之后再整理
`[root@localhost ~]# fdisk -lDisk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 66554433 16500001 83 LinuxDisk /dev/mapper/centos-root: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): n
If you want to create more than four partitions, you must replace a primary partition with an extended partition first.Command (m for help): ^C
[root@localhost ~]# cat /etc/f favicon.png filesystems firewalld/ fonts/ fstab [root@localhost ~]# cat /etc/f favicon.png filesystems firewalld/ fonts/ fstab [root@localhost ~]# cat /etc/fstab/dev/mapper/centos-root / xfs defaults 0 0
UUID=df180f7c-2f70-4c71-ba45-7767bd207383 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 [root@localhost ~]# fdisk -lDisk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 66554433 16500001 83 LinuxDisk /dev/mapper/centos-root: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 30G 29G 1.9G 94% / devtmpfs 747M 0 747M 0% /dev tmpfs 758M 0 758M 0% /dev/shm tmpfs 758M 8.8M 750M 2% /run tmpfs 758M 0 758M 0% /sys/fs/cgroup /dev/sda1 509M 173M 337M 34% /boot overlay 30G 29G 1.9G 94% /var/lib/docker/overlay2/3cc1fad6e57ea1096d0e8fbcf98816e3aea67544768614b9dcea353836ea81a9/merged overlay 30G 29G 1.9G 94% /var/lib/docker/overlay2/7482808cf7f406570d3233b8f948616b780be2841d153b19e16994429e69fd7e/merged shm 64M 0 64M 0% /var/lib/docker/containers/d8a8962dfb76b436b672770893668e55c1fba4041fa4029a5d79ee7b27a47a69/shm shm 64M 0 64M 0% /var/lib/docker/containers/94e5ac3c9ea75e5d64aeb8bf7f62457a5f43f9181d06425b3fbcdb8a7fa92e5b/shm tmpfs 152M 0 152M 0% /run/user/0 [root@localhost ~]# fdisk -lDisk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 66554433 16500001 83 LinuxDisk /dev/mapper/centos-root: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): n
If you want to create more than four partitions, you must replace a primary partition with an extended partition first.Command (m for help): e
e: unknown command Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition’s system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)Command (m for help): ^C
[root@localhost ~]# fdisk -lDisk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 66554433 16500001 83 LinuxDisk /dev/mapper/centos-root: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost ~]# e2fsck -f /dev/sda4
e2fsck 1.42.9 (28-Dec-2013) /dev/sda4 is in use. e2fsck: Cannot continue, aborting.[root@localhost ~]# e2fsck -f /dev/sda3
e2fsck 1.42.9 (28-Dec-2013) /dev/sda3 is in use. e2fsck: Cannot continue, aborting.[root@localhost ~]# e2fsck -f /dev/sda2
e2fsck 1.42.9 (28-Dec-2013) /dev/sda2 is in use. e2fsck: Cannot continue, aborting.[root@localhost ~]# e2fsck -f /dev/sda1
e2fsck 1.42.9 (28-Dec-2013) /dev/sda1 is mounted. e2fsck: Cannot continue, aborting.[root@localhost ~]# e2fsck -f /dev/sda4
e2fsck 1.42.9 (28-Dec-2013) /dev/sda4 is in use. e2fsck: Cannot continue, aborting.[root@localhost ~]# wget -O /tmp/devresize.py http://mirrors.tencentyun.com/install/virts/devresize.py
–2021-02-24 10:19:49-- http://mirrors.tencentyun.com/install/virts/devresize.py Resolving mirrors.tencentyun.com (mirrors.tencentyun.com)… failed: Name or service not known. wget: unable to resolve host address ‘mirrors.tencentyun.com’ [root@localhost ~]# wget -O /tmp/devresize.py http://mirrors.t^Ccentyun.com/install/virts/devresize.py [root@localhost ~]# ping qq.om ping: qq.om: Name or service not known [root@localhost ~]# ping qq.om ping: qq.om: Name or service not known [root@localhost ~]# ping qq.om ping: qq.om: Name or service not known [root@localhost ~]# pvdisplay — Physical volume — PV Name /dev/sda2 VG Name centos PV Size <9.50 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 2431 Free PE 0 Allocated PE 2431 PV UUID fiHW1H-3fa6-ofBc-NDfH-3lqP-XP9h-NfuULU— Physical volume —
PV Name /dev/sda3 VG Name centos PV Size 6.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 1535 Free PE 0 Allocated PE 1535 PV UUID ET7vj5-1Udd-a7jr-YPWq-xNWY-j9w7-0q9hK0— Physical volume —
PV Name /dev/sda4 VG Name centos PV Size <15.74 GiB / not usable 1.28 MiB Allocatable yes PE Size 4.00 MiB Total PE 4028 Free PE 58 Allocated PE 3970 PV UUID etNbR9-tfqv-1u8h-fSJE-msW3-UGIx-Gwi1Am[root@localhost ~]# vgdisplay
— Volume group — VG Name centos System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 3 Act PV 3 VG Size <31.23 GiB PE Size 4.00 MiB Total PE 7994 Alloc PE / Size 7936 / 31.00 GiB Free PE / Size 58 / 232.00 MiB VG UUID LuG9vX-3OCv-KoFE-HJKW-uMqL-qWvL-fpDOVI[root@localhost ~]# vgextend VolGroup /dev/s
sda sda2 sda4 sg1 snapshot sr0 stdin sda1 sda3 sg0 shm/ snd/ stderr stdout [root@localhost ~]# vgextend VolGroup /dev/s sda sda2 sda4 sg1 snapshot sr0 stdin sda1 sda3 sg0 shm/ snd/ stderr stdout [root@localhost ~]# vgextend VolGroup /dev/sda4 Physical volume ‘/dev/sda4’ is already in volume group ‘centos’ Unable to add physical volume ‘/dev/sda4’ to volume group ‘centos’ /dev/sda4: physical volume not initialized. [root@localhost ~]# pvdisplay — Physical volume — PV Name /dev/sda2 VG Name centos PV Size <9.50 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 2431 Free PE 0 Allocated PE 2431 PV UUID fiHW1H-3fa6-ofBc-NDfH-3lqP-XP9h-NfuULU— Physical volume —
PV Name /dev/sda3 VG Name centos PV Size 6.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 1535 Free PE 0 Allocated PE 1535 PV UUID ET7vj5-1Udd-a7jr-YPWq-xNWY-j9w7-0q9hK0— Physical volume —
PV Name /dev/sda4 VG Name centos PV Size <15.74 GiB / not usable 1.28 MiB Allocatable yes PE Size 4.00 MiB Total PE 4028 Free PE 58 Allocated PE 3970 PV UUID etNbR9-tfqv-1u8h-fSJE-msW3-UGIx-Gwi1Am[root@localhost ~]# fdisk -l
Disk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 66554433 16500001 83 LinuxDisk /dev/mapper/centos-root: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost ~]# fdisk /dev/sda4
Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x8a320fa2.Command (m for help): d
No partition is defined yet!Command (m for help): n
Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): ^C [root@localhost ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): n
If you want to create more than four partitions, you must replace a primary partition with an extended partition first.Command (m for help): d
Partition number (1-4, default 4): Partition 4 is deletedCommand (m for help): n
Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e): p Selected partition 4 First sector (33554432-98303999, default 33554432): Using default value 33554432 Last sector, +sectors or +size{K,M,G} (33554432-98303999, default 98303999): Using default value 98303999 Partition 4 of type Linux and of size 30.9 GiB is setCommand (m for help): p
Disk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 98303999 32374784 83 LinuxCommand (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 will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@localhost ~]# partprobe(8) -bash: syntax error near unexpected token `8’ [root@localhost ~]# partprobe [root@localhost ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): p
Disk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 98303999 32374784 83 LinuxCommand (m for help): ^C
[root@localhost ~]# fdisk -lDisk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 98303999 32374784 83 LinuxDisk /dev/mapper/centos-root: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost ~]# pvresize /dev/sda4
Physical volume “/dev/sda4” changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized [root@localhost ~]# pvresize No command with matching syntax recognised. Run ‘pvresize --help’ for more information. Correct command syntax is: pvresize PV …[root@localhost ~]# pvdisplay
— Physical volume — PV Name /dev/sda2 VG Name centos PV Size <9.50 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 2431 Free PE 0 Allocated PE 2431 PV UUID fiHW1H-3fa6-ofBc-NDfH-3lqP-XP9h-NfuULU— Physical volume —
PV Name /dev/sda3 VG Name centos PV Size 6.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 1535 Free PE 0 Allocated PE 1535 PV UUID ET7vj5-1Udd-a7jr-YPWq-xNWY-j9w7-0q9hK0— Physical volume —
PV Name /dev/sda4 VG Name centos PV Size 30.87 GiB / not usable 3.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 7903 Free PE 3933 Allocated PE 3970 PV UUID etNbR9-tfqv-1u8h-fSJE-msW3-UGIx-Gwi1Am[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 30G 29G 1.9G 94% / devtmpfs 747M 0 747M 0% /dev tmpfs 758M 0 758M 0% /dev/shm tmpfs 758M 8.8M 750M 2% /run tmpfs 758M 0 758M 0% /sys/fs/cgroup /dev/sda1 509M 173M 337M 34% /boot overlay 30G 29G 1.9G 94% /var/lib/docker/overlay2/3cc1fad6e57ea1096d0e8fbcf98816e3aea67544768614b9dcea353836ea81a9/merged overlay 30G 29G 1.9G 94% /var/lib/docker/overlay2/7482808cf7f406570d3233b8f948616b780be2841d153b19e16994429e69fd7e/merged shm 64M 0 64M 0% /var/lib/docker/containers/d8a8962dfb76b436b672770893668e55c1fba4041fa4029a5d79ee7b27a47a69/shm shm 64M 0 64M 0% /var/lib/docker/containers/94e5ac3c9ea75e5d64aeb8bf7f62457a5f43f9181d06425b3fbcdb8a7fa92e5b/shm tmpfs 152M 0 152M 0% /run/user/0 [root@localhost ~]# lvextend -l + 100%FREE /dev/mapper/centos-root Invalid argument for --extents: + Error during parsing of command line. [root@localhost ~]# lvextend -l +100%FREE /dev/mapper/centos-root Invalid argument for --extents: +100%FREE Error during parsing of command line. [root@localhost ~]# lvextend -l +100%FR^C /dev/mapper/centos-root [root@localhost ~]# esize2fs^C [root@localhost ~]# lvextend -l +100%FREE /dev/mapper/centos-root Size of logical volume centos/root changed from 30.00 GiB (7680 extents) to 45.36 GiB (11613 extents). Logical volume centos/root successfully resized. [root@localhost ~]# resize /dev/mapper/centos-root -bash: resize: command not found [root@localhost ~]# resize2fs /dev/mapper/centos-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn’t find valid filesystem superblock. [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 30G 29G 1.9G 94% / devtmpfs 747M 0 747M 0% /dev tmpfs 758M 0 758M 0% /dev/shm tmpfs 758M 8.8M 750M 2% /run tmpfs 758M 0 758M 0% /sys/fs/cgroup /dev/sda1 509M 173M 337M 34% /boot overlay 30G 29G 1.9G 94% /var/lib/docker/overlay2/3cc1fad6e57ea1096d0e8fbcf98816e3aea67544768614b9dcea353836ea81a9/merged overlay 30G 29G 1.9G 94% /var/lib/docker/overlay2/7482808cf7f406570d3233b8f948616b780be2841d153b19e16994429e69fd7e/merged shm 64M 0 64M 0% /var/lib/docker/containers/d8a8962dfb76b436b672770893668e55c1fba4041fa4029a5d79ee7b27a47a69/shm shm 64M 0 64M 0% /var/lib/docker/containers/94e5ac3c9ea75e5d64aeb8bf7f62457a5f43f9181d06425b3fbcdb8a7fa92e5b/shm tmpfs 152M 0 152M 0% /run/user/0 [root@localhost ~]# fdisk -lDisk /dev/sda: 50.3 GB, 50331648000 bytes, 98304000 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000015dbDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 20971519 9960448 8e Linux LVM /dev/sda3 20971520 33554431 6291456 83 Linux /dev/sda4 33554432 98303999 32374784 83 LinuxDisk /dev/mapper/centos-root: 48.7 GB, 48708452352 bytes, 95133696 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost ~]# resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28`@转载地址:http://aucci.baihongyu.com/