Resize таблицы разделов
1) Проверяем размер диска (/dev/sda)
root@dctest-d:~# lsblk
3) Выполняем сканирование диска (поиск изменений)
root@dctest-d:~# echo 1 > /sys/block/sda/device/rescan
4) Проверяем изменения /dev/sda
root@dctest-d:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 68.4G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 48.6G 0 part
├─dctest--d--vg-root 254:0 0 44.6G 0 lvm /
└─dctest--d--vg-swap_1 254:1 0 4G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 68.4G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 48.6G 0 part
├─dctest--d--vg-root 254:0 0 44.6G 0 lvm /
└─dctest--d--vg-swap_1 254:1 0 4G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
5) Выполняем изменения таблицы разделов
root@dctest-d:~# parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
6) Смотрим на размеры диска и существующих разделов
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 73.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 256MB 255MB primary ext2 boot
2 256MB 52.4GB 52.2GB extended
5 257MB 52.4GB 52.2GB logical lvm
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 73.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 256MB 255MB primary ext2 boot
2 256MB 52.4GB 52.2GB extended
5 257MB 52.4GB 52.2GB logical lvm
7) изменяем размеры разделов LVM, начиная с верхнего
(parted) resizepart 2 100%
(parted) resizepart 5 100%
(parted) resizepart 5 100%
8) Проверяем размеры разделов и выходим из parted
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 73.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 256MB 255MB primary ext2 boot
2 256MB 73.4GB 73.1GB extended
5 257MB 73.4GB 73.1GB logical lvm
(parted) q
Information: You may need to update /etc/fstab.
Disk /dev/sda: 73.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 256MB 255MB primary ext2 boot
2 256MB 73.4GB 73.1GB extended
5 257MB 73.4GB 73.1GB logical lvm
(parted) q
Information: You may need to update /etc/fstab.
9) Сообщаем системе об изменениях в разделах
root@dctest-d:~# partprobe
10) Проверяем изменения раздела sda5
root@dctest-d:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 68.4G 0 disk
├─sda1 8:1 0 243M 0 part /boot
└─sda5 8:5 0 68.1G 0 part
├─dctest--d--vg-root 254:0 0 44.6G 0 lvm /
└─dctest--d--vg-swap_1 254:1 0 4G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 68.4G 0 disk
├─sda1 8:1 0 243M 0 part /boot
└─sda5 8:5 0 68.1G 0 part
├─dctest--d--vg-root 254:0 0 44.6G 0 lvm /
└─dctest--d--vg-swap_1 254:1 0 4G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
11) LVM. Проверяем размер PV /dev/sda5
====================================
root@dctest-d:~# pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name dctest-d-vg
PV Size 48.59 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12438
Free PE 0
Allocated PE 12438
PV UUID iiyna2-lRS7-7gPm-QZX2-kRpH-Ssw2-ehFBSz
--- Physical volume ---
PV Name /dev/sda5
VG Name dctest-d-vg
PV Size 48.59 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12438
Free PE 0
Allocated PE 12438
PV UUID iiyna2-lRS7-7gPm-QZX2-kRpH-Ssw2-ehFBSz
12) LVM. Изменяем и проверяем размер PV /dev/sda5
root@dctest-d:~# pvresize /dev/sda5
Physical volume "/dev/sda5" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
root@dctest-d:~# pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name dctest-d-vg
PV Size 68.12 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 17438
Free PE 5000
Allocated PE 12438
PV UUID iiyna2-lRS7-7gPm-QZX2-kRpH-Ssw2-ehFBSz
PV Name /dev/sda5
VG Name dctest-d-vg
PV Size 68.12 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 17438
Free PE 5000
Allocated PE 12438
PV UUID iiyna2-lRS7-7gPm-QZX2-kRpH-Ssw2-ehFBSz
13) LVM. Проверяем размер LV /dev/dctest-d-vg/root
root@dctest-d:~# lvdisplay
--- Logical volume ---
LV Path /dev/dctest-d-vg/root
LV Name root
VG Name dctest-d-vg
LV UUID P6PiaC-thno-e5h7-Lo75-KM1v-Qpw4-2b5QSN
LV Write Access read/write
LV Creation host, time dctest-d, 2019-05-16 08:11:12 +0300
LV Status available
# open 1
LV Size 44.59 GiB
Current LE 11414
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/dctest-d-vg/swap_1
LV Name swap_1
VG Name dctest-d-vg
LV UUID Xe11YQ-IYrD-D5Xs-5oQy-1b1r-VkQe-6AL4ab
LV Write Access read/write
LV Creation host, time dctest-d, 2019-05-16 08:11:12 +0300
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
--- Logical volume ---
LV Path /dev/dctest-d-vg/root
LV Name root
VG Name dctest-d-vg
LV UUID P6PiaC-thno-e5h7-Lo75-KM1v-Qpw4-2b5QSN
LV Write Access read/write
LV Creation host, time dctest-d, 2019-05-16 08:11:12 +0300
LV Status available
# open 1
LV Size 44.59 GiB
Current LE 11414
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/dctest-d-vg/swap_1
LV Name swap_1
VG Name dctest-d-vg
LV UUID Xe11YQ-IYrD-D5Xs-5oQy-1b1r-VkQe-6AL4ab
LV Write Access read/write
LV Creation host, time dctest-d, 2019-05-16 08:11:12 +0300
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
14) LVM. Изменяем и проверяем размер LV /dev/dctest-d-vg/root
root@dctest-d:~# lvextend -l +100%FREE /dev/dctest-d-vg/root
Size of logical volume dctest-d-vg/root changed from 44.59 GiB (11414 extents) to 64.12 GiB (16414 extents).
Logical volume dctest-d-vg/root successfully resized.
root@dctest-d:~# lvdisplay
--- Logical volume ---
LV Path /dev/dctest-d-vg/root
LV Name root
VG Name dctest-d-vg
LV UUID P6PiaC-thno-e5h7-Lo75-KM1v-Qpw4-2b5QSN
LV Write Access read/write
LV Creation host, time dctest-d, 2019-05-16 08:11:12 +0300
LV Status available
# open 1
LV Size 64.12 GiB
Current LE 16414
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/dctest-d-vg/swap_1
LV Name swap_1
VG Name dctest-d-vg
LV UUID Xe11YQ-IYrD-D5Xs-5oQy-1b1r-VkQe-6AL4ab
LV Write Access read/write
LV Creation host, time dctest-d, 2019-05-16 08:11:12 +0300
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
Size of logical volume dctest-d-vg/root changed from 44.59 GiB (11414 extents) to 64.12 GiB (16414 extents).
Logical volume dctest-d-vg/root successfully resized.
root@dctest-d:~# lvdisplay
--- Logical volume ---
LV Path /dev/dctest-d-vg/root
LV Name root
VG Name dctest-d-vg
LV UUID P6PiaC-thno-e5h7-Lo75-KM1v-Qpw4-2b5QSN
LV Write Access read/write
LV Creation host, time dctest-d, 2019-05-16 08:11:12 +0300
LV Status available
# open 1
LV Size 64.12 GiB
Current LE 16414
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/dctest-d-vg/swap_1
LV Name swap_1
VG Name dctest-d-vg
LV UUID Xe11YQ-IYrD-D5Xs-5oQy-1b1r-VkQe-6AL4ab
LV Write Access read/write
LV Creation host, time dctest-d, 2019-05-16 08:11:12 +0300
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
15) FS. Проверяем свободное место
root@dctest-d:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 396M 5.4M 391M 2% /run
/dev/mapper/dctest--d--vg-root 26G 794M 24G 4% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 236M 37M 187M 17% /boot
tmpfs 396M 0 396M 0% /run/user/1000
16) FS. Изменяем и проверяем размер
root@dctest-d:~# resize2fs /dev/dctest-d-vg/root
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/dctest-d-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 6, new_desc_blocks = 9
The filesystem on /dev/dctest-d-vg/root is now 16807936 (4k) blocks long.
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/dctest-d-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 6, new_desc_blocks = 9
The filesystem on /dev/dctest-d-vg/root is now 16807936 (4k) blocks long.
root@dctest-d:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 68.4G 0 disk
├─sda1 8:1 0 243M 0 part /boot
└─sda5 8:5 0 68.1G 0 part
├─dctest--d--vg-root 254:0 0 64.1G 0 lvm /
└─dctest--d--vg-swap_1 254:1 0 4G 0 lvm [SWAP]
sr0
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 68.4G 0 disk
├─sda1 8:1 0 243M 0 part /boot
└─sda5 8:5 0 68.1G 0 part
├─dctest--d--vg-root 254:0 0 64.1G 0 lvm /
└─dctest--d--vg-swap_1 254:1 0 4G 0 lvm [SWAP]
sr0