Archive for the ‘howto’ Category

Create Arbitrary Sized Sparse Files under Windows and Linux

Thursday, September 25th, 2008

Apparently there is something to be said about short blog posts. Allegedly I tend to get long winded sometimes and my posts can run a tad verbose sometimes. I usually tell people to STFU and go read Steve Yegge if they want to see verbose. I’m short, concise and to the point compared to him. But I figured that I’ll try some of that short blog post thing that people seem to be enjoying in other parts of the web. So I’m making a post about a silly little windows command. This is so that I don’t forget it about it next time I need it.

Have you ever needed a file of specific size to test something but you didn’t care what that file was? You know, just a space holder or a space filler kind of a thing? This is what you need to do to create one on Windows XP:

fsutil file createnew file.ext 10000

Naturally file.ext is the desired name of the file you want to create, and the numeric argument is the desired size in bytes. Note that fsutil creates a sparse file which means that this operation will be blindingly fast. For example it took about 3 seconds to create a 10GB file on my elderly windows machine.

Useful trick. I sometimes use it to see how a given app will act when it encounters a file of certain size. To accomplish the same thing in linux you apparently need to do something like:

dd if=/dev/zero of=my-file bs=1 count=0 seek=10G

I messed around with it, and the bs and count are important so don’t just skip them. The seek attribute specifies the desired size of your file, and here you can use human readable units (like 10Gb in the example).

So if you ever need a file of a specific size to test something, here is how you make one. How is that for a short post? What do you mean 350 words is not short? Ah, go to hell then. I tried. Next post will be verbose again. ;)

Using CPAN version of WWW::Mechanize with ActiveState Perl on Windows

Monday, February 25th, 2008

I end up doing this each time I reinstall windows, and every time I forget how I did it, so I figured I’ll archive the process here. Perhaps it will help some of you. And I know, someone will say why don’t you use the PPM repository. Let’s just say i don’t want to. I want to grab the latest WWW::Mechanize package from CPAN and run with it.

Why am I posting it now? Because I needed to reinstall windows once again on my desktop, and now I need to get my blackboard scrips to work again.

This is really a multi step process. I’ll assume you have perl installed already. If not, you can get Activestate Perl which works pretty well on windows. Just grab the MSI package, install it and all the useful tools including perl, cpan and ppm will land in your path. From there follow these 3 easy steps:

Step 1: Get nmake

You will need nmake – the windows version of the make utility to compile most of the CPAN packages. How do you get nmake? There are several ways to do it, but probably easiest one is to grab the Microsoft version of the tool from their knowledge base. Once you download it, dump it somewhere in your path. It doesn’t really matter where it is, but I stuck it in the bin directory of my Perl install.

Step 2: Get YAML from CPAN

You will need YAML to build WWW::Mechanize. What is YAML? Sort answer is: do you care? Long answer: look it up. All you need to know is that you need it. So run cpan from your console and type in:

install YAML

This should cause some streaming text on the screen as the package is fetched and compiled. If it fails, make sure nmake is in your path, and that it is named nmake.exe and not something else.

Step 3: Install WWW::Mechanize

Final step is the easy one – just fetch and install the WWW::Mechanize package using the traditional method:

install WWW::Mechanize

Make sure you do step 1 and 2 before you try this. If you have tried this before you installed YAML the build will fail for some reason. To avoid that, just quit cpan, and run it again. This will clear the local cache and will re-fetch the package for a clean build.

So, there you have it. I know it’s a bit of a dry and uninteresting post for Monday morning. But this is more of a reminder to myself than anything else. I never remember where to grab nmake or what is that other package without which nothing ever builds on windows. Hopefully some of you will find it helpful. :)

Gutsy on Dell Latitude D830

Friday, February 1st, 2008

I got my brand new Dell Latitude D830 laptop today, and the first thing I did with it was installing Gutsy. Dell was nice enough to partition the drive for me so I didn’t have to bother with resizing. This is possibly like the single most useful service they offer in their store. Installation went very smoothly, but configuring the laptop was a bit more rocky than my recent test with Inspiron 600m

New Dell Latitude D830 On my Desk

I’m pleased to report that my Intel PRO/Wireless 3945ABG card worked out of the box without any tweaking. It is listed in the Restricted Drivers section but there was nothing I had to do to enable it. It just popped into action and that was that. I’m very happy about this. As far as I could tell everything else except for the sound card worked. Yes Aplhast, my sound card doesn’t work! I’m blaming you! You jinksed it buddy! ;P

Lshw tells me that I have an Intel 82801H (ICH8 Family) HD Audio Controller. In Ubuntu circles ICH8 is an acronym for “fucking pain in the ass”. It just doesn’t work without major tweaking. Patching and recompiling ALSA might be required. And even then it is not guaranteed that it will work at all.

But there is no way in hell I’m willing to accept “doesn’t work” without at least trying. After some googling I found two possible solutions. First one was very simple – simply add the following line to /etc/modprobe.d/alsa-base:

options snd-hda-intel probe_mask=1 model=3stack

I did just that, rebooted and found out that this doesn’t work. Of course! Why would it. Things can’t be this easy, can they? I left the line in it’s place just in case and moved to the next suggestion which was equally easy. Just install one small package and reboot.

sudo aptitude install linux-backports-modules-generic

I rebooted and heard a faint chime of KDE startup sound. It was a little bit quiet so I mashed the Volume Up button above the keyboard. Gutsy actually knew about this button, and displayed a nice overlay volume bar on my screen. I maxed out the sound, fired up Amarok and played the welcome message. It wasn’t as loud as the sounds in Windows, but for my purposes it was perfectly adequate. So yes, sound is working. All is well!

Just about everything else worked including Bluetooth. Ot at least I think it works because the LDE lights up, and KDE has a nice icon in the taskbar which tells me the MAC adress of my card. Unfortunately I do not have any bluetooth toys that I could test it with. Any suggestions for a bluetooth appliance for this laptop?

The Nvidia Quadro NVS 140M card was red in the restricted driver panel signifying that the proprietary drivers were not installed but are available. Since everything looked fine I decided to leave it be for now. I could always go back and install the driver later. So I messed around with it some more, and then decided to plop it in the place of my regular laptop.

As soon as I connected the laptop to my external monitor and hit Fn+F8 (which is the CRT/LCD switch) everything went to hell. I got incredibly colorful, psychedelic, blinking patterns on both screens and that was it. Killing the X server did nothing – this weird display corruption had to be happening at a lower level. Only thing I could do was to pull the monitor plug and REISUB.

So I figured this was the time to install the nvidia driver. So I went to K-menu, System Settings, Advanced, Restricted Drivers and installed it without ever dropping down to CLI. Neat! Naturally I needed to reboot for the new driver to go into action. Unfortunately I immediately realized that Nvidia decided to take away my Fn+F8 function. I was able to flip back and forward between LCD and CRT during the framebuffer loading screen, but as soon as X started the picture would jump back to the laptop LCD and stay there.

It took me few minutes to figure out the magical spell I needed here:

nvidia-settings

It pops up a very nice config dialog you can use to set up he multi-display stuff:

NVidia Dialog

Once I did that, everything started working just fine. Now I’m running on a beautiful 1280×1024 resolution and enjoying how incredibly fast this hardware seems compared to my old 700 Mhz junker. It is a great machine!

If you are planning to buy a machine for Linux though I would probably recommend the Dell Ubuntu line – this way you avoid the fun I had here with the sound card. And that machine comes with an integrated webcam (kinda like Apple does) which is kinda awesome. I got this one because it was supposed to be a dual boot machine and I kinda needed it to have an XP license attached to it. I’d recommend it but only if you are not afraid of getting your hands dirty messing around with the sound card. You know what… I take that back – it’s just one package and one line in alsa-base file (I don’t know which one did it, and I don’t care at thisp point) – I did the research for you so it should be easy. :mrgreen: