[BraLUG] Online Erweitern von ext3 Filesystemen
slipway at inbev.de
slipway at inbev.de
Do Jul 21 11:54:10 CEST 2011
Hallo zusammen,
nochmals danke für den, was den Ort angeht, ungeplanten gestrigen
Freiluft-Linux-Abend!
Gestern abend hatte ich mich ein wenig, ich glaube mit Markus?, unterhalten.
Irgendwie kamen wir auf Filesysteme zu sprechen und er sagte dabei,
dass ext3 FS nicht online erweiterbar wären, sondern erst ext4.
Ich nehme an, dass er sich nur vertan hatte und eigentlich ext2 im
Hinterkopf hatte.
Denn die online Erweiterung von ext3 FS mache ich fast täglich.
Wie ich bei Blick in die /proc/filesystems jetzt fetsgestellt habe,
bieten die Kernel meiner RHEL 5 Systeme noch nicht mal ext4 Support.
War ich jetzt wohl von Fedora verwöhnt, deren mittlerweile sogar BTRFS
supportet.
[root at gyro:/opt/nagios/etc/objects]
# grep ext /proc/filesystems
ext2
ext3
Ich will jetzt niemanden langweilen oder gar rechthaberisch
erscheinen, aber hier mal kurz gezeigt, wie wunderbar online
Erweiterungen bei ext3 funktionieren.
[root at gyro:/opt/nagios/etc/objects]
# vgdisplay vg_local|grep -e Size -e Free
VG Size 46.56 GB
PE Size 32.00 MB
Alloc PE / Size 1013 / 31.66 GB
Free PE / Size 477 / 14.91 GB
[root at gyro:/opt/nagios/etc/objects]
# lvcreate -l 8 -n lv_trial vg_local
Logical volume "lv_trial" created
[root at gyro:/opt/nagios/etc/objects]
# mke2fs -q -j /dev/vg_local/lv_trial
Wie bereits oben gezeigt, supportet mein Kernel gar nichts anderes
ausser ext{2,3}, aber hier nochmal die magic No. des angelegten ext3
FS als Nachweis.
[root at gyro:/opt/nagios/etc/objects]
# tune2fs -l /dev/vg_local/lv_trial|grep magic
Filesystem magic number: 0xEF53
[root at gyro:/opt/nagios/etc/objects]
# mount /dev/vg_local/lv_trial /mnt/tmp1
[root at gyro:/opt/nagios/etc/objects]
# mount|grep trial
/dev/mapper/vg_local-lv_trial on /mnt/tmp1 type ext3 (rw)
[root at gyro:/opt/nagios/etc/objects]
# df -h /mnt/tmp1
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_local-lv_trial
248M 11M 226M 5% /mnt/tmp1
Mal schnell das FS künstlich gefüllt.
[root at gyro:/opt/nagios/etc/objects]
# dd if=/dev/zero bs=1M count=226 seek=225 of=/mnt/tmp1/chunck
226+0 records in
226+0 records out
236978176 bytes (237 MB) copied, 1.19605 seconds, 198 MB/s
[root at gyro:/opt/nagios/etc/objects]
# ls -l /mnt/tmp1/chunck
-rw-r--r-- 1 root root 472907776 Jul 21 11:29 /mnt/tmp1/chunck
[root at gyro:/opt/nagios/etc/objects]
# df -h /mnt/tmp1
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_local-lv_trial
248M 237M 0 100% /mnt/tmp1
und online erweitert
[root at gyro:/opt/nagios/etc/objects]
# lvextend -l +8 /dev/vg_local/lv_trial
Extending logical volume lv_trial to 512.00 MB
Logical volume lv_trial successfully resized
[root at gyro:/opt/nagios/etc/objects]
# lvdisplay /dev/vg_local/lv_trial |grep Size
LV Size 512.00 MB
[root at gyro:/opt/nagios/etc/objects]
# resize2fs /dev/vg_local/lv_trial
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg_local/lv_trial is mounted on /mnt/tmp1; on-line
resizing required
Performing an on-line resize of /dev/vg_local/lv_trial to 524288 (1k) blocks.
The filesystem on /dev/vg_local/lv_trial is now 524288 blocks long.
[root at gyro:/opt/nagios/etc/objects]
# df -h /mnt/tmp1
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_local-lv_trial
496M 238M 234M 51% /mnt/tmp1
[root at gyro:/opt/nagios/etc/objects]
# tune2fs -l /dev/vg_local/lv_trial|grep -E 'Block (size|count)'
Block count: 524288
Block size: 1024
[root at gyro:/opt/nagios/etc/objects]
# echo $((524288/1024))
512
Also online extension ist kein Alleinstellungsmerkmal von XFS.
Allerdings muss ich zugeben, dass online shrinking nicht möglich ist
und einen fsck zuvor erwartet.
[root at gyro:/opt/nagios/etc/objects]
# tune2fs -l /dev/vg_local/lv_trial|awk -F':[[:space:]]*' '/Block
count/{print$2/2}'|xargs resize2fs /dev/vg_local/lv_trial
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg_local/lv_trial is mounted on /mnt/tmp1; on-line
resizing required
On-line shrinking from 524288 to 262144 not supported.
[root at gyro:/opt/nagios/etc/objects]
# umount /mnt/tmp1
[root at gyro:/opt/nagios/etc/objects]
# tune2fs -l /dev/vg_local/lv_trial|awk -F':[[:space:]]*' '/Block
count/{print$2/2}'|xargs resize2fs /dev/vg_local/lv_trial
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/vg_local/lv_trial' first.
[root at gyro:/opt/nagios/etc/objects]
# fsck -t ext3 -fC /dev/vg_local/lv_trial
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg_local/lv_trial: 12/131072 files (8.3% non-contiguous),
259410/524288 blocks
[root at gyro:/opt/nagios/etc/objects]
# tune2fs -l /dev/vg_local/lv_trial|awk -F':[[:space:]]*' '/Block
count/{print$2/2}'|xargs resize2fs /dev/vg_local/lv_trial
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg_local/lv_trial to 262144 (1k) blocks.
The filesystem on /dev/vg_local/lv_trial is now 262144 blocks long.
[root at gyro:/opt/nagios/etc/objects]
# mount /dev/vg_local/lv_trial /mnt/tmp1
[root at gyro:/opt/nagios/etc/objects]
# df -h /mnt/tmp1
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_local-lv_trial
248M 237M 763K 100% /mnt/tmp1
[root at gyro:/opt/nagios/etc/objects]
# umount /mnt/tmp1
[root at gyro:/opt/nagios/etc/objects]
# lvremove -f /dev/vg_local/lv_trial
Logical volume "lv_trial" successfully removed
Naja, aber alle Welt will in der Regel nur online erweitern aber nicht
unbedingt verkleinern, oder?
Kann XFS eigentlich online verkleinert werden?
Gruß
Ralph
Mehr Informationen über die Mailingliste Bralug