Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I used to have a dual boot in one of my hard disk drives - Ubuntu and Windows 7. Then, I added a SSD which is now my main hard disk drive, and I'm using it for Windows 7 completely, keeping Ubuntu in the old HD. I restored the Grub so everything works ok, except for one thing.

Everytime I update the grub, it detects two windows:

Found Windows 7 (loader) on /dev/sda1
Found Windows 7 (loader) on /dev/sdb1

Obviously, I don't want it to detect the Windows on sdb1. Because I no longer use it (I manually deleted the files). What can I do about that without wiping out completely the partition?

share|improve this question
    
How did you delete all the files? Not from Windows, I assume, since it wouldn't allow you to do that while it's running. Can you just reformat the partition, which will clear the directory completely? GRUB is probably detecting the Windows boot files. –  Marty Fried Jun 17 '12 at 19:35
    
I deleted them from linux. Using ls -la, no hidden or boot files appear, which is pretty weird. –  José Tomás Tocino Jun 17 '12 at 19:48
    
I added an answer because it was too long for a comment. It's not complete, but will work if nobody comes up with anything better. –  Marty Fried Jun 17 '12 at 20:46

3 Answers 3

up vote 2 down vote accepted

I'm not sure what it uses to detect the OS. I'd try a quick reformat of the partitions.

If nothing else works, here is a patch that can be made to /etc/grub.d/30_os-prober that will allow you to specify any partitions you want to skip:

/etc/grub.d/30_os-prober modification

These lines can be added to the file (just past the middle) to skip any partitions that you don't want to show up in the menu. Leaving the string empty will skip nothing.

Add the lines starting with

############## Patch to prevent some partitions being autodetected

through

############## End of patch:

for OS in ${OSPROBED} ; do
  DEVICE="`echo ${OS} | cut -d ':' -f 1`"
  LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
  LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
  BOOT="`echo ${OS} | cut -d ':' -f 4`"

  ############## Patch to prevent some partitions being autodetected
  SKIP_THESE_DEVICES="sdb1"
  # SKIP_THESE_DEVICES="sda1 sdb1 sdb2"   example for multiple devices
  # SKIP_THESE_DEVICES=""                 example for no devices

  PARTITIONNAME="`echo ${DEVICE} | cut -c 6- 2> /dev/null`"
  if [ "`echo ${SKIP_THESE_DEVICES} | grep -e ${PARTITIONNAME} 2> /dev/null`" ] ; then
    continue
  fi
  ############## End of patch

  if [ -z "${LONGNAME}" ] ; then
    LONGNAME="${LABEL}"
  fi

After changing this file, you will, of course, need to run sudo update-grub to regenerate the menu. You should be able to see the results from the terminal's output when it says "Found ..." for each entry; you can run it first before the mods, then compare the output to after the mods. You should not see the removed entries.

share|improve this answer

You should use a Gparted live cd to delete your windows partition on the old HD. But you may have to fix grub after you do this.

share|improve this answer

If Windows 7 is still getting detected, it means that the parition you made still contains some bootloader files of Windows 7. Why not delete the partition itself? That will definitely solve this issue.

I suggest that you keep a backup of any files you want, and delete the partition of your Windows 7 in your old HD. After that update the grub.

I don't think I need to suggest tools to you, but Gparted is the best partition editor from what I know.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.