Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extending logical volume in ubuntu [closed]

I have the following problem. I ' ve added a 20GB to my ubuntu machine (from 20 to 40gb). Now this is what i get from fdisk -l command :

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 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 identifier: 0x000881a0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758    41940991    20719617    5  Extended
/dev/sda5          501760    41940991    20719616   8e  Linux LVM

Disk /dev/mapper/zabbix-root: 20.1 GB, 20124270592 bytes
255 heads, 63 sectors/track, 2446 cylinders, total 39305216 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 identifier: 0x00000000

Disk /dev/mapper/zabbix-root doesn't contain a valid partition table

Disk /dev/mapper/zabbix-swap_1: 1069 MB, 1069547520 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2088960 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 identifier: 0x00000000

I tried to exteng it with this command :

lvextend -L+20G /dev/mapper/zabbix-root

and i got following

Extending logical volume root to 38.74 GiB
Insufficient free space: 5120 extents needed, but only 5 available

Can someone help with what to do to extend my root with 20gb more?

Thanks

UPDATE

Ok i made it up with cfdisk then pvcreate and vgextend , then with lvextend and now i can see 40gb in my volumegroup with vgdisplay command.

next question is. How to refresh also info for commands like df etc.? with df -h there is still only 19gb in here... ill send my outputs from lvdisplay,vgdisplay,fdisk -l, and df -h.

fdisk -l :

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 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 identifier: 0x000881a0

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758    83886079    41692161    5  Extended
/dev/sda5          501760    41940991    20719616   8e  Linux LVM
/dev/sda6        41941055    83886079    20972512+  83  Linux

Disk /dev/mapper/zabbix-root: 41.6 GB, 41599107072 bytes
255 heads, 63 sectors/track, 5057 cylinders, total 81248256 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 identifier: 0x00000000

Disk /dev/mapper/zabbix-root doesn't contain a valid partition table

Disk /dev/mapper/zabbix-swap_1: 1069 MB, 1069547520 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2088960 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 identifier: 0x00000000

Disk /dev/mapper/zabbix-swap_1 doesn't contain a valid partition table

df -h :

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/zabbix-root   19G   17G  791M  96% /
udev                     489M  8.0K  489M   1% /dev
tmpfs                    200M  280K  199M   1% /run
none                     5.0M     0  5.0M   0% /run/lock
none                     498M     0  498M   0% /run/shm
/dev/sda1                228M   25M  192M  12% /boot

vgdisplay :

--- Volume group ---
VG Name               zabbix
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  5
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                2
Act PV                2
VG Size               39.76 GiB
PE Size               4.00 MiB
Total PE              10178
Alloc PE / Size       10173 / 39.74 GiB
Free  PE / Size       5 / 20.00 MiB
VG UUID               d4I8HJ-Rq2h-CPf1-LKFm-Bsam-3Mqe-9e39F3

lvdisplay :

--- Logical volume ---
LV Name                /dev/zabbix/root
VG Name                zabbix
LV UUID                N4NqWB-P6Hr-L51A-q98I-oAE9-qmvu-wHjQxo
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                38.74 GiB
Current LE             9918
Segments               3
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:0

--- Logical volume ---
LV Name                /dev/zabbix/swap_1
VG Name                zabbix
LV UUID                jDDTkD-VpZf-BXng-rQDI-HKSc-I8j2-mOY47c
LV Write Access        read/write
LV Status              available
# open                 2
LV Size                1020.00 MiB
Current LE             255
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:1

pvdisplay :

--- Physical volume ---
PV Name               /dev/sda5
VG Name               zabbix
PV Size               19.76 GiB / not usable 2.00 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              5058
Free PE               0
Allocated PE          5058
PV UUID               g2jnVt-dFQ6-takf-qz8L-QFf4-VAEQ-QYvp3u

--- Physical volume ---
PV Name               /dev/sda6
VG Name               zabbix
PV Size               20.00 GiB / not usable 992.50 KiB
Allocatable           yes
PE Size               4.00 MiB
Total PE              5120
Free PE               5
Allocated PE          5115
PV UUID               Il7KFu-rCa9-3sUE-0Hrz-qtyX-s8eL-eLpOGR
like image 420
Martin Fric Avatar asked May 13 '13 06:05

Martin Fric


1 Answers

So i figured it out. At first i needed to enlarge my disk size in vmware enviroment. After that i needed to rescan my ubuntu server with something like :

echo "- - -" > /sys/class/scsi_host/host#/scan

where # i had to replace with numbers for every host in scsi_host. Then i was able to see added space in ubuntu with command :

fdisk -l

In next step i had to prepare or format that freespace with using this command :

cfdisk /dev/sda

-you can format it as u wish (also space) There is a new partition now. - in my case : /dev/sda6

Next step is to use pvcreate for new partition :

pvcreate /dev/sda6

after this is done simply add it to existing volume group using :

vgextend vg_name /dev/sda6

and now we can finally extend my logical volume using :

lvextend -L+20G /dev/zabbix/root 

and if now check fdisk -l there is /zabbix-root with +20GB :) bud dont forget to use resize2fs to let filesystem know there is some change. If u will not do this u are not able to use new space.

resize2fs /dev/zabbix/root
like image 134
Martin Fric Avatar answered Sep 20 '22 20:09

Martin Fric