msgbartop
Tips, notes, HOWTOs
msgbarbottom

17 Feb 10 Dealing With Recursiveless Grep

If you work at all in Solaris (and maybe just older versions I don’t know) you will eventually find out that the version of “grep” shipped with the OS is missing the “-r” option for doing recursive greps.  Over the years I have found myself becoming a huge fan of this ability and I am always amazed to find there are versions that don’t include it.  Today I set out to come up with a way to emulate the behavior.

I came up with two solutions.  First we have:

find . |xargs grep PATTERN

While this seemed to work fine at first I noticed that it had issues with file that contained spaces. It would treat each “word” of a file name with spaces as a separate filename and I would get errors from grep about not being able to find the file. If you know that you don’t have any filenames with spaces though the above should work just fine.

As I played around further I managed to come up with the following second iteration:

find . -exec grep PATTERN {} /dev/null \;

This one worked just as well as the first one but had the added advantage of treating file names with spaces in the correctly. I don’t claim to be a find master. Unfortunately I can’t tell you why the “/dev/null” is required except that I can tell you without it you will get the lines in files matching the pattern returned but not the filename the line is contained in.

Tags: , , ,

18 Nov 09 Move LVM2 VG From Old Drive To A Drive On A New Machine

My old computer recently died.  It was old enough that I didn’t spend a lot of time trying to fix it.  I took the opportunity to get a new one.  I have my drives set up so that my “home” partitions are in an LVM volume group.  I wanted to move that VG to the new drive on the new machine.  This is what worked well for me.

Assuming you have the old drive connected to the new machine the simplest way seemed to be adding the physical volume on the new disk to the VG on the old disk then moving all of the extents that exist in the VG on the old disk to the new.  Finally I removed the old disk from the VG.

Here are the steps I took, I will explain each after the code.

vgchange -ay
pvcreate /dev/sda5
vgextend MyVG /dev/sda5
vgmove -v /dev/sdb3 /dev/sda5
vgreduce MyVG /dev/sdb3

1: That started up the MyVG volume group on the old HDD.  Although it’s not shown above I mounted it and looked around to make sure the files were there and everything looked good.

2: I allocated the partition on the physical disk in the new machine (sda5 for me) to LVM.

3: Here I added the LVM physical volume (pv) created above to the MyVG volume group that up to this point resided only on the old HDD.  So now instead of a 100G “disk” only on the 1 HDD I now had a 360G “disk” that actually spanned 2 physical disks.

4: This moved all of the physical extents of MyVG that resided on the old HDD (sdb3 for me) to physical extents on the new HDD.  -v just gave me a 15 second rolling counter of the progress.  It took about 25 minutes to move 100G or so.

5: This removed the old HDD from the MyVG.  Everything is now on the same volume group it has always been on but that VG now resides fully on the new HDD now.

In case you are wondering why I didn’t just keep the old HDD I moved from a desktop machine to a laptop.

Tags: , , , , , , , , ,

25 Jan 09 Magic Keys

Just wanted to save this off finally.  Not that having it here will help me if I am locked up but…

If you enabled Magic SysRq (CONFIG_MAGIC_SYSRQ=y, found in make menuconfig at Kernel hacking -> Magic SysRq key) in your kernel you can cleanly reboot if evil freezes your system with the following keyboard combination:
Alt-SysRq-R (keyboard in raw mode)
Alt-SysRq-S (save unsaved data to disk)
Alt-SysRq-E (send termination signal)
Alt-SysRq-I (send kill signal)
Alt-SysRq-U (remount all mounted file systems)
Alt-SysRq-B (reboots the system)

More info at WP including some nice mnemonic’s for helping to remember.

Tags: , ,

16 Dec 08 Extend LVM2 Logical Volume

I found myself recently having to add some space to one of my LVM partitions.  It’s fairly simple.  First extend the partition size with lvextend:

lvextend -L+1G /dev/myvg/homevol

Then, because I use ReiserFS I do:

resize_reiserfs -f /dev/myvg/homevol

If you use a different underlying filesystem refer to this page from the LVM HOWTO.

Tags: , , ,

07 Dec 08 Use Refractor (Prism) Firefox Addon In Ubuntu

You can get Refractor (Prism addon) to work in Ubuntu (and probably other unices) with one added step to the install process.

After installation you need to right click the icon and choose Properties.

Original Properties

Original Properties

In the Command box change “firefox”, for me it was “/usr/lib/firefox-3.0.4/firefox”, to xulrunner.

New Properties

New Properties

Tags: , , , , , ,

SEO Powered by Platinum SEO from Techblissonline