Years ago i installed ubuntu on a hard drive in my computer. A few days ago, after the release of 18.04, i bought a ssd and reinstalled everything on that. The old hdd is still linked in the computer - just to look up things.

GRUB does index the old hdd as secondary boot option. But i will never ever boot the old system again. So is there any way to remove the old hard drive from the grub options?

  • I had this happening once; I think I commented out the line in a grub script that runs os-prober, but I don't have that pc any more to check. – Organic Marble May 31 '18 at 11:17
  • @karel Thanks, i'll definitely check that tool. Do you know, if it just removes the references of the OS or does it actually deletes files? Of course, i would like to keep all the other files on the hard drive. – chris.ribal May 31 '18 at 11:47
  • OS-Uninstaller supports removing only selected OS boot list entries in the GRUB. – karel May 31 '18 at 12:11
  • Reopen voters Duplicate is about deleting a partition. OP wants to keep partition but doesn't want it to appear in Grub menu. As such I don't think this is a duplicate question. – WinEunuuchs2Unix Jun 1 '18 at 1:44
  • I agree with @WinEunuuchs2Unix. This question has nothing to do, directly, with the other partitions. It's about editing the grub menu. The question being closed, gives the impression that you have to remove the partition to remove the menu entry. The one answer isn't the best either. You don't have to disable the prober to OS_Prober to edit the boot menu. If the question is reopened it could get very good answers (or at least, links to other questions concerning editing the grub menu) which would be more helpful... and posibly a different reason for closing the question. – L. D. James Jun 1 '18 at 3:45

Short Answer

If you don't want third party utilities you can do it with a move command:

sudo mv /mnt/extra_distro/boot /mnt/extra_distro/boot.old

Then sudo update-grub of course.

Long Answer

Grub's OS_Prober checks each mounted drive for presence of /boot/* entries of vmlinuz* and initrd.img*. Then adds those options to your booted instance of grub. On my system for example:

$ sudo mount-menu.sh
Mount Partition

      ┌───────────┤ Use arrow, page, home & end keys. Tab toggle option ├────────────┐
      │ NAME        FSTYPE  LABEL                    SIZE MOUNTPOINT                 │ 
      │                                                                              │ 
      │ sda                                        931.5G                           ↑│ 
      │ ├─sda4      ntfs    WINRETOOLS               450M                           ▒│ 
      │ ├─sda2                                       128M                           ▒│ 
      │ ├─sda5      ntfs    Image                   11.4G                           ▒│ 
      │ ├─sda3      ntfs    HGST_Win10               919G /mnt/d                    ▒│ 
      │ └─sda1      vfat    ESP                      500M                           ▒│ 
      │ nvme0n1                                      477G                           ▒│ 
      │ ├─nvme0n1p5 ntfs                             858M                           ▒│ 
      │ ├─nvme0n1p3                                   16M                           ▒│ 
      │ ├─nvme0n1p1 ntfs                             450M                           ▒│ 
      │ ├─nvme0n1p8 ntfs    Shared_WSL+Linux           9G /mnt/e                    ▒│ 
      │ ├─nvme0n1p6 ext4    Ubuntu18.04             23.7G                           ▮│ 
      │ ├─nvme0n1p4 ntfs    NVMe_Win10             390.4G /mnt/c                    ▒│ 
      │ ├─nvme0n1p2 vfat                              99M /boot/efi                 ▒│ 
      │ ├─nvme0n1p9 swap    Linux Swap               7.9G [SWAP]                    ▒│ 
      │ └─nvme0n1p7 ext4    NVMe_Ubuntu_16.0        44.6G /                         ↓│ 
      │                                                                              │ 
      │                                                                              │ 
      │                     <Select unmounted partition> <Exit>                      │ 
      │                                                                              │ 

I will mount the Ubuntu 18.04 partition:

Mount Device:  /dev/nvme0n1p6
Mount Name:    /mnt/mount-menu.BkLzA
File System:   ext4
ID:            Ubuntu
RELEASE:       18.04
CODENAME:      bionic
DESCRIPTION:   Ubuntu 18.04 LTS
 Size  Used Avail Use%
  24G   18G  4.7G  79%

Now update grub and look at the menu:

$ sudo update-grub
$ grub-menu.sh
Grub Version: 2.02~beta2-36ubuntu3.18

        ┌─────────┤ Use arrow, page, home & end keys. Tab toggle option ├──────────┐
        │ Menu No. --------------- Menu Name ---------------                         
        │1>41 Ubuntu, with Linux 4.4.0-127-generic (recovery mode)                 ↑ 
        │1>42 Ubuntu, with Linux 3.16.53-031653-generic                            ▒ 
        │1>43 Ubuntu, with Linux 3.16.53-031653-generic (upstart)                  ▒ 
        │1>44 Ubuntu, with Linux 3.16.53-031653-generic (recovery mode)            ▒ 
        │1>44 Ubuntu, with Linux 3.16.53-031653-generic (recovery mode)            ▒ 
        │2    Windows Boot Manager (on /dev/nvme0n1p2)                             ▒ 
        │3    Ubuntu 18.04 LTS (18.04) (on /dev/nvme0n1p6)                         ▒ 
        │4    Advanced options for Ubuntu 18.04 LTS (18.04) (on /dev/nvme0n1p6)    ▒ 
        │4>0  Ubuntu (on /dev/nvme0n1p6)                                           ▒ 
        │4>1  Ubuntu, with Linux 4.15.0-22-generic (on /dev/nvme0n1p6)             ▮ 
        │4>2  Ubuntu, with Linux 4.15.0-22-generic (recovery mode) (on /dev/nvme0  ▒ 
        │4>3  Ubuntu, with Linux 4.15.0-20-generic (on /dev/nvme0n1p6)             ▒ 
        │4>4  Ubuntu, with Linux 4.15.0-20-generic (recovery mode) (on /dev/nvme0  ▒ 
        │4>5  Ubuntu, with Linux 4.14.34-041434-generic (on /dev/nvme0n1p6)        ▒ 
        │4>6  Ubuntu, with Linux 4.14.34-041434-generic (recovery mode) (on /dev/  ▒ 
        │4>7  Ubuntu, with Linux 4.14.31-041431-generic (on /dev/nvme0n1p6)        ↓ 
        │                   <Display Grub Boot>        <Exit>                        
        │                                                                          │ 

Notice the grub options:

  • 2 Windows Boot Manager (on /dev/nvme0n1p2)
  • 3 Ubuntu 18.04 LTS (18.04) (on /dev/nvme0n1p6)
  • 4 Advanced options for Ubuntu 18.04 LTS (18.04) (on /dev/nvme0n1p6)

option 2 we want to keep, options 3 and 4 we want gone.

So on my system use:

$ sudo mv /mnt/mount-menu.BkLzA/boot /mnt/mount-menu.BkLzA/boot.old
$ sudo update-grub
$ grub-menu.sh
Grub Version: 2.02~beta2-36ubuntu3.18

        ┌─────────┤ Use arrow, page, home & end keys. Tab toggle option ├──────────┐
        │ Menu No. --------------- Menu Name ---------------                       │ 
        │                                                                          │ 
        │     1>33 Ubuntu, with Linux 4.13.0-43-generic                       ↑    │ 
        │     1>34 Ubuntu, with Linux 4.13.0-43-generic (upstart)             ▒    │ 
        │     1>35 Ubuntu, with Linux 4.13.0-43-generic (recovery mode)       ▒    │ 
        │     1>36 Ubuntu, with Linux 4.9.77-040977-generic                   ▒    │ 
        │     1>37 Ubuntu, with Linux 4.9.77-040977-generic (upstart)         ▒    │ 
        │     1>38 Ubuntu, with Linux 4.9.77-040977-generic (recovery mode)   ▒    │ 
        │     1>39 Ubuntu, with Linux 4.4.0-127-generic                       ▒    │ 
        │     1>40 Ubuntu, with Linux 4.4.0-127-generic (upstart)             ▒    │ 
        │     1>41 Ubuntu, with Linux 4.4.0-127-generic (recovery mode)       ▒    │ 
        │     1>42 Ubuntu, with Linux 3.16.53-031653-generic                  ▒    │ 
        │     1>43 Ubuntu, with Linux 3.16.53-031653-generic (upstart)        ▒    │ 
        │     1>44 Ubuntu, with Linux 3.16.53-031653-generic (recovery mode)  ▒    │ 
        │     1>44 Ubuntu, with Linux 3.16.53-031653-generic (recovery mode)  ▒    │ 
        │     2    Windows Boot Manager (on /dev/nvme0n1p2)                   ▒    │ 
        │     3    Windows Boot Manager (on /dev/sda1)                        ▮    │ 
        │     4    System setup                                               ↓    │ 
        │                                                                          │ 
        │                                                                          │ 
        │                   <Display Grub Boot>        <Exit>                      │ 
        │                                                                          │ 

VOILA Extra unwanted distribution no longer appears. Note, I had read once that simply renaming /mnt/extra_distro/grub/grub.cfg file would solve the issue but testing this just now didn't seem to work.

| improve this answer | |
  • This is exactly what i needed! Keep the files intact, but prevent the drive from being indexed by grub. Thanks! – chris.ribal Jun 5 '18 at 23:03
  • Not seeing grub-menu and update-grub on my Ubuntu 18.04 so I assume these are available only when entering grub config rather than after booting Ubuntu itself – matanster Mar 30 at 15:47
  • 1
    @matt Try using locate update-grub it should appear. As far as grub-menu.sh goes that is a script I wrote: askubuntu.com/questions/599208/… – WinEunuuchs2Unix Mar 30 at 22:40

I found my notes on this.

Edit /etc/default/grub and add the line


Exit, saving changes, then run

sudo update-grub

From the grub wiki (item 16)

This entry is used to prevent GRUB from adding the results of os-prober to the menu. A value of "true" disables the os-prober check of other partitions for operating systems, including Windows, Linux, OSX and Hurd, during execution of the update-grub command. This will keep grub from looking for other OS'es.

| improve this answer | |
  • 1
    The fact that Windows disappears from grub menu when all you wanted to disappear was an old hard drive installation of Ubuntu or whatever should be highlighted in bold. – WinEunuuchs2Unix Jun 5 '18 at 23:48
  • 1
    Making Windows disappear is a feature not a bug! JK, good point, edited. – Organic Marble Jun 5 '18 at 23:58
  • 1
    I must admit (not surprising giving my user name) I avoid Windows most of the year, but I must admit every few months or so I get a gaming urge and go back there for that reason. Luckily there is Ubuntu on "Bash on Windows" (WSL) where I can open a gnome-terminal window so I can still experiment with Ask Ubuntu questions and answers. – WinEunuuchs2Unix Jun 6 '18 at 0:15

The easiest (GUI) way is to run grub-customizer

$ sudo add-apt-repository ppa:danielrichter2007/grub-customizer
$ sudo apt-get update
$ sudo apt-get install grub-customizer
| improve this answer | |

You can use the GRUB_OS_PROBER_SKIP_LIST option to selectively disable scanning devices. So for example, if you want to exclude /dev/sdb1 and /dev/sdc1, first you need to find out their UUID:

blkid | grep -E 'sdb1|sdc1'

Will output something like:

/dev/sdb1: LABEL="bkp_root" UUID="1-2-3-4-5" TYPE="ext4" PARTUUID="123"
/dev/sdc1: LABEL="bkp2_root" UUID="a-b-c-d-e" TYPE="ext4" PARTUUID="abc"

Then write the option to /etc/default/grub using this format:

GRUB_OS_PROBER_SKIP_LIST="1-2-3-4-5@/dev/sdb1 a-b-c-d-e@/dev/sdc1"

Finally, when you run sudo update-grub it will inform you of the changes:

Skipped Ubuntu 18.04.5 LTS (18.04) on /dev/sdb1 by user request.
Skipped Ubuntu 18.04.5 LTS (18.04) on /dev/sdc1 by user request.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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