07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

# df -h /srv/files/<br />

Filesystem Size Used Avail Use% Mounted on<br />

/dev/mapper/vg_critical-lv_files<br />

6.9G 4.6G 2.1G 70% /srv/files<br />

CAUTION<br />

Resizing filesystems<br />

Not all filesystems can be resized online; resizing a volume can therefore<br />

require unmounting the filesystem first and remounting it aerwards. Of<br />

course, if one wants to shrink the space allocated to an LV, the filesystem<br />

must be shrunk first; the order is reversed when the resizing goes in the other<br />

direction: the logical volume must be grown before the filesystem on it. It's<br />

rather straightforward, since at no time must the filesystem size be larger<br />

than the block device where it resides (whether that device is a physical partition<br />

or a logical volume).<br />

The ext3, ext4 and xfs filesystems can be grown online, without unmounting;<br />

shrinking requires an unmount. The reiserfs filesystem allows online resizing<br />

in both directions. The venerable ext2 allows neither, and always requires<br />

unmounting.<br />

We could proceed in a similar fashion to extend the volume hosting the database, only we've<br />

reached the VG's available space limit:<br />

# df -h /srv/base/<br />

Filesystem Size Used Avail Use% Mounted on<br />

/dev/mapper/vg_critical-lv_base<br />

# vgdisplay -C vg_critical<br />

1008M 835M 123M 88% /srv/base<br />

VG #PV #LV #SN Attr VSize VFree<br />

vg_critical 2 2 0 wz--n- 8.14g 144.00m<br />

No matter, since LVM allows adding physical volumes to existing volume groups. For instance,<br />

maybe we've noticed that the sdb1 partition, which was so far used outside of LVM, only contained<br />

archives that could be moved to lv_backups. We can now recycle it and integrate it to the<br />

volume group, and thereby reclaim some available space. This is the purpose of the vgextend<br />

command. Of course, the partition must be prepared as a physical volume beforehand. Once the<br />

VG has been extended, we can use similar commands as previously to grow the logical volume<br />

then the filesystem:<br />

# pvcreate /dev/sdb1<br />

Physical volume "/dev/sdb1" successfully created<br />

# vgextend vg_critical /dev/sdb1<br />

Volume group "vg_critical" successfully extended<br />

# vgdisplay -C vg_critical<br />

VG #PV #LV #SN Attr VSize VFree<br />

vg_critical 3 2 0 wz--n- 9.09g 1.09g<br />

# [...]<br />

316 The Debian Administrator's Handbook

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!