Expand Linux partitions to overwrite old Windows partitions
Q I'm new to Linux, and I have decided to completely wipe Windows XP from my laptop and just have Linux. I am dual-booting XP and Ubuntu; could you please tell me how to remove Windows and just have Ubuntu? How would I expand the Linux partitions to take over the space where Windows XP used to be? As I am a bit of a newbie, would it be easier just to totally format the drive and reinstall Linux?
A To answer your last question first, reinstalling Ubuntu from scratch and taking the option to use the whole disk would indeed be an easy way to do this, but you'd lose your existing setup and data. Removing the Windows partition and allocating the space to Linux would leave your existing Ubuntu setup intact, and you'd learn more about how Linux works in the process. Removing Windows is easy. The first step is to delete the Windows partition (usually hda1) using the Gnome Partition Editor available from the System > Administration menu. If this isn't available, you should install GParted from the Synaptic package manager. The Windows partition is usually easy to identify, because the filesystem is NTFS (or possibly FAT), and Linux doesn't use these filesystems. Next click on the unallocated space this leaves and press the New button to create a new Linux partition of type ext3 (the default settings should be correct for this). Now, with the new partition still highlighted, go to the menus and select Partition > Format To > Ext3 (see screenshot, right). Press Apply to make these changes. The next step is to remove the Windows entry from the boot menu. Open a terminal and type
sudo -i gedit /boot/grub/menu.lst
to load the boot menu into an editor. Towards the end of the file you'll find a line starting 'title Windows' Delete from this line down to the next blank line and save the file. Your boot menu is now Windows-free. Adding the space you've just freed up is somewhat less straightforward. Linux partitions can only be resized by moving the end position, yet the space you've freed up lies before the beginning of the Linux partitions, because the Windows partition was the first on the disk. Fortunately, Linux allows you to use multiple partitions - in this case we can use the space previously taken by Windows as your home directory (an advantage of this approach is that if you reinstall or switch to a different distro, you can keep your personal files because they're on their own partition). You tell the system to use this partition for home by adding a line to the file /etc/fstab (filesystem table). In the terminal you've just used, type
Add the following line and save the file:
/dev/hda1 /home ext3 defaults 0 0
Before you reboot, which will activate the new home partition, you need to copy your existing files across. Still in the terminal, type
mkdir /mnt/tmp mount /dev/hda /mnt/tmp mv /home/* /mnt/tmp/ reboot
This mounts the new partition somewhere temporary, moves your home directory over to it and reboots the computer to make the changes permanent. After this, there will be no sign of Windows at the boot menu, and when Ubuntu comes up, the space previously used by Windows will be available for storing your own files.
- Removing Linux and restoring Windows partitions
- Removing hidden Windows partitions
- Can NTFS partitions be defragmented on Linux?
- Dual-booting Linux and Windows
- Safely transfer data between partitions