G
G
Grigory Shepelev2021-07-28 08:51:42
linux
Grigory Shepelev, 2021-07-28 08:51:42

How to increase LVM disk more than 4 partitions?

Increased the disk on the virtual machine from 11gb to 17gb

# df -h
File system Size Used Dost Used% Mounted in
/dev/mapper/centos-root 11G 1001M 11G 9% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1, 9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.5M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 143M 872M 15% /boot
tmpfs 380M 0 380M 0% /run/user/0

# fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 Unit sectors
= 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: 0x000ca6ff Device Load

Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 20971519 9436160 8e Linux LVM
/dev/sda3 20970680 218 LVM
/dev/sda4 23068672 25165823 1048576 8e Linux LVM

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 16G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 9G 0 part
│ └─centos-root 253:0 0 11G 0 lvm /
├─sda3 8:3 0 1G 0 part
│ └─centos -root 253:0 0 11G 0 lvm /
└─sda4 8:4 0 1G 0 part
└─centos-root 253:0 0 11G 0 lvm / sr0
11:0 1 1024M 0 rom

/sda5
#fdisk /dev/sda
: n
: p
Tried deleting /dev/sda4 and re-adding. But when informing the system about the change, it gives an error.

Command (m for help): d
Partition number (1-4, default 4): 4
Partition 4 is deleted

Command (m for help): n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): p Selected
partition 4 +size{K,M,G} (23068672-33554431, default 33554431): Default value 33554431 Partition 4 of type Linux and of size 5 GiB is set Command (m for reference): t Partition number (1-4 , default 4): Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for reference): w The partition table has been changed!



Called ioctl() to reread the partition table.

WARNING: Re-reading the partition table failed with error 16: The device or resource is 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)

# partprobe
Error: Partition(s) 4 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Wexter, 2021-07-28
@gshepelev

Disk label type: dos

You have a partition table on an MBR disk, it does not allow you to create more than 4 primary/extended partitions. Delete partition 4, create an extended one and create as much as you want in it.
Although, IMHO, it’s easier and better not to resize the disk, but to add a second virtual one and throw it entirely into lvm

M
Melkij, 2021-07-28
@melkij

Why add another section if you also want to add it to lvm? Just expand
parted resizepart + pvresize

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question