Score:0

How can I resize my default ubuntu lvm?

jp flag

I need to add to default ubuntu lvm partition +20GB space. How can I do it in my case? You can see output of lsbkl command below. This is my virtualbox VM, not production server, and all of this disks and partitions are free, include raid5. Can I use all of this stuff for extend purposes? What steps should I follow to achieve it?

rebrainme2@ubuntu2:~$ lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
loop0                       7:0    0 43.6M  1 loop  /snap/snapd/14978
loop1                       7:1    0 43.6M  1 loop  /snap/snapd/15177
loop2                       7:2    0 55.5M  1 loop  /snap/core18/2344
loop3                       7:3    0 67.9M  1 loop  /snap/lxd/22526
loop4                       7:4    0 61.9M  1 loop  /snap/core20/1361
loop5                       7:5    0 67.2M  1 loop  /snap/lxd/21835
loop6                       7:6    0 61.9M  1 loop  /snap/core20/1376
loop7                       7:7    0 55.5M  1 loop  /snap/core18/2284
sda                         8:0    0   10G  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    1G  0 part  /boot
└─sda3                      8:3    0    9G  0 part
  └─ubuntu--vg-ubuntu--lv 253:2    0    9G  0 lvm   /
sdb                         8:16   0    8G  0 disk
├─sdb1                      8:17   0    2G  0 part  /mnt/sdb1
├─sdb2                      8:18   0    2G  0 part  /mnt/disk
├─sdb3                      8:19   0    2G  0 part  /mnt/sdb3
└─sdb4                      8:20   0    2G  0 part  /mnt/sdb4
sdc                         8:32   0    8G  0 disk
└─md0                       9:0    0   10G  0 raid5 /mnt/raid5
sdd                         8:48   0    2G  0 disk
└─md0                       9:0    0   10G  0 raid5 /mnt/raid5
sde                         8:64   0    2G  0 disk
└─md0                       9:0    0   10G  0 raid5 /mnt/raid5
sdf                         8:80   0    2G  0 disk
└─md0                       9:0    0   10G  0 raid5 /mnt/raid5
sdg                         8:96   0    2G  0 disk
└─md0                       9:0    0   10G  0 raid5 /mnt/raid5
sdh                         8:112  0    5G  0 disk
└─vg--rebrain-lv--rebrain 253:1    0    5G  0 lvm   /mnt/lvm
sdi                         8:128  0    2G  0 disk
└─md0                       9:0    0   10G  0 raid5 /mnt/raid5
sdj                         8:144  0    5G  0 disk
└─vg--test-lv--test       253:0    0    5G  0 lvm   /mnt/lv-test
sr0                        11:0    1 1024M  0 rom


/dev/disk/by-uuid/2d747eec-1c31-4c12-849c-efe362e3245e /boot ext4 defaults 0 1
/swap.img       none    swap    sw      0       0
UUID=a6c59d0e-37a7-4532-b843-6025dabef69f /mnt/sdb1 ext4 defaults 0 2
/dev/sdb2 /mnt/disk btrfs defaults 0 2
UUID=55165d2b-f3b5-46b2-af04-7366861c82b6 /mnt/sdb3 xfs defaults 0 2
UUID=1B74-0C7D /mnt/sdb4 vfat defaults 0 2
UUID=33fbef0a-0b91-41e9-ac7d-7d554797341c /mnt/raid5 ext4 defaults 0 2
UUID=60cd605a-dc94-452f-abe4-203079ac2e67  /mnt/lvm ext4 defaults 0 2
UUID=ed038f9c-896a-4aaf-a703-5134783701ab /mnt/lv-test ext4 defaults 0 2


rebrainme2@ubuntu2:~$ sudo vgdisplay
[sudo] password for rebrainme2:
  --- Volume group ---
  VG Name               vg-test
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <5.00 GiB
  PE Size               4.00 MiB
  Total PE              1279
  Alloc PE / Size       1279 / <5.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               ZCjGyZ-n1Rs-bT8d-z0cg-k8fO-9d2J-Fonggh

  --- Volume group ---
  VG Name               vg-rebrain
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  9
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <5.00 GiB
  PE Size               4.00 MiB
  Total PE              1279
  Alloc PE / Size       1279 / <5.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               Qu97rM-Fint-1yaA-skTo-F3gg-NOrE-1Mvj7q

  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <9.00 GiB
  PE Size               4.00 MiB
  Total PE              2303
  Alloc PE / Size       2303 / <9.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               XVpMjv-fuIw-UMG9-eeZN-2E09-sODM-kxF3I8



rebrainme2@ubuntu2:~$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdj
  VG Name               vg-test
  PV Size               5.00 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1279
  Free PE               0
  Allocated PE          1279
  PV UUID               N5fWom-E678-uzKn-c4Dt-ielb-57GN-9h2kfm

  --- Physical volume ---
  PV Name               /dev/sdh
  VG Name               vg-rebrain
  PV Size               5.00 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1279
  Free PE               0
  Allocated PE          1279
  PV UUID               osioC0-jmJe-OiLG-73Qm-63od-JcTm-VW2cCy

  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               ubuntu-vg
  PV Size               <9.00 GiB / not usable 0
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2303
  Free PE               0
  Allocated PE          2303
  PV UUID               aZUyYt-IujY-wAjp-Zrdu-PsV5-aVv6-Rqw0ND
Roid avatar
cg flag
You need provide more information, if the virtual group have enough space to extend the logical volume the task is easy. Can you provide the outputs of vgdisplay
jp flag
@Roid not problem, I've done it.
Score:0
jp flag

Ok, guys, I do it myself. This is what I've done, maybe it will be useful for anybody. Just in case, I wanted to extend ubuntu default logical volume with all my available disks.

  1. Delete logical volumes

    sudo lvremove vg-test/lv-test sudo lvremove vg-rebrain/lv-rebrain

  2. delete volume group

    sudo vgremove vg-rebrain sudo vgremove vg-test

  3. Execute pvscan to check all pv names

  4. Extend ubuntu default vg

    sudo vgextend ubuntu-vg /dev/sdh sudo vgextend ubuntu-vg /dev/sdj

  5. Extend logical volume

    sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

  6. Resize filesystem

    sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

Then I decided to add all my disks to current raid5 massive /dev/md0

sudo mdadm --add /dev/md0 /dev/sdb4
sudo mdadm --add /dev/md0 /dev/sdb3
sudo mdadm --add /dev/md0 /dev/sdb1
sudo mdadm --grow --raid-devices=9 /dev/md0

To monitor this process I used mdadm --detail /dev/md0

After this I decided to add all raid5 disk space to logical volume ubuntu-lv:

sudo pvcreate /dev/md0
sudo vgextend ubuntu-vg /dev/md0
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.