The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 6,683โ€…    Votes:  5โ€…    โœ… Solution
Tags: boot   grub2   hard-drive  
Link: ๐Ÿ” See Original Answer on Ask Ubuntu โง‰ ๐Ÿ”—

URL: https://askubuntu.com/q/1042589
Title: Remove second hard drive OS from grub
ID: /2018/06/01/Remove-second-hard-drive-OS-from-grub
Created: June 1, 2018    Edited:  June 12, 2020
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


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:

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.

โ‡ง How can I change the keybindings in Nautilus? Wireless keyboard not working with Ubuntu 18.04 Live USB  โ‡ฉ