Wednesday, February 2, 2011

How to restore the Ubuntu/XP/Vista/7 bootloader (Updated for Ubuntu 10.10)

This How-to is for windows dual booters who reinstall an operating system only to find that it has taken away access to their other operating system.
Whether you want to restore the XP, Vista, 7 or Ubuntu (Grub) bootloader, this guide will walk you through it.

All three parts of this tutorial require that you boot from a cd. If you don't know how to do this, check here.

If you have made a mistake and want to revert the changes, simply follow the instructions for reinstalling the previous bootloader. For example, if you have installed vista over ubuntu, try to get the ubuntu bootloader back, but want to get the vista bootloader back, simply follow my instructions for installing the vista bootloader.


How to restore the Ubuntu grub bootloader (9.10 and beyond)

First you need to find out what your drives are called. You can do this by going to a terminal and typing:
Code:
sudo fdisk -l
You will get something like this:




From that you need to find the device name of your Ubuntu drive, something like “/dev/sda5″.
So, still in the terminal, type:
Code:
sudo mkdir /media/sda5
sudo mount /dev/sda5 /media/sda5
And then, to reinstall the grub:
Code:
sudo grub-install --root-directory=/media/sda5 /dev/sda
Push enter and you’re done! Of course you need to replace “/dev/sda5″ and “/dev/sda” with what you found in the fdisk output.

How to restore the Ubuntu grub bootloader (9.04 and older)

First of all, all credit for this part of the tutorial goes to catlet. I am simply rewriting his tutorial to have all three bootloaders in this tutorial.

So, lets begin. To restore the grub, you must boot off the ubuntu live cd. Any ubuntu live cd will do.

Once there, open a terminal (Applications>Accessories>Terminal) and type this:

Code:
sudo grub
Next, you need to find which hard drive ubuntu and the grub is installed to. You do this by running this command:

Code:
find /boot/grub/stage1
Take note of what it returns (something like (hd0,1).)

Now you need to tell Grub where it is installed. Using the output of the last command, change this one and run it:

Code:
root (hd<a>,<b>)
Replacing <a> and <b> with what you got back before. For example, if "find /boot/grub/stage1" gave me "(hd0,1)", you would run "root (hd0,1)"

Ok, so thats the configuration over and done with. Now we just need to run one command to install the Grub to your hard drive:

Code:
setup (hd0)
Now to quit and check if it has worked:

Code:
quit
Code:
sudo reboot
Make sure you have taken the live cd out of your disc tray. All going well, you should start back up and see the grub once again.


How to restore the Windows XP bootloader

For this you will need your Windows XP installation CD. Boot into it now.

You will get to a part where it asks if you want to repair or recover. To do so, press "r".

If prompted, enter your Windows XP administrator password. This will leave you at at a command line, so type in the following two commands:

Code:
fixboot
Code:
fixmbr
Then type
Code:
exit
then remove your XP cd. If everything has gone well, you should come to your XP bootloader.


How to restore the Windows Vista or 7 bootloader

To restore the Windows Vista/7 bootloader, you must first boot off your Windows Vista/7 installation DVD.
If you have one of the many OEM computers that didnt come with a Vista/7 installation disk, you can get the same effect with a Vista recovery disk, which you can download for Vista or Win 7.
When you get to the Regional settings, select your Location/Keyboard setting then click next. On the next page you must click on "Repair your computer."

On the next page, if it finds your Windows Vista/7 installation, make sure it is UNSELECTED before clicking next.
Then click on "Command prompt". From there, type in the folowing:

Code:
bootrec.exe /fixboot
Code:
bootrec.exe /fixmbr
Now close the two windows and click "Restart."

Take out your Vista/7 DVD and hopefully, you will be left with your Windows Vista/7 Bootloader.

Setup CUPS - Print Server on Ubuntu

CUPS - Print Server

The primary mechanism for Ubuntu printing and print services is the Common UNIX Printing System (CUPS). This printing system is a freely available, portable printing layer which has become the new standard for printing in most Linux distributions.
CUPS manages print jobs and queues and provides network printing using the standard Internet Printing Protocol (IPP), while offering support for a very large range of printers, from dot-matrix to laser and many in between. CUPS also supports PostScript Printer Description (PPD) and auto-detection of network printers, and features a simple web-based configuration and administration tool.

Installation

To install CUPS on your Ubuntu computer, simply use sudo with the apt-get command and give the packages to install as the first parameter. A complete CUPS install has many package dependencies, but they may all be specified on the same command line. Enter the following at a terminal prompt to install CUPS:

sudo apt-get install cups

Upon authenticating with your user password, the packages should be downloaded and installed without error. Upon the conclusion of installation, the CUPS server will be started automatically.
For troubleshooting purposes, you can access CUPS server errors via the error log file at: /var/log/cups/error_log. If the error log does not show enough information to troubleshoot any problems you encounter, the verbosity of the CUPS log can be increased by changing the LogLevel directive in the configuration file (discussed below) to "debug" or even "debug2", which logs everything, from the default of "info". If you make this change, remember to change it back once you've solved your problem, to prevent the log file from becoming overly large.

Configuration

The Common UNIX Printing System server's behavior is configured through the directives contained in the file /etc/cups/cupsd.conf. The CUPS configuration file follows the same syntax as the primary configuration file for the Apache HTTP server, so users familiar with editing Apache's configuration file should feel at ease when editing the CUPS configuration file. Some examples of settings you may wish to change initially will be presented here.
[Tip]
Prior to editing the configuration file, you should make a copy of the original file and protect it from writing, so you will have the original settings as a reference, and to reuse as necessary.
Copy the /etc/cups/cupsd.conf file and protect it from writing with the following commands, issued at a terminal prompt:

sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.original
sudo chmod a-w /etc/cups/cupsd.conf.original

  • ServerAdmin: To configure the email address of the designated administrator of the CUPS server, simply edit the /etc/cups/cupsd.conf configuration file with your preferred text editor, and add or modify the ServerAdmin line accordingly. For example, if you are the Administrator for the CUPS server, and your e-mail address is 'bjoy@somebigco.com', then you would modify the ServerAdmin line to appear as such:

    ServerAdmin bjoy@somebigco.com

  • Listen: By default on Ubuntu, the CUPS server installation listens only on the loopback interface at IP address 127.0.0.1. In order to instruct the CUPS server to listen on an actual network adapter's IP address, you must specify either a hostname, the IP address, or optionally, an IP address/port pairing via the addition of a Listen directive. For example, if your CUPS server resides on a local network at the IP address 192.168.10.250 and you'd like to make it accessible to the other systems on this subnetwork, you would edit the /etc/cups/cupsd.conf and add a Listen directive, as such:

    Listen 127.0.0.1:631           # existing loopback Listen
    Listen /var/run/cups/cups.sock # existing socket Listen
    Listen 192.168.10.250:631      # Listen on the LAN interface, Port 631 (IPP)

    In the example above, you may comment out or remove the reference to the Loopback address (127.0.0.1) if you do not wish cupsd to listen on that interface, but would rather have it only listen on the Ethernet interfaces of the Local Area Network (LAN). To enable listening for all network interfaces for which a certain hostname is bound, including the Loopback, you could create a Listen entry for the hostname socrates as such:

    Listen socrates:631  # Listen on all interfaces for the hostname 'socrates'

    or by omitting the Listen directive and using Port instead, as in:

    Port 631  # Listen on port 631 on all interfaces

For more examples of configuration directives in the CUPS server configuration file, view the associated system manual page by entering the following command at a terminal prompt:

man cupsd.conf

[Note]
Whenever you make changes to the /etc/cups/cupsd.conf configuration file, you'll need to restart the CUPS server by typing the following command at a terminal prompt:

sudo /etc/init.d/cups restart

Web Interface

[Tip]
CUPS can be configured and monitored using a web interface, which by default is available at http://localhost:631/admin. The web interface can be used to perform all printer management tasks.
In order to perform administrative tasks via the web interface, you must either have the root account enabled on your server, or authenticate as a user in the lpadmin group. For security reasons, CUPS won't authenticate a user that doesn't have a password.
To add a user to the lpadmin group, run at the terminal prompt:
sudo usermod -aG lpadmin username

Further documentation is available in the Documentation/Help tab of the web interface.

Setup Network File System (NFS) on Ubuntu

Network File System (NFS)

NFS allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files.
Some of the most notable benefits that NFS can provide are:
  • Local workstations use less disk space because commonly used data can be stored on a single machine and still remain accessible to others over the network.
  • There is no need for users to have separate home directories on every network machine. Home directories could be set up on the NFS server and made available throughout the network.
  • Storage devices such as floppy disks, CDROM drives, and USB Thumb drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.

Installation

At a terminal prompt enter the following command to install the NFS Server:

sudo apt-get install nfs-kernel-server

Configuration

You can configure the directories to be exported by adding them to the /etc/exports file. For example:

/ubuntu  *(ro,sync,no_root_squash)
/home    *(rw,sync,no_root_squash)

You can replace * with one of the hostname formats. Make the hostname declaration as specific as possible so unwanted systems cannot access the NFS mount.
To start the NFS server, you can run the following command at a terminal prompt:

sudo /etc/init.d/nfs-kernel-server start

NFS Client Configuration

Use the mount command to mount a shared NFS directory from another machine, by typing a command line similar to the following at a terminal prompt:

sudo mount example.hostname.com:/ubuntu /local/ubuntu

[Warning]
The mount point directory /local/ubuntu must exist. There should be no files or subdirectories in the /local/ubuntu directory.
An alternate way to mount an NFS share from another machine is to add a line to the /etc/fstab file. The line must state the hostname of the NFS server, the directory on the server being exported, and the directory on the local machine where the NFS share is to be mounted.
The general syntax for the line in /etc/fstab file is as follows:

example.hostname.com:/ubuntu /local/ubuntu nfs rsize=8192,wsize=8192,timeo=14,intr

If you have trouble mounting an NFS share, make sure the nfs-common package is installed on your client. To install nfs-common enter the following command at the terminal prompt:
sudo apt-get install nfs-common

Setup FTP server in Ubuntu 10.04

FTP Server

File Transfer Protocol (FTP) is a TCP protocol for uploading and downloading files between computers. FTP works on a client/server model. The server component is called an FTP daemon. It continuously listens for FTP requests from remote clients. When a request is received, it manages the login and sets up the connection. For the duration of the session it executes any of commands sent by the FTP client.
Access to an FTP server can be managed in two ways:
  • Anonymous
  • Authenticated
In the Anonymous mode, remote clients can access the FTP server by using the default user account called "anonymous" or "ftp" and sending an email address as the password. In the Authenticated mode a user must have an account and a password. User access to the FTP server directories and files is dependent on the permissions defined for the account used at login. As a general rule, the FTP daemon will hide the root directory of the FTP server and change it to the FTP Home directory. This hides the rest of the file system from remote sessions.

vsftpd - FTP Server Installation

vsftpd is an FTP daemon available in Ubuntu. It is easy to install, set up, and maintain. To install vsftpd you can run the following command:
sudo apt-get install vsftpd

Anonymous FTP Configuration

By default vsftpd is configured to only allow anonymous download. During installation a ftp user is created with a home directory of /home/ftp. This is the default FTP directory.
If you wish to change this location, to /srv/ftp for example, simply create a directory in another location and change the ftp user's home directory:
sudo mkdir /srv/ftp
sudo usermod -d /srv/ftp ftp 
After making the change restart vsftpd:
sudo /etc/init.d/vsftpd restart
Finally, copy any files and directories you would like to make available through anonymous FTP to /srv/ftp.

User Authenticated FTP Configuration

To configure vsftpd to authenticate system users and allow them to upload files edit /etc/vsftpd.conf:
local_enable=YES
write_enable=YES
Now restart vsftpd:
sudo /etc/init.d/vsftpd restart
Now when system users login to FTP they will start in their home directories where they can download, upload, create directories, etc.
Similarly, by default, the anonymous users are not allowed to upload files to FTP server. To change this setting, you should uncomment the following line, and restart vsftpd:
anon_upload_enable=YES


Enabling anonymous FTP upload can be an extreme security risk. It is best to not enable anonymous upload on servers accessed directly from the Internet.
The configuration file consists of many configuration parameters. The information about each parameter is available in the configuration file. Alternatively, you can refer to the man page, man 5 vsftpd.conf for details of each parameter.

Securing FTP

There are options in /etc/vsftpd.conf to help make vsftpd more secure. For example users can be limited to their home directories by uncommenting:
chroot_local_user=YES
You can also limit a specific list of users to just their home directories:
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
After uncommenting the above options, create a /etc/vsftpd.chroot_list containing a list of users one per line. Then restart vsftpd:
sudo /etc/init.d/vsftpd restart
Also, the /etc/ftpusers file is a list of users that are disallowed FTP access. The default list includes root, daemon, nobody, etc. To disable FTP access for additional users simply add them to the list.
FTP can also be encrypted using FTPS. Different from SFTP, FTPS is FTP over Secure Socket Layer (SSL). SFTP is a FTP like session over an encrypted SSH connection. A major difference is that users of SFTP need to have a shell account on the system, instead of a nologin shell. Providing all users with a shell may not be ideal for some environments, such as a shared web host.
To configure FTPS, edit /etc/vsftpd.conf and at the bottom add:
ssl_enable=Yes
Also, notice the certificate and key related options:
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
By default these options are set the certificate and key provided by the ssl-cert package. In a production environment these should be replaced with a certificate and key generated for the specific host. For more information on certificates see the section called “Certificates”.
Now restart vsftpd, and non-anonymous users will be forced to use FTPS:
sudo /etc/init.d/vsftpd restart
To allow users with a shell of /usr/sbin/nologin access to FTP, but have no shell access, edit /etc/shells adding the nologin shell:
# /etc/shells: valid login shells
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/screen
/usr/sbin/nologin
This is necessary because, by default vsftpd uses PAM for authentication, and the /etc/pam.d/vsftpd configuration file contains:
auth    required        pam_shells.so
The shells PAM module restricts access to shells listed in the /etc/shells file.
Most popular FTP clients can be configured connect using FTPS. The lftp command line FTP client has the ability to use FTPS as well.

Straight Through Cable Wiring


Straight Through Cable Wiring

RJ-45 Pin #Color (both sides identical)
Pin 1White with Orange
Pin 2Orange
Pin 3White with Green
Pin 4Blue
Pin 5White with Blue
Pin 6Green
Pin 7White with Brown
Pin 8Brown

Cross Over Cable Wiring

RJ-45 Pin #1 Side Color2 Side Color
Pin 1White with OrangeWhite with Green
Pin 2OrangeGreen
Pin 3White with GreenWhite with Orange
Pin 4BlueBlue
Pin 5White with BlueWhite with Blue
Pin 6GreenOrange
Pin 7White with BrownWhite with Brown
Pin 8BrownBrown







Windows Dual Boot



Introduction

This page describes how to set up your computer in order to dual boot Ubuntu and Windows.

Back Up Your Data

Although this may seem obvious, it is important to backup your data files to an external backup medium before attempting a dual-boot install (or any other hard drive manipulation), in case your hard drive becomes corrupted during the process. External hard drives, USB flash drives, and multiple DVDs or CDs are useful as external backup media.

Have a Windows recovery CD/DVD available

Many computer manufacturers that pre-install Windows provide a Windows recovery/re-installation CD or DVD with the computer. However, many companies no longer ship a physical disk but instead create a hidden partition on the hard drive in which the recovery-disk information is stored. A utility is then usually provided which allows the user to burn a recovery/re-installation CD or DVD from it. If you are buying a new computer and intent on dual-booting, make sure you have (or can make) a physical Windows recovery/re-installation CD or DVD. If neither a CD/DVD nor a recovery partition/burning utility is provided by your computer manufacturer, you may need to telephone your vendor and ask for a CD or DVD (to which you are normally entitled under the Windows EULA).
It is very important to have such a physical recovery/re-installation CD/DVD prior to changing your hard drive, in case your hard drive becomes corrupted in the process (and the recovery partition thereby becomes unavailable for use).
Once you have created a physical backup disk from a restore-image partition on the hard-drive, the restore-image partition can either be removed or left in place. Ubuntu can be installed with it intact without problems.

Getting Recovery Media

You may need to request a physical recovery/re-installation CD or DVD directly from your computer manufacturer. Here are some resources:
Alternatively, if you own a licensed copy of Windows Vista or Windows 7, you may download a system recovery CD that may be used to access a recovery console free of charge from NeoSmart Technologies. This CD can't be used to reinstall Windows in case things go majorly wrong, but it does contain the needed tools to set boot-related issues right.

Install Ubuntu after Windows

In general, a Windows OS should be installed first, because its bootloader is very particular and because Windows installers tend to overwrite the entire hard drive (potentially wiping out any other data stored on it). If Windows isn't already installed, install it first. If you are able to partition the drive prior to installing Windows, leave space for Ubuntu during the initial partitioning process. Then you won't have to resize your NTFS partition to make room for Ubuntu later (saving a bit of time).
When a Windows installation already occupies the entire hard drive, its partition needs to be shrunk, creating free space for the Ubuntu partition. See How to Resize Windows Partitions to learn how to do this.
This can be done through Control Panel -> Administrative tools -> Computer Management -> Disk Management. You can then use the partition manager to shrink the partitions. As a side note, you can only create free space to the right of a partition.
If you have resized the windows 7 /vista partitions and cannot boot up windows, you can use the instructions fromWindowsRecovery to fix it. Once free space has been created on the hard drive, it is easy to install Ubuntu as the second operating system (and it is done automatically) from the Ubuntu LiveCD. Allow the Ubuntu LiveCD to install to "largest available free space" (if you have left unallocated free space), or manually into a partition that you have already created for Ubuntu.

Install Ubuntu

  • Download an Ubuntu LiveCD image (.iso) from Ubuntu Downloads and burn an Ubuntu LiveCD (see BurningIsoHowto).
  • Insert the LiveCD into your CD-ROM drive and reboot your PC.
  • If the computer does not boot from the CD (eg. Windows starts again instead), check your BIOS settings and adjust them so that booting from the CD is allowed.
  • Proceed with installation until you are asked this question: "How do you want to partition the disk ?".

Resizing Partitions Using the Ubuntu Installer

Automatic partition resizing

  • Choose the First Option (It should be something like: "Resize IDE1 master, partition #1 (hda1) and use freed space").
  • Specify the size of the new partition as a percentage of your entire hard disk.
  • Click on "Forward".

Manual partitioning

  • Choose "Manually edit partition table"
  • Listed will be your current partitions
  • Select the partition you want to resize and press Enter.
  • Select "Size:", press Enter.
  • Select Yes, press Enter.
  • Type in a new size in Gigabytes for your partition, it's recommended you free up AT LEAST 10 GB of free space for your Ubuntu install. Press Enter when happy with your changes. It may take some time to apply the changes.
  • Create a swap partition of at least your amount of RAM (if you don't know, 2000 MB is a good value).
  • Create a partition for your Ubuntu installation, at least 10 GB.
  • Select "Finish partitioning and write changes to disk".

Master Boot Record and Boot Manager

GNU/GRUB2 is the boot manager installed in Ubuntu by default. If you use the Alternate CD you can choose Lilo instead. GRUB2, GRUB and Lilo are good Open Source boot managers so the main parts of the boot loaders are installed inside Ubuntu. This means Ubuntu is independent and avoids any need for writing to other operating systems. To accomplish this, the only thing in your computer outside of Ubuntu that needs to be changed is a small code in the MBR (Master Boot Record) of the first hard disk. The MBR code is changed to point to the boot loader in Ubuntu. You will be presented with a list of operating systems and you can choose one to boot. If you do nothing Ubuntu will boot after a ten second countdown. If you select Windows then GRUB or Lilo will chain-load Windows for you at the Windows boot sector, which is the first sector of the Windows partition.
If you have a problem with changing the MBR code, you might prefer to just install the code for pointing to GRUB to the first sector of your Ubuntu partition instead. If you do that during the Ubuntu installation process, then Ubuntu won't boot until you configure some other boot manager to point to Ubuntu's boot sector. Windows Vista no longer utilizes boot.ini, ntdetect.com, and ntldr when booting. Instead, Vista stores all data for its new boot manager in a boot folder. Windows Vista ships with an command line utility called bcdedit.exe, which requires administrator credentials to use. You may want to read http://go.microsoft.com/fwlink/?LinkId=112156 about it.
Using a command line utility always has its learning curve, so a more productive and better job can be done with a free utility called EasyBCD, developed and mastered in during the times of Vista Beta already. EasyBCD is user friendly and many Vista users highly recommend EasyBCD.

Installing Windows After Ubuntu

Normally when Windows is installed after Ubuntu the "Master Boot Record", MBR, will be overwritten. You can bootup off a LiveCDand repair the MBR. However, there are 2 different approaches:

Recovering GRUB after reinstalling Windows

There are also these help guides
Which should help with any install of Ubuntu now. For some simple cases the advice below might help

Ubuntu 10.04 or 9.10

Sorry, definitely use this guide

Ubuntu 9.10 & earlier

The older Grub, sometimes called Grub-legacy or perhaps Grub1 was used up until Ubuntu 9.10. The default for 9.10 was initially Grub1 but installs would drift over to Grub2 without users really being aware of the change. With any current Ubuntu install it is wise to install, or re-install Grub2 as shown in the link above.
If you run an older Ubuntu or had any trouble with Grub2 then Grub1 & Lilo are still available. To fix the MBR with an older LiveCDto access a Grub command-line:
  1. Boot into a LiveCD
  2. Open a terminal
  3. Open the GRUB Command-line utility by typing
sudo grub
  1. Find where Grub is. If this gives a few different answers then you will need to find the correct one, perhaps by trial-and-error.
find /boot/grub/stage1
  1. Tell GRUB which partition to tell the MBR your Grub is on by entering
root (hdA,B)
The coordinates A,B are where 'A' is the hard-drive number, starting at 0, and 'B' is the partition number, starting at 0. For example, if Ubuntu was installed on the second partition of the first hard-drive, the command should be
root (hd0,1)
  1. Tell GRUB which drive's MBR to fix
setup (hd0)
Replace 0 only in the extremely unlikely event that your bios does not use the first hard-drive as the boot device. Typically Ubuntu might be on any drive but the bios will almost always go to the first drive's MBR to find out where to find the boot-loader.
  1. Leave the GRUB Command line
quit
and reboot.

Master Boot Record backup and re-replacement

Back-up the existing MBR, install Windows, replace your backup overwriting the Windows boot code:
  1. Create an NTFS partition for windows (using fdisk, GPartEd or whatever tool you are familiar with)
  2. Backup the MBR e.g. dd if=/dev/sda of=/mbr.bin bs=446 count=1
  3. Install windows
  4. Boot into a LiveCD
  5. Mount your root partition in the LiveCD
  6. Restore the MBR e.g. dd if=/media/sda/mbr.bin of=/dev/sda bs=446 count=1
  7. Restart and Ubuntu will boot
  8. Setup grub to boot windows

Issues with Windows XP and NTFS

The Ubuntu installer has included support for resizing NTFS partitions since Ubuntu 5.10 (Breezy Badger) was released way back in 2005. Very few problems have been reported relative to the huge number of times that the installer has been used. If you tried the above procedure and have had no luck, it might be that there is a pre-existing problem either in the file system, in the partition table or the hard disk.
First you should try running CHKDSK before trying again to resize the partition, and if you are using the Alternate CD, defragging might help. It is recommended that you run CHKDSK once again after resizing your NTFS partition.
Also, try the following alternative methods:

Using QtParted from the System Rescue CD

  1. Boot into Windows and backup any valuable documents/photos etc onto removable media such as CD-R/DVD-R.
  2. Run the Windows disk check tool (Error-checking) on C: a couple of times (the results can be seen in the Administrative Tools > Event Viewer > Application under a "Winlogon" entry).
  3. Run the Windows defragmentation tool on C:
  4. Download the System Rescue CD ISO image (100 MB; has several very useful software tools).
  5. Burn the ISO image to a CD.
  6. Boot from the CD and hit Enter when you see the message "Boot:".
  7. When you get a command prompt, enter:
run_qtparted
  1. Select your disk on the graphical screen (most likely /dev/hda).
  2. Select your NTFS partition to be resized (most likely /dev/hda1).
  3. Right click with the mouse and choose Resize.
  4. Set the new partition size.
  5. Commit your changes in the File -> Commit menu. If your keyboard and mouse stop responding during resizing then please just be patient.
  6. Once your changes are saved, remove the System Rescue CD and insert your Ubuntu installation CD.
  7. Reboot and install Ubuntu into the free space.

Using GParted from UNetbootin-PartedMagic

Another approach to resizing partitions, which does not require a CD, is to load PartedMagic from Windows via the UNetbootin PartedMagic Loader:
  1. Download and install the Windows (.exe) file, then reboot.
  2. Select the UNetbootin-partedmagic entry after rebooting, and wait as PartedMagic boots up.
  3. Start the partition manager by clicking the GParted icon on the the panel.
  4. Select your disk (probably /dev/sda) via the drop-down menu on the top-right corner of the interface.
  5. Right-click the NTFS partition to be resized (probably /dev/sda1), and select the "resize" option.
  6. Drag the slider to specify the new size the NTFS partition should be resized to, then press OK.
  7. Press the "Apply" button to resize the disk, then reboot once done.
  8. Upon the next Windows boot, click OK when prompted to remove UNetbootin-partedmagic to remove its boot menu entry.

Reinstall Ubuntu Grub Bootloader After Windows Crash


If you run a dual-boot system with Linux and Windows, this has happened to you. You had to do your monthly reinstall of Windows, and now you don’t see the linux bootloader anymore, so you can’t boot into Ubuntu or whatever flavor of linux you prefer.
Here’s the quick and easy way to re-enable Grub.
1) Boot off the LiveCD
2) Open a Terminal and type in the following commands, noting that the first command will put you into the grub “prompt”, and the next 3 commands will be executed there. Also note that hd0,0 implies the first hard drive and the first partition on that drive, which is where you probably installed grub to during installation. If not, then adjust accordingly.
sudo grub
> root (hd0,0)
> setup (hd0)
> exit
Reboot (removing the livecd), and your boot menu should be back.

Only read below if Windows is now missing from the boot menu
If you installed Ubuntu before you installed Windows, then Ubuntu will not have anything in the grub configuration for Windows. This is where you’ll have to do a bit of manual editing to the grub boot menu file.
If you open the file /boot/grub/menu.lst with the following command:
sudo gedit /boot/grub/menu.lst
You’ll see a sample section for Windows, which you’ll want to uncomment and add to the boot menu list in whatever position you want it in. (uncomment by removing the #’s)
# title   Windows 95/98/NT/2000
# root   (hd0,0)
# makeactive
# chainloader   +1
Note that you should also verify that hd0,0 is the correct location for Windows. If you had installed Windows on the 4th partition on the drive, then you should change it to (hd0,3)

Thanks for Ubuntu forums all data it's taken from the forum and official server manual