Showing posts with label guide. Show all posts
Showing posts with label guide. Show all posts

Wednesday, October 16, 2013

Installing a new hard disk without reinstalling Ubuntu/Windows

I own a 7-year old Dell Inspiron 1420 laptop, which comes with a 160 GB hard drive. My optical drive stopped working a couple of years ago and I had been contemplating getting a secondary hard drive. The only thing that kept me from it was the whole process of reinstalling my dual boot configuration on it. While Ubuntu installation is not too difficult and is done pretty quickly, I really hate having to reinstall Windows. The OS installation alone takes up a lot of time, not to forget the time required for installing additional programs like a good web browser, PDF reader, a compression program, antivirus, an office suite and vlc/mplayer - these are perhaps the most basic necessities that are needed to make your Windows functional.

A couple of months back, I decided to finally get an additional drive 750 GB drive and a caddy to place it securely in place of my optical drive. Choosing a caddy is easy - you just need to take care of two things : the size of the optical drive (12.5 or 9 mm) and the interface (IDE/SATA) that it uses to connect the motherboard. This is the same interface which is used to connect your optical drive and can be checked when you take out your optical drive.

Cloning the hard disk

Important Note:  /dev/sda refers to the complete hard drive and includes all partitions. /dev/sda1 refers to a specific partition of the same hard drive.

My home folder is on the same partition as the Ubuntu install. So I just cloned the two partitions using the terminal. My Ubuntu and Windows partitions were on /dev/sda1 and /dev/sda2 respectively. A good way to make sure you have the correct partition is to use the GParted tool (included in the Live CD) or the fdisk -l command at the terminal.
user@pc: ~$ sudo fdisk -l
Then I connected my external drive and used the following commands:
user@pc: ~$ dd if=/dev/sda1 of=/media/EXTERNAL/Ubuntu.img bs=4096
user@pc: ~$ dd if=/dev/sda2 of=/media/EXTERNAL/Win7.img bs=4096
I used this method because it does not require installing additional programs. For more ways of cloning, this article on lifehacker is a good read.

In the meantime, I used unetbootin to create a Ubuntu bootable USB. When the backup was done, I simply shut down my computer and replaced my primary hard drive with the new spacious one I had bought. The next step was to boot into Ubuntu using the live USB I had just made and then partition the new drive. I made a partition system similar to my previous one -
1. ext4 (Ubuntu)
2. NTFS (Windows 7)
3. NTFS (storage of common data files like Dropbox/Firefox profile/Music/etc.)

Note that I do not use any separate swap partition on my computer.

Of course, I made sure that the new partitions were at least the same size or bigger than the previous ones to ensure that the image file can be written back on them. When the partitions were made and properly formatted, I restored the OS installations on my new drive using the following commands:
user@pc: ~$ dd if=/media/EXTERNAL/Ubuntu.img of=/dev/sdb1 bs=4096
user@pc: ~$ dd if=/media/EXTERNAL/Win7.img of=/dev/sdb2 bs=4096
Yes, the new hard drive was mounted as /dev/sdb in my case. But you should check using the fdisk -l command to make sure you are restoring the images on the correct drives/partitions. Now, we are almost done.

Reinstalling the bootloader

One thing to notice here is that I cloned individual partitions instead of the whole drive. While this would have been also possible, I did it this way because I did not have enough free space on my external disk. Which is why the next step becomes important. I have two OS installations on the new hard drive now but no bootloader. To make this computer recognize the OS installs, I installed grub2 on the drive in the following way (Source: HowToUbuntu):

1. While still in the live CD/USB environment, open a terminal and mount the partition your Ubuntu Installation is on. Again, it can be found out by using GParted or the fdisk command.
user@pc: ~$ sudo mount /dev/sdb1 /mnt  
2. Now bind the directories that grub needs access to to detect other operating systems, in the following fashion
user@pc: ~$ mount --bind /dev /mnt/dev && sudo mount --bind /dev/pts /mnt/dev/pts && sudo mount --bind /proc /mnt/proc && sudo mount --bind /sys /mnt/sys
3. Now we need to change the apparent root directory of the live environment to the one on the Ubuntu partition we just mounted
user@pc: ~$ sudo chroot /mnt
4. Now install, check, and update grub. Grub is installed on the whole drive and not a single partition, so use /dev/sdb instead of /dev/sdb1 for the following set of commands
user@pc: ~$ grub-install /dev/sdb
user@pc: ~$ grub-install --recheck /dev/sdb
user@pc: ~$ update-grub
5. Now the grub installation is complete. All that is left is to exit the chrooted system and unmount everything.
user@pc: ~$ exit && sudo umount /mnt/dev && sudo umount /mnt/dev/pts && sudo umount /mnt/proc && sudo umount /mnt/sys && sudo umount /mnt
6. Shut down and turn your computer back on, and you will be met with the default grub2 screen.

That's it! Now you should have a completely running system with the same configuration as you had before. I have not tried doing this with a significant change in the system configuration. Even with those changes, Ubuntu should port to the new system configuration just fine. The only problem that you could face is with Windows because sometimes its WGA kicks in if it detects a change in your hardware.

Sunday, March 24, 2013

Conky Configuration Guide


There have been tremendously detailed guides on configuring conky all over the internet. However, so much information can be confusing at times. And this universe of information can be especially intimidating for the people new to conky/linux. I felt the need to make a collection of useful and regularly updated resources to make the daunting task of configuring your conky a little easier.

From knowing nothing about conky, I have made use of some of these online resources to make my conky look like this:


Let's take it step-by-step.

1. Installation


The installation for various distros are well documented on the official conky webpage.

Debian/Ubuntu

At a terminal:
$ sudo apt-get install conky

Gentoo

Have no fear, Conky is in portage. You can install it with:
# emerge app-admin/conky
 
or, using Paludis:
# paludis -i app-admin/conky

Arch

Conky is available in pacman:
# pacman -S conky 

 FreeBSD

Conky is avaible in FreeBSD ports, check FreshPorts for details.

Foresight

For Foresight Linux or any other rPath-based distro:
# conary update conky=cookingwithroids.rpath.org@cwr:all

Compiling from source

You'll need the X11 development libraries, version 6.8.2 or later. package name is probably libx11-dev (on Debian/Ubuntu), as well as the development libraries for any additional features.

$ ./configure --prefix=/usr --enable-x11 --enable-mpd # see --help for a full listing of options

$ make 

# make install
The last step is optional, if you don't do this, the conky executable will be in src/.

2. Configuration


So you just installed a shiny new conky on your computer. But nothing seems to work. Why is that so? This is because conky needs a configuration file to tell it what to display. This is usually named as .conkyrc and it contains instructions about what information to display on your desktop and how. Understanding the configuration file may seem difficult at first but you get the hang of it in a couple of hours even if you have never done any programming before.

A good resource to tweak the configuration file according to your needs has been written by VinDSL on ubuntuforums. The link to the guide is:

VinDSL's Conky Configuration Guide


3. Additional Dependencies & Fonts


Most configurations make use of additional scripts/plugins/fonts. Examples of these include certain weather scripts, email checking scripts or scripts that fetch the current track information from your music player.

These scripts have to be downloaded separately, and their paths configured in the conky configuration files that make use of them. Sometimes, the scripts themselves need additional editing - but this is usually very simple and often involves just replacing certain fields like your email id & password or the link to your local weather conditions.

4. Weather


Okay, why do I need to mention weather separately? Because configuring this part may be trickier than others. It used to be easy before weather.com made drastic changes to their website. Most scripts made use of weather.com until almost an year back, when the website made it mandatory to register to fetch weather updates.

One of the best resources I have come across for this is by Teo. The complete thread is at the following link:

Teo's weather scripts using Accuweather/WUnderground/NWS/Weather.com

5. Additional Information/References


If you are already familiar with a little programming and do not wish to go through the lengthy guides mentioned above the Arch Linux Wiki on conky is a good place to start. It details a lot of things from fetching RSS feeds to configuring GMail in conky.

Arch Linux Wiki

Another useful and concise option is the conky variable list at the official webpage on sourceforge. This list is presented in the form of a table, with a short description of how each command works. A little familiarity with conky may be required before you jump to this one.

Conky variables list on Sourceforge

Happy Conky-ing!