Skip to content
www.mytechnote.ru
Menu
  • Administration
    • Scripts
  • Equipment
    • Reviews
    • Instructions
  • Other
  • English
    • English
    • Русский
Menu

How to Extend an LVM Partition in Linux

It is quite common to deploy virtual machines from templates, which means their disks often need to be expanded afterward. I decided to leave this note here as a quick reference with the required commands for extending a partition on Astra Linux 1.8 using LVM.

1) Check the available disks

sudo lsblk

Example output:

NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                    8:0    0   101G  0 disk
├─sda1                 8:1    0   487M  0 part /boot
├─sda2                 8:2    0     1K  0 part
└─sda5                 8:5    0  29.5G  0 part
  ├─astra--vg-root   252:0    0  28.6G  0 lvm  /
  └─astra--vg-swap_1 252:1    0   980M  0 lvm  [SWAP]
sr0

2) Force the system to rescan the disk.

This allows the operating system to detect the new virtual disk size.

sudo echo 1 > /sys/class/block/sda/device/rescan

Then verify the disk layout again:

sudo lsblk

Example output:

NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                    8:0    0   101G  0 disk
├─sda1                 8:1    0   487M  0 part /boot
├─sda2                 8:2    0     1K  0 part
└─sda5                 8:5    0  29.5G  0 part
  ├─astra--vg-root   252:0    0  28.6G  0 lvm  /
  └─astra--vg-swap_1 252:1    0   980M  0 lvm  [SWAP]
sr0                  11:0    1  1024M  0 rom

3) Install Parted and extend the partition

This step is optional. You can use fdisk instead, but I find parted more convenient.

Install Parted:

sudo apt update && sudo apt -y install parted

Start the utility:

sudo parted

Display the partition table:

(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 108GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  512MB   511MB   primary   ext2         boot
 2      513MB   32,2GB  31,7GB  extended
 5      513MB   32,2GB  31,7GB  logical                lvm

Resize the partitions:

(parted) resizepart 2 100% 
(parted) resizepart 5 100% 
(parted) quit

If there are no errors, reload the partition table and verify the changes:

sudo partprobe /dev/sda 
sudo lsblk

NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                    8:0    0   101G  0 disk
├─sda1                 8:1    0   487M  0 part /boot
├─sda2                 8:2    0     1K  0 part
└─sda5                 8:5    0 100,5G  0 part
  ├─astra--vg-root   252:0    0  28,6G  0 lvm  /
  └─astra--vg-swap_1 252:1    0   980M  0 lvm  [SWAP]
sr0                   11:0    1  1024M  0 rom

4) Extend the LVM volume

First, check the physical volumes (PV):

sudo pvs
PV VG Fmt Attr PSize PFree 
/dev/sda5 astra-vg lvm2 a-- <29.52g 0

Resize the physical volume:

sudo pvresize /dev/sda5
sudo pvs
PV         VG        Fmt  Attr PSize      PFree
/dev/sda5  astra-vg lvm2 a--  <100.52g   71.00g

Next, check the logical volumes (LV):

sudo lvscan
ACTIVE '/dev/astra-vg/root'   [28.56 GiB] inherit
ACTIVE '/dev/astra-vg/swap_1' [980.00 MiB] inherit

Extend the root logical volume:

sudo lvextend -l +100%FREE /dev/astra-vg/root
sudo lvs
LV      VG        Attr       LSize
root    astra-vg -wi-ao---- 99.56g
swap_1  astra-vg -wi-ao---- 980.00m

5) Resize the filesystem

Finally, resize the filesystem to use the newly allocated space:

resize2fs /dev/astra-vg/root

resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/astra-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 13
The filesystem on /dev/astra-vg/root is now 26099712 (4k) blocks long.

6) Verify the result

df -h

Filesystem                     Size  Used Avail Use% Mounted on
udev                           7.8G     0  7.8G   0% /dev
tmpfs                          1.6G  824K  1.6G   1% /run
/dev/mapper/astra--vg-root      98G  5.6G   88G   6% /
tmpfs                          7.9G  8.0K  7.9G   1% /dev/shm
tmpfs                          5.0M     0  5.0M   0% /run/lock
/dev/sda1                      455M  164M  267M  39% /boot
tmpfs                          1.6G     0  1.6G   0% /run/user/1000z0_0_0x0_0x0
Posted on 30.07.202630.07.2026 by sanglyb

Post navigation

← SCCM Reporting Errors After Migrating from SQL Server 2016 to 2019

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Подписывайтесь

Youtube
vk
telegram
github
twitter
rss
  • Форум
  • Об авторе
  • Поддержать автора

Популярные записи

Новые записи

  • How to Extend an LVM Partition in Linux
  • SCCM Reporting Errors After Migrating from SQL Server 2016 to 2019
  • Problem Using PassFiltEx on Older CPUs
  • How to remove attachments from old calendar events in Exchange using a script
  • How to download and install Office 2024 LTSC

Архивы

  • 2026 (3)
  • 2025 (5)
  • 2024 (7)
  • 2023 (30)
  • 2022 (4)
  • 2020 (17)
  • 2017 (82)
  • 2016 (5)
© 2015-2026 www.mytechnote.ru
Использование материалов сайта возможно только с разрешения владельца или обязательна индексируемая, прямая, передающая вес ссылка на материал.