• ×
    Information
    Windows update impacting certain printer icons and names. Microsoft is working on a solution.
    Click here to learn more
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
  • ×
    Information
    Windows update impacting certain printer icons and names. Microsoft is working on a solution.
    Click here to learn more
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
Guidelines
The HP Community is where owners of HP products, like you, volunteer to help each other find solutions.
Archived This topic has been archived. Information and links in this thread may no longer be available or relevant. If you have a question create a new topic by clicking here and select the appropriate board.
HP Recommended

My Problem: Can't boot from second drive by default

I have an HP Pavillion dv7 1451NR, product number NV204UA#ABA.

I have two drives installed.

I have Windows 7 64-bit installed on drive 0 and Ubuntu 32-bit installed on drive 1.

 

I can successfully boot either operating system by the following procedure:

  1. Power up

  2. Press escape-key to get to BIOS

  3. Press F9-key to get to boot menu

  4. Boot menu shows two drives named “Internal Hard Drive”

  5. If I select the first entry named “Internal Hard Drive” I boot to Windows 7.

  6. If I select the 2nd entry named “Internal Hard Drive” I boot to Ubuntu.

 

I power up if I do NOT press escape, the machine boots to Windows after the timeout.

My Problem: I want to boot to Ubuntu by default.

 

I've checked the HP bios and I don't believe there is any way to do this by changing the boot priority in BIOS. The BIOS doesn't seem to differentiate between the two hard drives. I only has one entry for “Internal Hard Drive”.

 

I believe an approach that should work is:

  1. Use bcdedit or easybcd to create a BCD record that points to GRUB.

  2. Create a GRUB config file that “chain” loads Ubuntu.

  3. Use bcdedit to move the GRUB entry as the default.

I've tried various permutations but can't get it to work.

 

Question: Should my idea work?

Detailed question: How do I discover where the initial boot image is for GRUB? I know I need the a copy of sector 0 from the drive and partition that Ubuntu and GRUB are on. From Ubuntu I have tried permutations of “dd if=/dev/sdxx of=/NST/grubsdXX.bin bs=512 count=1” to generate the boot image. Non have worked.

Detailed question: What exactly should the BCD record look like? What commands do I use to create it. I've tried various permutations of

bcdedit /create /d “GRUB” /application BOOTSECTOR

bcdedit /set {60e1c218-a9b3-11e0-89b8-00235abb6d44} device partition=C:

bcdedit /set {60e1c218-a9b3-11e0-89b8-00235abb6d44} path \nst\grubsdXX.bin

bcdedit /displayorder {60e1c218-a9b3-11e0-89b8-00235abb6d44} /addlast”

I think I'm close, but can't get it to work. My guess is either I'm not getting the right sector 0 image into grubsdXX.bin or I'm not setting the “partition” or path correctly or possibly I need to install GRUB on drive 0.

 

Any help would be appreciated. Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
HP Recommended

One refinement: I discovered how to avoid having to edit the menu item every time you update the Ubuntu kernel. When it is updated Ubuntu creates a link in the root of the root partition that points to the latest kernel and one that points the latest initrd. Therefore if you replace the reference to a specific kernel (example: /boot/vmlinuz-3.2.0-48-gereic-pae) and initrd (example: /boot/initrd.img-3.2.0-48-generic-pae) with "/vmlinuz" and "/initrd.img". Your menu will always boot the latest installed Ubuntu.

View solution in original post

3 REPLIES 3
HP Recommended

Hi @c-cubed ,

 

Welcome to the HP Forums!:smileyhappy:



It is a terrific place to find answers.
For you to have the best experience in the HP forum I would like to direct your attention to the HP Forums Guide Learn How to Post and More

 

I understand that you have Windows 7 on drive 0 and Ubuntu on Drive 1.

YOu can boot to either one by selecting it in the bios but would like to have the option presented to you on boot so you can choose without accessing the bios.

 

Here are  links to  How to Install Ubuntu on separate hard drive in a dual boot? [duplicate

WindowsDualBoot, and Install on Second Hard Drive with startup boot option?

 

You can try these, I am not sure if it will then provide the options on boot or not.

 

If this has not helped here is a link to Ubuntu Support

 

Good Luck!

Sparkles1

HP Recommended

Sparkles, your suggestions were very good. I solved my problem using easybcd and neogrub. See below.

My Problem:

Following a power up I wanted my Ubuntu OS to boot by default.

 

Environment:

I have an HP Pavilion Entertainment PC model Pavilion dv7 1451nr.

I have two sata drives installed. One in the primary bay and one in the secondary bay.

I have Windows 7 64 bit installed on drive 0 and Ubuntu installed on drive 1.

Windows 7 was installed first, Ubuntu was installed second.

The Windows 7 boot loader is installed in the MBR on drive o,

The Ubuntu/Grub boot loader is installed in the MBR on drive 1.

The HP bios shows two drives both named “Internal Laptop Drive.

 

Additional Background

If I boot my machine and do not hit any keys. It boots using the MBR on drive 0. This boots Windows 7.

If I boot my machine and press Escape-Key and the F9-Key the bios boot menu is displayed. If I choose the first “Internal Laptop Drive” Windows boots. If I choose the 2nd “Internal Laptop Drive” Ubuntu boots. The HP bios does not provide a mechanism to default to booting from the second drive. Therefore I can not boot to Linux by default. If this HP machine had a better BIOS. I could have done this easily buy just changing the default boot order in BIOS.

 

Steps to get Ubuntu booted from 2nd drive by default

This process involves booting each operating systems multiple times so it takes patients. However it is relatively simple, somewhat tedious.

 

Required equipment & materials

Have a pencil and paper handy to take notes so you don't get lost and also to record information needed as you transition from one OS to another.

 

Your computer and an Internet connection.

 

1.Backup your system and critical file

 

I strongly suggest you do a full back-up of your system, all drives, before starting. Its hard to screw this up and its relatively easy to recover, but having a full back-up is good procedure.

 

After backing up your drives, boot Windows. Start a command-line terminal using “Run As Administrator”. Change directory to the “\boot” directory. Note “\boot” is a hidden directory. Make a backup copy of the file named “BCD”. In all most all instances if something goes wrong you can recover by merely restoring this file. Since you have two operating systems. That's relatively easy. You boot your Ubuntu system. Mount your Windows file system and restore the “BCD” file.

2.Find/Verify Ubuntu root disk & partition

Boot Ubuntu. Login and open a shell with sudo/root privileges. If you already know the disk and partition of your Ubuntu OS skip to step 2.

 

Use command “df”. The partition labeled “Mounted on /” is the root partition.

See the column labeled “Filesystem” to determine the filesystem and disk of the root partition.

Write this down you will need them.

Example:

 

c-cubed-laptop:~$ df

 

Filesystem 1K-blocks Used Available Use% Mounted on

 

/dev/sdb5 101058996 34207896 61717532 36% /

 

udev 1918628 4 1918624 1% /dev

 

tmpfs 771540 924 770616 1% /run

 

none 5120 0 5120 0% /run/lock

 

none 1928844 160 1928684 1% /run/shm

 

/dev/sdb1 205499196 62038008 143461188 31% /media/Hitachi_boot_disk

 

/dev/sda1 473647100 226068092 247579008 48% /media/Windows

 

 

3.Copy the Grub menu file from Linux to Windows

From your sudo/root shell. If it is not already mounted, mount the file system containing your Windows OS. “cd” to the root of the Windows OS file system. Copy “menu.lst” from /boot/grub to /NST in your Windows file system, changing the name to protect the file.

 

Example:

c-cubed-laptop:~$cd /media/Windows

c-cubed-laptop:~$cp /boot/grub/menu.lst ./NST/unbuntumenu.lst

 

menu.lst is the grub menu used by your Ubuntu grub loader to load unbuntu.

 

4.Download and install easybcd

Shutdown Ubuntu and boot to Windows 7. Login and use your favorite browser to download “easybcd” from NeoSmart Technologies. Its a great piece of freeware. I found it at ( https://neosmart.net/EasyBCD/ ).

Install easybcd following the instructions provided.

 

5.Modify the Windows 7 Boot Configuration Data file (BCD) to allow Windows LDR to BOOT Ubuntu

 

Go to your Windows start menu and launch easybcd. It will display something like the screen in Figure 1.

 

Click/select add entry. Then click select the NeoGrub tab. The first time you click NeoGrub it will have an option to “Install” click it. It will then display the screen below (figure 2). Click “Configure”. This will create a file “menu.lst” in the directory \NST. You can change the “Name:” of the entry you are adding from “Neogrub...” to something more meaningful, say “Ubuntu”. Save the changes and exit easybcd.

 

 

Figure 1   1.Replace the Neogrub menu.lst with your Ubuntu menu.lst

Open a Windows command line terminal using “run as administrator”. Switch to the drive that your Windows OS is loaded on and cd to the directory \NST.

 

The two files “menu.lst” (created by easybcd) and “ubuntumenu.lst” created by you will be in this directory.

 

Rename “menu.lst” to “neogrubmenu.lst”. Rename “ubuntumenu.lst” to menu.lst.

 

2.Modify the menu.lst to deal with differences between Ubuntu and Windows

 

Using “Wordpad” open “menu.lst. Do not use “Notepad”. The file was created in Linux and “Notepad” can't deal with the Linux line ends.

 

Neogrub, the grub loader in Windows, needs to know the drive and partition of the Ubuntu Linux kernel you want to load. This information is not in the file you copied from Ubuntu. So you need to add it.

 

Some background. Grub numbers drives and partitions from 0 to n. Linux file systems number drives from a-..., and numbers partitions from 1-n+1. GO FIGURE!!!

 

So take the information you wrote down in step one (example /dev/sdb5). In the example this is drive 1 (b) and partition 4 (5-1).

 

Neogrub needs you to define the root partition as hd[drive,parition]. In our example (/dev/sdb5) this translates to hd[1,4].

 

Ubunbtu (Linux) needs the root partition identified as /dev/sdXX. In our example this is /dev/sdb5.

 

So using “wordpad.” we make those changes. See the example below with the changes colored RED.

 

NOTE: My Ubuntu menu.lst file had many possible kernels to boot because Ubuntu saves the old kernel each time you update. This allows you to boot to an older kernel should something go wrong. I deleted all the entries corresponding to the older kernels to make the example easier. You can do the same, or not.

 

Warning: When you update your Ubuntu kernel you will need to update the “menu.lst” file in your Windows file system. If you fail to do that, you will continue to boot your “old” Ubuntu kernel.

 

 

 

 

Menu.lst example

 

# menu.lst - See: grub(8), info grub, update-grub(8)

# grub-install(8), grub-floppy(8),

# grub-md5-crypt, /usr/share/doc/grub

# and /usr/share/doc/grub-doc/.

 

## default num

# Set the default entry to the entry number NUM. Numbering starts from 0, and

# the entry number 0 is the default if the command is not used.

#

# You can specify 'saved' instead of a number. In this case, the default entry

# is the entry saved with the command 'savedefault'.

# WARNING: If you are using dmraid do not use 'savedefault' or your

# array will desync and will not let you boot your system.

default 0

 

## timeout sec

# Set a timeout, in SEC seconds, before automatically booting the default entry

# (normally the first entry defined).

timeout 10

 

## hiddenmenu

# Hides the menu by default (press ESC to see the menu)

#hiddenmenu

 

# Pretty colours

#color cyan/blue white/blue

 

## password ['--md5'] passwd

# If used in the first section of a menu file, disable all interactive editing

# control (menu entry editor and command-line) and entries protected by the

# command 'lock'

# e.g. password topsecret

# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/

# password topsecret

 

#

# examples

#

# title Windows 95/98/NT/2000

# root (hd0,0)

# makeactive

# chainloader +1

#

# title Linux

# root (hd0,1)

# kernel /vmlinuz root=/dev/hda2 ro

#

 

#

# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

 

### BEGIN AUTOMAGIC KERNELS LIST

## lines between the AUTOMAGIC KERNELS LIST markers will be modified

## by the debian update-grub script except for the default options below

 

## DO NOT UNCOMMENT THEM, Just edit them to your needs

 

## ## Start Default Options ##

## default kernel options

## default kernel options for automagic boot options

## If you want special options for specific kernels use kopt_x_y_z

## where x.y.z is kernel version. Minor versions can be omitted.

## e.g. kopt=root=/dev/hda1 ro

## kopt_2_6_8=root=/dev/hdc1 ro

## kopt_2_6_8_2_686=root=/dev/hdc2 ro

# kopt=root=UUID=fdd42e98-b244-44a2-acf1-a991c2a4314b ro

 

## default grub root device

## e.g. groot=(hd0,0)

# groot=fdd42e98-b244-44a2-acf1-a991c2a4314b

 

## should update-grub create alternative automagic boot options

## e.g. alternative=true

## alternative=false

# alternative=true

 

## should update-grub lock alternative automagic boot options

## e.g. lockalternative=true

## lockalternative=false

# lockalternative=false

 

## additional options to use with the default boot option, but not with the

## alternatives

## e.g. defoptions=vga=791 resume=/dev/hda5

# defoptions=quiet splash

 

## should update-grub lock old automagic boot options

## e.g. lockold=false

## lockold=true

# lockold=false

 

## Xen hypervisor options to use with the default Xen boot option

# xenhopt=

 

## Xen Linux kernel options to use with the default Xen boot option

# xenkopt=console=tty0

 

## altoption boot targets option

## multiple altoptions lines are allowed

## e.g. altoptions=(extra menu suffix) extra boot options

## altoptions=(recovery) single

# altoptions=(recovery mode) single

 

## controls how many kernels should be put into the menu.lst

## only counts the first occurence of a kernel, not the

## alternative kernel options

## e.g. howmany=all

## howmany=7

# howmany=all

 

## specify if running in Xen domU or have grub detect automatically

## update-grub will ignore non-xen kernels when running in domU and vice versa

## e.g. indomU=detect

## indomU=true

## indomU=false

# indomU=detect

 

## should update-grub create memtest86 boot option

## e.g. memtest86=true

## memtest86=false

# memtest86=true

 

## should update-grub adjust the value of the default booted system

## can be true or false

# updatedefaultentry=false

 

## should update-grub add savedefault to the default options

## can be true or false

# savedefault=false

 

## ## End Default Options ##

 

title Ubuntu 12.04.2 LTS, kernel 3.2.0-48-generic-pae

###Added to define root drive and partition for Neogrub

root (hd1,4)

uuid fdd42e98-b244-44a2-acf1-a991c2a4314b

kernel /boot/vmlinuz-3.2.0-48-generic-pae root=UUID=fdd42e98-b244-44a2-acf1-a991c2a4314b ro quiet splash root=/dev/sdb5

initrd /boot/initrd.img-3.2.0-48-generic-pae

#removed

##quiet

 

 

### END DEBIAN AUTOMAGIC KERNELS LIST

 

# This is a divider, added to separate the menu items below from the Debian

# ones.

title Other operating systems:

root

 

 

# This entry automatically added by the Debian installer for a non-linux OS

# on /dev/sda1

title Windows 7

rootnoverify (hd0,0)

savedefault

makeactive

chainloader +1

 

 

#end of menu file

 

 

C:\Windows\system32>bcdedit

 

Windows Boot Manager

--------------------

identifier {bootmgr}

device partition=C:

description Windows Boot Manager

locale en-US

inherit {globalsettings}

default {default}

resumeobject {768789e4-35e9-11dd-b461-e92a35599e1c}

displayorder {current}

{default}

toolsdisplayorder {memdiag}

timeout 30

displaybootmenu Yes

 

Windows Boot Loader

-------------------

identifier {current}

device partition=C:

path \Windows\system32\winload.exe

description Windows 7

locale en-US

inherit {bootloadersettings}

recoverysequence {60e1c20b-a9b3-11e0-89b8-00235abb6d44}

recoveryenabled Yes

osdevice partition=C:

systemroot \Windows

resumeobject {768789e4-35e9-11dd-b461-e92a35599e1c}

nx OptIn

 

Real-mode Boot Sector

---------------------

identifier {default}

device partition=C:

path \NST\NeoGrub.mbr

description Unbuntu

 

C:\Windows\system32>

 

Save the file and you are almost done.

 

3.Using easybcd Change the default boot order in your Windows BCD

Make sure you save the modified “menu.lst” file. Close “Wordpad”. Open easybcd. Chose the “Edit Boot Menu” option. Change the default boot image from Windows 7 to the new Ubuntu entry you created.

 

 

4.Your done

Shutdown Windows. Power down your system (not really necessary). Power it up and allow it to boot by default. The Windows boot loader will start. It will hand-off to Neogrub. Neogrub will boot your Ubuntu operating system.

Additional Information:

After you have installed Neogrub. You could use the standard Windows program “bcdedit” to make the changes to the bcd file. Its a command-line utility. It offers more power than easybcd, but requires more knowledge.

 

Its also possible to use easybcd and configure a menu.lst file to chain load Ubuntu. If you do this the Windows boot loader starts Neogrub and then Neogrub starts the Ubuntu boot loader. An advantage of this approach is that you do not have to manually update the menu.lst file in the Windows file system when you update your Ubuntu kernel. My next project is to figure out the magic incantations for chain loading.

HP Recommended

One refinement: I discovered how to avoid having to edit the menu item every time you update the Ubuntu kernel. When it is updated Ubuntu creates a link in the root of the root partition that points to the latest kernel and one that points the latest initrd. Therefore if you replace the reference to a specific kernel (example: /boot/vmlinuz-3.2.0-48-gereic-pae) and initrd (example: /boot/initrd.img-3.2.0-48-generic-pae) with "/vmlinuz" and "/initrd.img". Your menu will always boot the latest installed Ubuntu.

Archived This topic has been archived. Information and links in this thread may no longer be available or relevant. If you have a question create a new topic by clicking here and select the appropriate board.
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the <a href="https://www8.hp.com/us/en/terms-of-use.html" class="udrlinesmall">Terms of Use</a> and <a href="/t5/custom/page/page-id/hp.rulespage" class="udrlinesmall"> Rules of Participation</a>.