If you are already using LVM, you you have already taken a very smart step to manage your disks and partitions. I will show you the steps needed to resize (extend) an LVM volume and how to grow the filesystem that is on top of the volume.

I assume that you are familiar with LVM.

So, if we want to add a whole disk, we have to tell the LVM to use an entire partition:

fdisk /dev/sdc
n(ew)
p(rimary)
1
t(ype)
8e (LVM)
w(rite)

Now, we can mark the partition with a LVM compatible flag:

pvcreate /dev/sdc1

Depending on your LVM version, you will be able to display the information about your physical volume (I am not, but that's no problem, pvdisplay -C -a would show the volume):


root@sluvf001:~# pvscan
PV /dev/sdb1 VG vg00 lvm2 [15,99 GB / 0 free]
Total: 1 [15,99 GB] / in use: 1 [15,99 GB] / in no VG: 0 [0 ]
root@sluvf001:~# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg00
PV Size 15,99 GB / not usable 0
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 4094
Free PE 0
Allocated PE 4094
PV UUID K8Dgt9-pdYo-WDg4-IW9v-MVyI-Cl9i-5b29lC

Our volumegroup has still one pv:

root@sluvf001:~# vgdisplay
--- Volume group ---
VG Name vg00
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 15,99 GB
PE Size 4,00 MB
Total PE 4094
Alloc PE / Size 4094 / 15,99 GB
Free PE / Size 0 / 0
VG UUID 9Ep797-ctSQ-z6KY-xJ8d-oajm-Yblj-AGM4ng

So, now, we want to extend the volume group, which means that we are adding this physical volume to the pool of allocatable physical volumes in this volume group.

root@sluvf001:~# vgextend -v vg00 /dev/sdc1
Checking for volume group "vg00″
Archiving volume group "vg00″ metadata (seqno 2).
Adding physical volume '/dev/sdc1′ to volume group 'vg00′
Wiping cache of LVM-capable devices
Volume group "vg00″ will be extended by 1 new physical volumes
Creating volume group backup "/etc/lvm/backup/vg00″ (seqno 3).
Volume group "vg00″ successfully extended

root@sluvf001:~# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg00
PV Size 15,99 GB / not usable 0
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 4094
Free PE 0
Allocated PE 4094
PV UUID K8Dgt9-pdYo-WDg4-IW9v-MVyI-Cl9i-5b29lC

--- Physical volume ---
PV Name /dev/sdc1
VG Name vg00
PV Size 15,99 GB / not usable 0
Allocatable yes
PE Size (KByte) 4096
Total PE 4094
Free PE 4094
Allocated PE 0
PV UUID T6KwNt-Qd5c-1AUX-Nwej-2mk8-rrWF-tBTR02

We are able to see our /dev/sdc1 with pvdisplay NOW.

Let's have a look at our logical volume:

root@sluvf001:~# lvdisplay
--- Logical volume ---
LV Name /dev/vg00/lvsamba
VG Name vg00
LV UUID qZnJxj-rpsQ-j313-yRrN-zWcr-lX7H-I98W0D
LV Write Access read/write
LV Status available
# open 2
LV Size 15,99 GB
Current LE 4094
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:0

In order to extend the filesystem over all used physical volumes in our volume group, we need to know the total physical extends:

root@sluvf001:~# vgdisplay
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 31,98 GB
PE Size 4,00 MB
Total PE 8188
Alloc PE / Size 4094 / 15,99 GB
Free PE / Size 4094 / 15,99 GB
VG UUID 9Ep797-ctSQ-z6KY-xJ8d-oajm-Yblj-AGM4ng

root@sluvf001:~# lvextend -l 8188 -v /dev/vg00/lvsamba
Finding volume group vg00
Archiving volume group "vg00″ metadata (seqno 3).
Extending logical volume lvsamba to 31,98 GB
Creating volume group backup "/etc/lvm/backup/vg00″ (seqno 4).
Found volume group "vg00″
Found volume group "vg00″
Loading vg00-lvsamba table
Suspending vg00-lvsamba (253:0)
Found volume group "vg00″
Resuming vg00-lvsamba (253:0)
Logical volume lvsamba successfully resized

We just resized the volume ("partition") of our logical volume group.

If you are using reiserfs (version 3), you are able to resize the file system without (un)mounting. resize_reiserfs -f /dev/vg00/lvsamba tells reiserfs to allocate all available blocks (or: extends) in order to enlarge the filesystem locates on /dev/vg00/lvsamba

root@sluvf001:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/.static/dev/sda1
4016284 1611592 2200672 43% /
varrun 192920 128 192792 1% /var/run
varlock 192920 0 192920 0% /var/lock
udev 10240 72 10168 1% /dev
devshm 192920 0 192920 0% /dev/shm
/dev/mapper/vg00-lvsamba
16768508 15366404 1402104 92% /srv/samba

root@sluvf001:~# resize_reiserfs -f /dev/vg00/lvsamba
resize_reiserfs 3.6.19 (2003 www.namesys.com)

resize_reiserfs: On-line resizing finished successfully.

root@sluvf001:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/.static/dev/sda1
4016284 1611592 2200672 43% /
varrun 192920 128 192792 1% /var/run
varlock 192920 0 192920 0% /var/lock
udev 10240 72 10168 1% /dev
devshm 192920 0 192920 0% /dev/shm
/dev/mapper/vg00-lvsamba
33537020 15366404 18170616 46% /srv/samba

Et voila. We doubled our space on /srv/samba.

Ähnliche Beiträge:

  1. Wie kann man die Arcor / Youporn Sperre umgehen?
  2. Vergrößern einer ext3-Partition, oder eine endlose Geschichte

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Gibt einen Kommentar ab

Folgende HTML-Tags sind erlaubt: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment Spam Protection by WP-SpamFree