WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Can I boot from the Windows 7 Loader?  (Read 6107 times)

Offline mfloris

  • Newbie
  • *
  • Posts: 4
Can I boot from the Windows 7 Loader?
« on: September 14, 2018, 09:08:30 AM »
Hello everyone,

I squeezed a microcore frugal installation on my hard disk, between the Windows and the Lubuntu partition.

The idea is to use it as an emergency partition to fix Lubuntu (or Windows) whenever I mess it up - and it happens a lot - without needing the Lubuntu Live USB pendrive.

I like to keep the Windows bootloader in place and use it to boot every OS (I know it's a bad idea)

To boot Lubuntu from the Windows bootlader I installed grub2 on the Lubuntu partition itself (something like /dev/sda7 instead of /dev/sda) and copied the first 512B into C:\lubuntu.bin which I can launch from the Windows boot.

I can't do the same with TinyCore because when TinyCore is not running, everything is compressed and I don't have the complete filesystem

I tried to boot TinyCore from a USB stick and

grub-install --root-directory=/dev/sda8/tce /dev/sda8

But I get an error like "/dev/sda8/tce/boot/grub/stage1 not read correctly"

I tried some other things (like grub-install /dev/sda8) but still, it's like there is no linux on /dev/sda8 because as far as I understood the filesystem is created on RAM and it runs from there, there is not really a linux installation on the hard disk

Is there some other way that I can boot TinyCore from the Windows7 bootloader?

I only have two requirements:

1) Keep the Windows7 bootloader in place, as the first thing to show up at boot

2) booting whatever basic linux console from the hard disk, without having to insert any external storage or the network cable. I don't need persistence or desktop environment

Thank you! :)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11570
Re: Can I boot from the Windows 7 Loader?
« Reply #1 on: September 14, 2018, 09:42:42 AM »
Hi mfloris
Quote
To boot Lubuntu from the Windows bootlader I installed grub2 on the Lubuntu partition itself (something like /dev/sda7 instead of /dev/sda) and copied the first 512B into C:\lubuntu.bin which I can launch from the Windows boot.
Then do the same thing on  /dev/sda8  and edit that config file to point to the  kernel  and  initrd.
Quote
I squeezed a microcore frugal installation on my hard disk, between the Windows and the Lubuntu partition.
Then that partition must have a  kernel  (vmlinuz)  and an  initrd  (core.gz)  on it. Probably under  /boot.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11570
Re: Can I boot from the Windows 7 Loader?
« Reply #2 on: September 14, 2018, 09:45:49 AM »
Hi mfloris
Almost forgot, then add an entry to the Windows bootloader for  sda8.

Offline mfloris

  • Newbie
  • *
  • Posts: 4
Re: Can I boot from the Windows 7 Loader?
« Reply #3 on: September 14, 2018, 10:25:02 AM »
Then do the same thing on  /dev/sda8  and edit that config file to point to the  kernel  and  initrd.

Well as I already wrote, I did try that but it failed. From microcore live usb:

#grub-install --root-directory=/mnt/sda8/tce /dev/sda8
The file /mnt/sda8/tce/boot/grub/stage1 not read correctly

I tried to install grub2 from Lubuntu but there is not enough space on the microcore partition (just 18MB!!). I have to enlarge it and try again. A good idea would be to give it 1GB or so and then shrink it back when everything works

Anyway I was asking for a different approach since TinyCore is not Ubuntu and trying to boot it the same way might be conceptually wrong

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11570
Re: Can I boot from the Windows 7 Loader?
« Reply #4 on: September 14, 2018, 10:33:28 AM »
Hi mfloris
Quote
... since TinyCore is not Ubuntu and trying to boot it the same way might be conceptually wrong
They still both start up the same way, with a kernel and an initrd.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11570
Re: Can I boot from the Windows 7 Loader?
« Reply #5 on: September 14, 2018, 10:41:45 AM »
Hi mfloris
A less direct way would be to add a menu entry to the grub config file in your Lubuntu partition to sda8. When the Windows
bootloader comes up you select grub2, then when grub2 comes up you select Tinycore.

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 760
Re: Can I boot from the Windows 7 Loader?
« Reply #6 on: September 14, 2018, 05:59:45 PM »
I agree with Rich; plus to be honest there's no reason Tiny/Micro can't live WITH your Lubuntu (sda7)


Simply create a home for microcore to reside (such as sda7/microcore), add another grub menu item, this one pointing to sda7/microcore/vmlinuz and sda7/microcore/core.gz respectively and voila...  you're done!  You might even want to rename your Lubuntu entry in Windows boot manager to just "Linux" and have your Grub manager deal with the menu of which flavor.


What happens afterward is simple...
MicroCore boots up from sda7, loads the kernel and init image into memory and once it's finished, has no further need for sda7 and disconnects from it, leaving the 'buntu partition rather protected as well.  At this stage, you'd never know 'buntu existed as the file structure is from within the init image, not the hard drive.

Offline mocore

  • Hero Member
  • *****
  • Posts: 632
  • ~.~
Re: Can I boot from the Windows 7 Loader?
« Reply #7 on: September 15, 2018, 04:01:10 AM »
imho this is a usefull resource wrt
methods of booting what ever from whatever
and boot terminology

http://diddy.boot-land.net/grub4dos/Grub4dos.htm

i think this is the relevent section
http://diddy.boot-land.net/grub4dos/files/install_windows.htm#windows3
wrt "Can I boot from the Windows 7 Loader"
 :)

Offline mfloris

  • Newbie
  • *
  • Posts: 4
Re: Can I boot from the Windows 7 Loader?
« Reply #8 on: September 17, 2018, 05:59:47 AM »
thank you mocore, that link is very insightful :)

Starting TinyCore from Lubuntu's grub2 defeats the whole purpose of having a fallback when Lubuntu can't boot

Besides, let's just forget that Lubuntu is in the disk too. Let's say I only have Windows7 and TinyCore, and I want to start TinyCore form Windows' bootloader

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 760
Re: Can I boot from the Windows 7 Loader?
« Reply #9 on: September 18, 2018, 12:56:20 AM »
Based on all of the concepts within this post, might I suggest the ultimate fail-safe?
"IF" the computer in question is capable (in BIOS) I'd recommend installing TinyCore onto a USB device (they're only a few $ in today's market) and have your bios set to boot from USB first, followed by CD/DVD, followed by Hard Drive(s).


Without the USB device plugged in, BIOS will see this and skip to the next device, the Cd/DVD drive.
If that's empty (or non-bootable media is in it) it moves forward to the hard drive.
This way, regardless of what's wrong (file system corruption, master boot record (MBR) is trashed, GRUB took a vacation, etc.) you can set up your USB pen drive to not only boot the machine, but to contain different utilities to assist with correcting common problems.  (Be sure to install NTFS and DOS file system support and tools; if this is done, you can copy the registry, startup files, copies of the boot records (etc.) on the USB pen in case something did go South, you've got the files to help get you back on track!)

Offline mfloris

  • Newbie
  • *
  • Posts: 4
Re: Can I boot from the Windows 7 Loader?
« Reply #10 on: September 18, 2018, 04:42:45 AM »
The ultimate failsafe might be just that, but with a different twist

The netbook has 3 USB ports and one SD reader, but the BIOS can't boot from the SD.

I use the USBs a lot and I wouldn't want to have something sticking from the side anyway (no matter how small the pendrive).

What I can do is buy one of those SD cards that flips into a USB drive and leave it always inside the SD card slot (which I rarely use)

This way, if something fail, I can just pop the SD out, flip it, stick it into a USB port and boot TinyCore

I wanted to be able to boot tinycore from the Windows loader but all in all you're right, if this has to be a failsafe tool it only makes sense that it stays physically "inside" the computer but not on the hard drive ;)

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 706
Re: Can I boot from the Windows 7 Loader?
« Reply #11 on: September 18, 2018, 10:22:13 AM »
Have you looked at this, add some chain-loading mechanism via windows.
So windows boot manager start some program to load grub.

Have seen and using this myself.

Code: (bash) [Select]
sudo grub-mkimage --format=i386-pc --output=core.img --prefix=\(hd0,msdos3\)/boot/grub biosdisk part_msdos ext2
sudo cat /usr/lib/grub/i386-pc/lnxboot.img core.img > new.img
sudo mount /dev/sda1 /mnt/
sudo cp new.img /mnt/Boot/arch.bin

It's copied from arch linux webpage:
https://wiki.archlinux.org/index.php/Talk:Dual_boot_with_Windows




Boot existing linux
# (optional) update core.img (see https://wiki.archlinux.org/index.php/GRUB#Generate_core.img_alone )
grub-install --target=i386-pc --grub-setup=/bin/true --debug /dev/sda

# embed core.img into bootable file
cat /usr/lib/grub/i386-pc/lnxboot.img /boot/grub/i386-pc/core.img >/media/win/grub4bcd.img
Hell, you don't even need to boot Linux, just extract those files from your Linux partition using some free tool and concatenate them.

Boot to Windows
bcdedit /create /d "Grub2" /application BOOTSECTOR
# The entry {ID} was successfully created.

bcdedit /set {ID} device partition=C:
bcdedit /set {ID} PATH \grub4bcd.img

# add grub as last entry
bcdedit /displayorder {ID} /addlast

# menu timeout
bcdedit /timeout 13

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Can I boot from the Windows 7 Loader?
« Reply #12 on: September 18, 2018, 01:13:55 PM »
...
I tried to boot TinyCore from a USB stick and

grub-install --root-directory=/dev/sda8/tce /dev/sda8

But I get an error like "/dev/sda8/tce/boot/grub/stage1 not read correctly"

I tried some other things (like grub-install /dev/sda8) but still, it's like there is no linux on /dev/sda8 because as far as I understood the filesystem is created on RAM and it runs from there, there is not really a linux installation on the hard disk
...
Code: [Select]
grub-install --root-directory=/dev/sda8this command is no longer available (obsolete) in current Grub2 installations

Use    (substitute your USB identifier like sdb1 in the command below)
Code: [Select]
sudo mount /dev/sdb1
sudo grub-install --boot-directory=/mnt/sdb1/boot /dev/sdb

See the grub info file for more
http://tinycorelinux.net/9.x/x86/tcz/grub2-multi.tcz.info

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 706
Re: Can I boot from the Windows 7 Loader?
« Reply #13 on: September 19, 2018, 03:49:43 AM »
This command will install grub on the boot master record.

Code: (bash) [Select]
sudo grub-install --boot-directory=/mnt/sdb1/boot /dev/sdb
So windows master boot record(mbr) will be overwritten on the sdb device.

If this is important?

Quote
1) Keep the Windows7 bootloader in place, as the first thing to show up at boot
« Last Edit: September 19, 2018, 03:53:32 AM by patrikg »

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Can I boot from the Windows 7 Loader?
« Reply #14 on: September 19, 2018, 06:32:53 AM »
This command will install grub on the boot master record.

Code: (bash) [Select]
sudo grub-install --boot-directory=/mnt/sdb1/boot /dev/sdb
So windows master boot record(mbr) will be overwritten on the sdb device.

If this is important?

Quote
1) Keep the Windows7 bootloader in place, as the first thing to show up at boot
AIUI this is in reference to the OP’s earlier attempt to install grub2 to his USB device which didn’t go well due to using obsolete commands from grub4dos 
:)


Sent from my iPhone using Tapatalk