Archive for September, 2010

Solved: Garbage getFrame Images with ffmpeg-php 0.6.0 and ffmpeg 0.5

After updating my installation of ffmpeg and ffmpeg-php on one of my web servers I noticed that images grabbed using ffmpeg-php’s getFrame function spat out weird garbage, usually three corrupt looking frames across the top and static in the bottom two thirds. I tried tinkering with it for a very long time with no success until putting it off for a few months and tonight I finally found the solution: recompiling ffmpeg with the bindist use flag.

# echo "media-video/ffmpeg cpudetection bindist" >> /etc/portage/package.use; emerge ffmpeg

Still not sure exactly what the problem was but glad to have it fixed now, all those corrupt thumbnails were embarrassing :s

Sneak Peek: Server Sentinel

I’m currently working on a rapidly redeployable Gentoo-based virtual machine for service monitoring, statistics graphing and trending and centralized log file collection and analysis. So far it’s just a pretty menu and a collection of third party apps but before I release it I intend on drawing them together through single-sign on. Access is provided over VPN and SSL only.

Managing Raw Disk/File System Image Files

Xen users frequently deal with raw file system image files. While this isn’t the ideal method for managing virtual machine storage it is the format of choice for redistribution. This article is a simple cheat sheet that will help you deal with sparse and regular image files.

To create a blank image file run:

dd if=/dev/zero bs=1M count=X > image.img

Where X is the size of the file in MB.

To enlarge an image file run:

dd if=/dev/zero bs=1M count=X >> image.img

Where X is the amount of space you want to add in MB.

To create a sparse file run:

dd if=/dev/zero of=image.img seek=X bs=1M count=0

Where X is the size of the image in MB

To enlarge a sparse file run:

dd if=/dev/zero of=image.img seek=X bs=1M count=0

Where seek=8 should be the current size of the sparse file plus the amount of space you wish to grow the image by in MB.

To enlarge an ext2 or ext3 file system to fill an expanded disk image run:

e2fsck -f image.img
e2resizefs image.img
e2fsck -f image.img

To create an ext2 file system on an image file run:

mke2fs image.img

To create an ext3 file system on an image file run:

mke2fs -j image.img

I often find that mke2fs’ defaults for file systems between 2 and 6 gigs are not efficient for full linux installs, make sure you have enough inodes and to really save on space reduce the block size to 1KB. Optionally you can force the defaults for a “small” file system by using the -T flag:

mke2fs -j -T small image.img

This helps clip off a lot of the wasted space created by the (Gentoo in particular but any given flavour’s) large number of small files.

To make a reiserfs file system run:

mkreiserfs image.img

Note that reiser’s ability to incorporate files smaller than the block size into its B-* tree probably makes assigning a smaller (than 4096B) block size more costly than it’s worth.

To expand a reiserfs file system to fill the available space in an image file run

resize_reiserfs image.img

To make an XFS file system run:

mkfs.xfs image.img

XFS caches heavily making it on one hand a decent file-based image performer at the cost of being slightly more fragile than other solutions. Another bonus is it is designed to scale up easily, however I tend to only use XFS as the “mother” FS on battery-backed hardware RAID setups and use ext3 for VM images due to its comparative resilience and the higher level of crash vulnerability virtual machines have over their host counterparts.

To expand an XFS file system to use all available space on a partition image run:

mount -o loop image.img /mnt/image
xfs_growfs /mnt/image

To mount an image file run

mount -o loop image.img /mnt/image

Remember not to perform any operations (like DD) on an image file while it is mounted.

To chroot into an image file with a working linux installation after mounting run:

mount -o bind /dev /mnt/image/dev
mount -t proc none /mnt/image/proc
chroot /mnt/image /bin/bash

Include /bin/bash where the default shell might be less permissive, i.e. standard sh or leave it off if the type of shell is unimportant.

To copy a file system’s contents verbatim to another file system mount both then run:

cp -ax /mnt/image1/* /mnt/image2/

You should do this to a freshly created sparse or regular file to increase the effectiveness of compression when redistributing an image. In a regular file, the empty space that would otherwise be completely zeroed out instead contains remnants of deleted files.

Return top
foxpa.ws
Online Marketing Toplist
Internet
Technology Blogs - Blog Rankings

Internet Blogs - BlogCatalog Blog Directory

Bad Karma Networks

Please Donate!


Made in Canada  •  There's a fox in the Gibson!  •  2010-12