Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, June 28, 2008

Intel Graphics and Ubuntu : Warning! Do NOT mix

So I had a little time my hands at office. We use 32-bit Windows XP for development,but the boxes are all 64-bit dual cores. So naturally I got the crazy idea in my head to install and run my programs (J2EE based) on 64-bit Linux (Kubuntu 8.04 - [KDE not KDE4] in this case).

Now I consider myself a fairly advanced Linux user, so the amount of difficulty I had in doing this was quite frankly, shocking. Lets go over what all happened:
  1. I didn't want to partition my drive so I installed Wubi. I don't really like Gnome, so I went in for Kubuntu. Wubi detected I had a 64-bit processor and started downloading the right ISO. So far so good!
  2. The system reboots in Linux and ... crashes. Time to boot in safe graphics mode
  3. Linux installs but my monitor resolution is all wrong. Checked the graphics card drivers and found the installer had permanently put my system in safe graphics mode... Reset graphics configuration to activate the normal driver
  4. Seems to work fine, KDE works, install compiz, works, restart... Damn! The screens gone blank, none of the keys work Restart... Again stuck. Restart in repair mode, uninstall compiz, the problem seems to be in starting KDE
  5. Decided to switch to Ubuntu from Kubuntu... Simple enough: just call sudo apt-get install ubtuntu-desktop
  6. OK! Gnome ... Sux .... Install KDE4 (sudo apt-get install kde4), remove the horrible new launcher, replace with old one, play around with the icons a bit and... Damn! The panel has disappeared
  7. Whew... After that fix, I am back... to square one... KDE4 Sux
  8. Restart (I don't even remember why... or maybe logged out) and... Damn! Its BSOD (BLACK Screen of Death) again
  9. Getting pissed... Check Google - oh wow! there's a bug (in Xorg - Ubuntu's Graphics Subsystem's - Intel 965 implementation). This is mirrored in Ubuntu. Ok... Get the latest experimental Xorg from here, uninstall the old version (sudo apt-get remove xserver-xorg-video-intel xserver-xorg-video-i810) and install the new one (sudo dpkg -i xserver-xorg-video-intel_2.3.1-1ubuntu1~bwh3_amd64.deb)
  10. Wow! Now Xorg works ONCE per restart - I can work fine if I log into the system, but if I log out, system hang... Sux... But still... manageable
  11. Ok now to work... Eclipse... check... Pidgin (2.4.2 to fix an annoying bug with sharing profiles with Windows XP)... check... JDK... Yikes comes with JDK6...
  12. OK... sudo apt-get install jdk5 ... Fail! ... Damn! ... search packages for JDK5 ... Fail!
  13. Now what? packages.ubuntu.com -> libraries -> hardy. Ok got it: ia32-sun-java5-bin for JDK5 32-bit and sun-java5-bin for autodetect (in my case, 64-bit). Now that I know the name, apt-get will work.
  14. Yippee! Everything works! Now I can run my stuff, (that btw, runs flawlessly from the start - WORA in action!) play around a bit... Damn! I logged out... Sux
  15. Back to Windows... I have had enough for a few weeks
Its amazing how difficult it is to get Linux set up... Ubuntu is tons better that anything else, but still miles off... Why is it that I can go on the net, download one version of a exe and it will blindly work on Windows, but if I try to do the SAME thing on the linux side, I have to worry about 10s of things - kernel versions, distributions, this and that... JDK 5 for Windows I can get off Sun's website. For Ubuntu? Good Luck. And considering the number of bugs in Xorg integration with Intel video cards, I almost feel Micro$oft is paying Intel to make this happen!

By the way, Wine is amazing. I got most of my favorite Windows utilites (Editplus, Baretail) working with Linux, which made me feel right at home. I even got IE working, Windows Media Player wouldn't work for some reason though and I didn't have the heart to debug more installation issues. This meant Launchcast wouldn't work either, though an enterprising person has come up with a perl based solution :) I still couldnt listen to my personal station though... just the pre-existing ones, but without ads...

Oh wait... I forgot... One last catastrophe... See Wubi creates a single file in the Windows NTFS filesystem for Linux. In the middle of all the crashes, this folder got corrupted and Scandisk ended up moving all the files out... I had a lot of fun moving everything back to the right location from File0001.chk! No data loss though...

Overall, looks like I wont be shifting full time to Linux for development anytime soon. Exchange integration is still not perfect, though Evolution has come a long way. On the flip side, once set up, Ubuntu actually works faster and stabler in 64-bit than Windows in 32-bit (besides the aforementioned Intel issues) JBoss and any J2EE or even Java programs run without any issues. And Compiz Fusion is truly fantastic of course. Its just that getting the base system setup was so annoying that I got really frustrated... Its just my luck to have to deal with Intel issues...

Well, in truth I might switch, if IS tries to force McAfee AV down my throat again :) ... And if I have to work in 64-bit for some reason, Linux is pretty much the only reasonable option...

Sunday, April 6, 2008

DVD/CD/Hard Drive Mirroring and Data Recovery using Linux (Kubuntu/Ubuntu)

So one of the Y-Cables in my computer failed. This caused (I think) random voltages to pass into my hard disk, which too started failing. Soon I found myself minus a hard disk and a lot of data. I had another hard disk of the exact same model, so I decided to use a Kubuntu/Ubuntu live disk to restore my failing hard disk to the other one.

My first attempt was to use dd.

dd if =/dev/hdX of=/dev/hdY

Now this would work but only because both hard disks were the exact same model. If they weren't I would have had to create a hard disk image and then copy data from that manually... not very useful. Unfortunately, the above doesn't work - dd stops at the first error. So a little research on the net showed the way:

dd bs=4k if=/dev/hdX of=/dev/hdY conv=noerror,sync

to mirror, or for an image

dd bs=4k if=/dev/hdX of=/path/to/image conv=noerror,sync

What do each of these options do? bs=4k makes dd copy in blocks of 4KB to ensure that it doesnt miss any good sectors, noerror means dont stop for errors, and sync means in case of an error output empty bytes so that the output image is not corrupted.

This unfortunately has a problem: bs=4k is miniscule. Telling dd to work like this will take days to recover data. Ideally we need something that moves extremely fast over a hard disk, scanning and copying good sectors with a large block size and then going back to reattempt the erroneous sectors with a smaller block size. There used to be a convoluted way to do this, using a program called dd_rescue and a batch file called dd_rhelp. However, this is not very efficient - the use of a batch file by definition slows things down. So the guys at GNU have come up with a very efficient program which does this automatically, called (guess?) ddrescue.

First you need to install ddrescue to your Live CD.

sudo apt-get install gddrescue

Note you need the gddrescue package not ddrescue. If you are unable to access the internet from your Live CD, you can download gddrescue*.deb (for your version of (K)Ubuntu) from here, copy it to a flash drive and then install it inside of the Live CD using

sudo dpkg -i gddrescue_1.2-1_i386.deb

There's a lot of advanced stuff you can do with ddrescue (see the man page, or the information here, here and here) However, in most normal use cases, you can jest get the data out using this command:

ddrescue /dev/hdX /dev/hdY /path/to/save/recovery.log

or, for an image

ddrescue /dev/hdX /path/to/image /path/to/save/recovery.log

The third option is non-compulsory. What it does is read and save a recovery log, so that if you have to shut down your machine or it crashes in the middle or recovery (recovery can take a LONG time for hard disks), ddrescue can resume seamlessly from where it left off (aint it cool)

Once you have the data out, if you mirrored your hard disk, you can just start using the new hard disk as normal (first making it a master etc). If you made an image, you can get the data from it out using

mkdir imagemout
sudo mount -o loop /path/to/image imagemount

For CD/DVDs, the output of dd/ddrescue is an ISO, which can be read or burned using any standard tool. Note that for DVD/CDs all the above applies, just for dd you have to use bs=2k not bs=4k

Of course, none of the above was useful for me... just putting in a new Y-Cable stopped any errors from showing up... I actually tossed a hard disk into the trash can, realized it wasnt the hard disk which was faulty and pulled it out. (And now it is running my Windows XP)