Showing posts with label recovery. Show all posts
Showing posts with label recovery. Show all posts

Monday, June 25, 2012

Installing Windows after Ubuntu while dual-booting

    If you ever want to install windows on your system and dual boot with your current ubuntu installation, you don't have to get rid of your current installation. You can do it without re-installing ubuntu all-over again. 

Note : You need to have a working internet connection for the same or you need to have following five files correspong to your system architecture ( amd64 or i386 ) to proceed.
a) grub2-common_1.99-12ubuntu5_<architecture>.deb
b) grub-gfxpayload-lists_0.5_<architecture>.deb
c) grub-pc-bin_1.99-12ubuntu5_<architecture>.deb
d) grub-common_1.99-12ubuntu5_<architecture>.deb
e) grub-pc_1.99-12ubuntu5_<architecture>.deb
     You can download these from :

If your system satisfy the above condition then just do as in the following steps :

1) Back-up whatever you want to preserve. ( for worst-case scenario )

2) Have a Ubuntu CD / DVD / bootable USB disk with you. You will need it later on.

3) Create a partition for your windows installation from your ubuntu installation ( if you don't have one ) . The partion need-not to be formated as NTFS for now as you can do the same while installing windows. Just make a unformatted partition or simply create a blank free space (partition ) . You can do it via Gparted partition editor. If you don't have it installed , you can have it by entering following command in the terminal :
                       sudo apt-get update && sudo apt-get install gparted

4) Install Windows on the new partition.Remember not to touch the partition(s) containing your ubuntu installation or swap area.

5) At this point of time you won't be able to see or use your current ubuntu installtion as the system will straight boot into the new Windows installation.

6) Boot from your Ubuntu CD / DVD / bootable USB disk .

7) Open the terminal and enter the following command :

 i) sudo mkdir /mnt/temp ( creates a temporary directory for mounting your ubuntu partition )
ii) sudo mount /dev/sda2 /mnt/temp ( here /dev/sda2 is the partition where your ubuntu installation lies )
iii) Also mount some miscellaneous file-systems for proper working of chroot command : 
        for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt/temp$i; done
iv) Now chroot into your ubuntu Installation :
                                  sudo chroot /mnt/temp
v) If the above commands run successfully, the terminal prompt should include "root" ( root@ubuntu:/# ), which indicates you are in the chroot environment.
vi) Confirm you have working net connection in the chroot environment ( for downloading the grub installation files if you have not already downloaded it ) :
                               ping archive.ubuntu.com
vii) Update your package list : This step is optional if you have already downloaded the grub files.
                                sudo apt-get update
viii) Purging the Grub Loader : Do not proceed to next command if you don't have a working internet connection or you do not have access to downloaded grub files . The next command will remove grub, grub-pc (Grub 2) and grub-common. If you are sure you have never had Grub legacy on the current installation you may omit "grub" from the next command.
                             apt-get purge grub grub-pc grub-common
Here is what you will have to do:
  • Press ENTER to continue.
  • Read the warning during the install about removing the bootloader. TAB to highlight "<Yes>" and press ENTER.
viii) Re-install the grub packages : 
                   Command :
                           apt-get install grub-common grub-pc
Here is what will happen:
  • You will be given the opportunity to add extra kernel options to the kernel line. If you don't know, you probably don't need them ; TAB to highlight "<OK>" and press ENTER.
  • Read the installation notes. TAB to "<OK>" to continue.
  • When presented with the device option, use the Up/Down keys to select the correct drive ( /dev/sdX ).
  • Make sure the installation drive [*] /dev/sdX has an asterisk next to it ( example: [*] /dev/sda ). 
  • If it doesn't, highlight it and press the SPACE bar to select it. Do not select a partition ( example: [ ] /dev/sda5 , etc). 
  • TAB to "<OK>" and press ENTER. When it has finishing the installation, you should have Grub 2 installed.
ix) Update the Grub Loader files
                     update-grub
x)- Exit the chroot environment
                       exit
If you have successfully exited chroot, the terminal prompt should return to the Ubuntu Live CD prompt ( ubuntu@ubuntu:~$ ).

8) Reboot your system and you will be presented a grub based boot-menu containing the choice of operating systems ( including Windows ) you want to boot.There it goes ....

Have a happy Ubuntu Experience...

Wednesday, October 5, 2011

Recovery of a deleted partition


                      My this post is coming after a gap of almost a week. Actually, almost for all the week I was busy in correcting my Hard-disk partions which I , by mistake, messed up.
                      It all began with me trying to boot from the mini iso of ubuntu. I was unable to find a way to make it boot from pen-drive. Even Ubuntu's Startup disk creator was also not able to help me. So, I decided to go with dd command , which makes an exact copy of almost any-thing. I was very wrong in thinking this and this is where all problem started. In stead of typing
 
                     dd if=mini.so of=/dev/sdc  ( where sdc was my pen-drive partition )
 
i did
 
                  sudo dd if=mini.iso of=/dev/sda  ( sda was my hard-disk )

                  The blunder mistake has been done. When I restarted my netbook to boot from the pen-drive, it simply refused even to recognise any bootable disk. I knew, I was screwed and I have corrupted my HD's partition table.

                  Before I proceed to tell you that how I recovered almost everything, I will present you with an idea of my Dell Netbook ( Inspiron Mini 10 ). My system is a dual-boot with Windows Xp SP3 Home Edition on the very first partition of 30GB ( a primary partition) and Ubuntu 11.04 Natty Narhwal on one logical partion of 50 GB inside the extended partition of 200 GB. My system configuration is 1GB RAM , 1.67 Ghz Intel Atom processor, 250GB HD and no internal CD/DVD drive but three USB ports.

The recovery process :

                 I plugged in my external transcend CD/DVD drive and tried to boot from an old Lucid Lynx ( Ubuntu 10.04 LTS ) CD. It worked but was unable to find any partition in my harddisk . I even tried
 
           sudo fdisk -l

                 It also said unable to find any reconizable partition table. My next step was to look for solution in ubuntu forum ( www.ubuntuforums.org ) , luckily I found a post similar to my problem and the corresponding link for a damn good program ( or software ) named testdisk.

Links



                   I also found a very good step-by-step process explaining the working of testdisk on the testdisk website 

                   So, I downloaded the latest available tarball (testdisk-6.12.linux26.tar.bz2 ) from the testdisk website ( http://www.cgsecurity.org/wiki/TestDisk ) and transferred it to my external hard-disk , so that I can re-use it when I have to reboot ( I was on a live disk ). In addition I made the bootable usb disk via the Startup disk creator as the performance of a lve disk from usb will any how be better than that of a CD. Next step was to launch the testdisk program from the external HD.

sudo testdisk_static ( sudo is neccesary to discover all the disk / partitions )

Screenshots :

1) The first screen will ask for log-file creation : Select create by using arrow keys on the key-board and press enter.


2) The second screen will show your disks /media available. Select your hard-disk and press enter.



3) The next screen will present you with a choice of selecting partion table type . Select Intel for normal ubuntu / windows installations.



4) The next screen will ask you for operations on the disk. Select analyse and press enter.



5) The next screen will show the current partition table structure. As you can see here, in my case it doesn't show up any thing. So, just press enter for quick search for the partitions.




6) The next screen will ask for a permission that it will scan for partition made under Windows Vista. Type Y and it will start scanning / analysing your system for lost partitions as per the below screen-shot. The process took around 15-20 minutes for my 250 GB hard-disk.


7) In The next screen it present a list of partions available for recovery. Even this list also doesn't contained my 1st partion ( containg Windows Xp Home Edition ). So, I went for a deep search option which took another 60-90 minutes. 

                The next list contained a lot more partitions than my system actually had. But luckily , this list contained my all partitions as well. 

                It also presented an option of listing / viewing the files. The partitions for which no files were listed , I changed the status of partition to D ( deleted) . The status of the 1st partion ( containg my Xp files ) was changed to * ( bootable primary ) , and rest partion were logical partitions, so there status was changed to L ( logical ). If I had any more primary partitions , its status would have been P ( primary ). The status can be changed using left and right arrow keys of key-board. You can find a detailed explanation on test-disk wiki page ( http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step ) . Press enter to continue.

8) In the next screen it will show you a final list of partitions. Make sure that it is your actual list of partitions and select proceed to write the partition table according to your findings.

9) the next screen will ask you about the boot sector. Here it presented me with two boot sectors – one was present boot sector which was corrupted and a back-up boot sector which was label as OK . So, i selected the option to copy the back-up boot sector to the present boot sector. Next screen was to quit the program and reboot the system ( after unplugging the external media i.e. the CD/DVD drive , pen-drive, external HD ).

               So, I thought it is all done and i should be able to boot right into my system.

But.............................