Linux LVM - MD Raid vs LVM mirror. Snapshots.

I'm migrating a xen machine (my gallery - g.pechurka.com ) from one machine to another.
I wanted to research from quite a long time what should I use in Linux.
I've got a nice working setup but when you research and test you always makes things better.

So, this night I've researched on if I should do MD raid1 or LVM2 mirroring.
Short answer: MD0 raid1 and Physical Volume over it (as used to now). Sometimes LVM is faster but when using single file. You can have serious problems if you have power failure or disk failure/disconnection when using LVM mirroring. It relies on underneath layer to write caches. For further reading open the link below.
Long answer here: lvm2-mirrors-vs-md-raid-1

Filesystems speed comparison: ext2, ext3, ext4dev, reiserfs and xfs.

Just a simple test for speed of ext2, ext3, ext4dev, reiserfs and xfs.
I've created a 5G lvm and did mkfs.* to it with all these systems.
lvm> lvcreate -L 5G -n speedtest tvg
mkfs (all default opts)
mount (no opts)
Then make dd if=/dev/zero of=a bs=G count=3
Then make dd if=a of=b


Here are the results:

FS type dd if=/dev/zero of=a speed dd if=a of=b speed
ext2 3221225472 bytes (3.2 GB) copied, 225.283 s, 14.3 MB/s 2047094784 bytes (2.0 GB) copied, 38.4914 s, 53.2 MB/s
ext3 3221225472 bytes (3.2 GB) copied, 248.433 s, 13.0 MB/s 1912479744 bytes (1.9 GB) copied, 52.1087 s, 36.7 MB/s
ext4 3221225472 bytes (3.2 GB) copied, 281.699 s, 11.4 MB/s 1918500864 bytes (1.9 GB) copied, 49.1343 s, 39.0 MB/s
reiserfs 3221225472 bytes (3.2 GB) copied, 248.827 s, 12.9 MB/s 2108379136 bytes (2.1 GB) copied, 62.5061 s, 33.7 MB/s
xfs 3221225472 bytes (3.2 GB) copied, 426.823 s, 7.5 MB/s 2132619264 bytes (2.1 GB) copied, 55.3356 s, 38.5 MB/s


It seems like ext3 is working best with big continious files currently.
Of course this is not a real life situation.
Maybe xfs and reiser will be better for a lot of small files? (reiser has it's glory about that).

Please let me know what you think!

Copy permissions of files from one dir to another or how to change permissions and ownership of identical dirs.

Have you ever been in the middle of deployment and noticed that the owner and permissions on dev package you have and production one are different?
Very oftern when deploing some sites I have two identical dirs with different owners and permissions - one from a dev web server and another from the production (where everything is tuned and working).
Here is a quick and durty way to change all ownership and permissions from prodution to development dir.
BE VERY CAREFULL. These permissions are not all masks. These are the one I needed!
Don't blind apply this script and run chm.sh after that!!!
FIRST check that you don't have some permissions rules in the chmod!!!
If you have 'chmod rw-r---- FILENAME' you will finish with -------- (0000) permissions!!!
You were warned!
mysite.production is a copy of the production dir somewhere else in the tree (your home for example).


$> find mysite.production/ ! -type l -ls | awk '{print "chmod "$3" "$11 " && chown "$5":"$6" "$11}' | sed -e 's/\.production//g' -e 's/-r--r--r--/044/' -e 's/-rw-rw-rw/0666/' -e 's/-rwxrwxrwx/0777/' -e 's/-rwx------/0700/' -e 's/-rwxr-xr-x/0755/' -e 's/-rwxr-x---/0750/' -e 's/-rw-r--r--/0644/' -e 's/-r-x------/0500/' -e 's/drwxr-xr-x/755/' -e 's/drwxrwxrwx/777/' > chm.sh
$>sh chm.sh


and try to compare some files that have specific perms.

that's all.
I'm SURE there is an easier way, and I'll be glad to share!!!

Xen + Desktop (3d) or what video card is ok if you want to use your quad desktop for xen machine

Short story:
If you have a machine that you want to have XEN+3D use ATI with radeonhd driver (check wich cards are supported).
Take a look here before try more than basic configuration of the driver: http://wiki.debian.org/XStrikeForce/HowToRandR12.

Long story:
For more than 5 months I've had a machine at home that was always off.
But not until tonight. :-)
It is a Core 2 Quad @ 2.5 GHZ with 4 gigs ram - a killer for desktop, very descent for server.
You'll almost never need that kind of power (expect you are a mad scientist doing some kind of calculations or a crazy gamer - not me!).
You'll definitely don't need it if you only watch movies, play some stupid doom like games, browse, read pdfs and do all kind of daily stuff on it.
When I got it I told to myself that I'll never use it until I can both have it as my test deployment server and as my primary desktop (including a dual headed video with two monitors connected and using two different GNOMEs on each).

You'll tell to yourself: 'uh! easy stuff.' (at least that's what I thought)
Well here I am five months later, at last I was able to complete my setup.

I've started by installing Debian Lenny (current unstable - now stable) and started digging....
The easiest part was configuring the dual head card to use the two separate monitors and to have two totally separated GNOMEs running.
It took me about two days to figure out that. It turned out that it is impossible to do this with only two X servers.
That is because they can't get attached to the same hardware card (if you have two different hardware cards - no problems).
The trick was to start a X server with wide screen splited on the two monitors (so called Xinerama or dual-view-mode - you know when you can move a window from one monitor to another). Upon this server you get another two 'virtual servers' started each running a GDM.
I'll find the link describing this and put it here.

So far, so good - I've got the two separate X working perfectly and I was almost complete.
Last step was just to change the kernel with XEN enabled one and I'm done.
When I rebooted in the XEN kernel I was 'WOW---F**KING' ... the XEN kernel was not able to work with Nvidia proprietary drivers.
At that time the machine was with NVIDIA GForce 7600 card.
I dug few weeks just to find nothing new - there were two ways to use NVIDIA (drivers):

  • stop using XEN

  • patch your kernel and hope you get it running and hopefully you'll have no problems



I didn't wanted to change my vanilla debian kernel because this is going to be my test deployment server and it should be as close as it can to my production machines.
Until then NVIDIA is dropped from my favorite video cards list - sad but true, it was my leader and most recommended card to be used it with linux...
What can you think of after NVIDIA?
ATI of course!
I have one - Asus X1600 (ATI chipset: RV530 X1600).
I've plugged it in. At that time I knew that only proprietary drivers were available for newer ATI cards, otherwise you get VERY bad performance and no 3d. That's why I've installed fglrx driver simply to find out that they also can't work with XEN.
DAMN.
The situation seemed hopeless. What other card can you use? (matrox? they've reports to have troubles with xen too!) and have descent 3d in linux? (please If you are aware of any card, post into the comments!)
I've left the project for few months but from few days while talking with a friend of mine, I've started looking for alternative of NVIDIA and ATI.

Tonight I was very surprised when I saw someone mentioned radeonhd driver. I've never heard of it. I've started digging and in about an hour I've got my ATI running with radeonhd driver and showing about 1500 FPS in glxgearx (WOW!!!) with XEN ENABLED KERNEL!
What was my suprise to see this. My problem was solved!
Just lost another hour to figure out how to start my two monitors split ed out in two with one on the left of the other... Xinerama won't work with this driver.
To fix things as you want use xrandr command ( from irc.freenode.org #radeonhd hint)
You can read more here: http://wiki.debian.org/XStrikeForce/HowToRandR12
Be careful with the device names.
These commands did the job for me:

xrandr --output DVI-I_1/digital --off
xrandr --output DVI-I_1/digital --mode 1680x1050 --rate 75
xrandr --output VGA_1 --left-of DVI-I_1/digital

Now I'm happy opensource driver user with most debian vanilla system I can imagine. :-)