Accidentally made a Vista partition into a swap partition

Q I was messing about with trying to create a swap partition on an old flash mp3 player, and I accidentally made a swap file on my Vista partition. I have not switched the swap file on, and used the mkswap command to make the swap file. My Vista still works, although I have to boot in through the recovery partition, so I am guessing it has only affected the start of the drive. Is there any way to reverse the mkswap command to enable me to fix the Vista partition? I have checked in GParted, and it reports the drive as a swap drive. Fdisk shows the partition as NTFS, which it should be, but there's no * under the boot heading. Does that mean that if I can restore the Vista boot info to the disk, it should work?

A If Vista still works, the partition must be OK. It looks like you have changed the partition type setting, probably to Linux Swap, and cleared the boot flag. This means that Windows cannot recognise the partition and that the bootloader does not think it can boot from here. Use whatever partition editor you prefer to set the partition type to NTFS (07) and set the bootable flag for it. I find cfdisk easy for this, and it is on just about every live CD I have ever tried. Boot from a live disc, open a root terminal and run cfdisk with:

cfdisk /dev/hda

When you've done this, select the partition, press t to set the type and choose NTFS from the list of alternatives, then press b to make it bootable. Finally press W (that is a capital W) to write the changes to the disk. You can also do this with a graphical editor like gparted or qtparted, but I find cfdisk faster for this. You don't even need to wait for a desktop to load if your favourite live disc already has an option to boot straight to a shell prompt (Knoppix users, for instance, can type knoppix 2 at the boot prompt).

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar