GRUB2 on BootFloppy it is posibile?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
koan
Level 1
Level 1
Posts: 5
Joined: Thu Jan 27, 2011 2:02 pm
Location: Plovdiv

GRUB2 on BootFloppy it is posibile?

Post by koan »

Until now I always install the boot loader on a floppy disk. I Just do not want GRUB to writes on my MBR-a. which is currently used bootloader Windows 7, on another drive and partition I have LinuxMint 10 DebianEdition.
We should note that the standard commands and ideas how to do this with GRUB for new GRUB2 not be apply. For example, there is no menu.lst stage1 stage2, etc.
During installation, also was not able to install a floppy GRUB2 and it istall the partition with the root directory, actually tried but did not get the first with new ubuntu and then with the Mint, total under the new distrota is new loader GRUB2
Here is part of attempts to install the floppy first in the good old way:

Code: Select all

user@mint:~/Desktop$ sudo grub-install /dev/fd0
/usr/sbin/grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!.
/usr/sbin/grub-setup: error: embedding is not possible, but this is required for cross-disk install.
What does this mean?
/usr/sbin/grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!.
/usr/sbin/grub-setup: error: embedding is not possible, but this is required for cross-disk install.


Then I tried with some new commands specifically for GRUB2

Code: Select all

mint user # grub-mkdevicemap
 
mint user # sudo grub-install --force --root-directory=/media/floppy /dev/fd0
[bg=yellow]/usr/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk.  This is a BAD idea..
/usr/sbin/grub-setup: error: embedding is not possible, but this is required for cross-disk install.[/bg]
mint user # sudo grub-mkconfig -o /media/floppy/boot/grub/grub.cfg
Generating grub.cfg ...
Found background image: linuxmint.png
Found Debian background: linuxmint.png
Found linux image: /boot/vmlinuz-2.6.32-5-686
Found initrd image: /boot/initrd.img-2.6.32-5-686
Found Windows 7 (loader) on /dev/sda1
done
mint user # 
What this means? What This is that BAD idea...?
"/usr/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk. This is a BAD idea..
/usr/sbin/grub-setup: error: embedding is not possible, but this is required for cross-disk install."


Then I tried in another way according to:
http://www.gnu.org/software/grub/manual ... 02dinstall

Code: Select all

# mke2fs /dev/fd0
     # mount -t ext2 /dev/fd0 /mnt
     # grub-install --root-directory=/mnt fd0
     # umount /mnt

Code: Select all

user@mint:~$ sudo mount -t ext2 /dev/fd0 /mnt
[sudo] password for ivan: 
user@mint:~$ sudo grub-install --root-directory=/mnt fd0
/usr/sbin/grub-probe: error: cannot stat `fd0'.
user@mint:~$ 
and again failed:
/usr/sbin/grub-probe: error: cannot stat `fd0'.

another tutorial had the following proposal at:

http://wiki.linuxquestions.org/wiki/Boot_Floppy
Creating a GRUB boot floppy
Insert a writable floppy
Go to a terminal
su to root
#fdformat /dev/fd0 (change /dev/fd0 if your floppy drive isn't at that location)
#mke2fs /dev/fd0
Now mount your floppy drive somewhere (e.g. to /mnt/floppy with #mount -t ext2 /dev/fd0 /mnt/floppy)
#grub-install --root-directory=/mnt/floppy '(fd0)'
Now create a valid grub.conf file at /mnt/floppy/boot/grub/grub.conf
Unmount floppy (e.g. #umount /mnt/floppy)

tried this suggestion

Code: Select all

user@mint # mount -t ext2 /dev/fd0 /mnt/floppy
user@mint # grub-install --root-directory=/mnt/floppy '(fd0)'
/usr/sbin/grub-setup: error: no such disk.
disappointed again > usr/sbin/grub-setup: error: no such disk.

As I complete deadlock. :?: Currently you run Linux with a universal program to a floppy boot which can start all: http://gujin.sourceforge.net/. Incidentally, a very useful program recommend it to anyone dealing with Linux.

My device.map
(fd0) /dev/fd0
(hd0) /dev/disk/by-id/ata-ExcelStor_Technology_J880_PFD200K203L27A
(hd1) /dev/disk/by-id/ata-SAMSUNG_SP0802N_S00JJ10A183047
(hd2) /dev/disk/by-id/ata-Maxtor_6E030L0_E163MGQE

Code: Select all

user@mint :~$ sudo fdisk -l

Disk /dev/sda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdf56df56

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3421    27479151    7  HPFS/NTFS
/dev/sda2            3422       10011    52934175    5  Extended
/dev/sda5            3422        6731    26587543+   7  HPFS/NTFS
/dev/sda6            6732       10011    26346568+   7  HPFS/NTFS

Disk /dev/sdc: 30.8 GB, 30750031872 bytes
255 heads, 63 sectors/track, 3738 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3e6da995

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1        1657    13309821    7  HPFS/NTFS
/dev/sdc2            1658        3738    16715602    f  W95 Ext'd (LBA)
/dev/sdc5            1658        1803     1172713+  82  Linux swap / Solaris
/dev/sdc6            1804        2718     7349706   83  Linux
/dev/sdc7            2719        3738     8193118+  83  Linux

Disk /dev/sdb: 80.1 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3b883b87

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        5604    45014098+   7  HPFS/NTFS
/dev/sdb2            5605        9733    33166192+   c  W95 FAT32 (LBA)

Disk /dev/sdd: 2063 MB, 2063597568 bytes
16 heads, 32 sectors/track, 7872 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5b150ca9
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
oobetimer

Re: GRUB2 on BootFloppy it is posibile?

Post by oobetimer »

Here you are .. :D

mkdir /tmp/fdroot

mkdir /tmp/fdroot/boot

mkdir /tmp/fdroot/boot/grub

cp /boot/grub/grub.cfg /tmp/fdroot/boot/grub

cd /tmp

grub-mkrescue --output=grub2.img fdroot

sudo dd if=grub2.img of=/dev/fd0
koan
Level 1
Level 1
Posts: 5
Joined: Thu Jan 27, 2011 2:02 pm
Location: Plovdiv

Re: GRUB2 on BootFloppy it is posibile?

Post by koan »

So here's what you get in the implementation of the code which offer.

Code: Select all

user@mint:~$ sudo -s
[sudo] password for user: 
mint user # mkdir /tmp/fdroot
mint user # mkdir /tmp/fdroot/boot
mint user # mkdir /tmp/fdroot/boot/grub
mint user # cp /boot/grub/grub.cfg /tmp/fdroot/boot/grub
mint user # cd /tmp
mint tmp # grub-mkrescue --output=grub2.img fdroot
Enabling BIOS support ...
xorriso 0.5.6 : RockRidge filesystem manipulator, libburnia project.

mint tmp # sudo dd if=grub2.img of=/dev/fd0
dd: write in „/dev/fd0“:No space left on device
2881+0 read block
2880+0 write block
copy 1474560 b (1,5 MB), 95,2699 s, 15,5 kB/s
mint tmp # 
After made a floppy that way and when I boot from a floppy disk appears GRUB shell prompt and nothing else happens. :roll:
GRUB>
Thus, we do rescue disk but it is not the same as the bootable floppy disk.
Seeking a solution to the problem I managed to do a rescue disk in several ways. But when I boot system with this disk it appeared GRUB2 menu but when I tried to start it could not run either Linux or windows.
Theoretically, when booting from rescue disk every time you update kernel will have to make a new floppy disk manual. For this I want to make a bootable floppy disk to automatically update and not a rescue disk.
sgosnell

Re: GRUB2 on BootFloppy it is posibile?

Post by sgosnell »

If you've had success using legacy grub, why not just continue to use it? You don't have to use grub2, you can always install the old version. When you're doing things unconventionally, you sometimes have to use more unconventional methods. It's very unusual these days to boot from a floppy, and floppy support is slowly but surely being phased out, because modern machines don't even have floppy drives. It's not difficult to put grub or grub2 on a USB drive, though, and using one of those might work better for you.
oobetimer

Re: GRUB2 on BootFloppy it is posibile?

Post by oobetimer »

koan
Level 1
Level 1
Posts: 5
Joined: Thu Jan 27, 2011 2:02 pm
Location: Plovdiv

Re: GRUB2 on BootFloppy it is posibile?

Post by koan »

sgosnell wrote:If you've had success using legacy grub, why not just continue to use it? You don't have to use grub2, you can always install the old version. When you're doing things unconventionally, you sometimes have to use more unconventional methods. It's very unusual these days to boot from a floppy, and floppy support is slowly but surely being phased out, because modern machines don't even have floppy drives. It's not difficult to put grub or grub2 on a USB drive, though, and using one of those might work better for you.
Well, To use the same old GRUB was the first idea I decided to try.

Let's start. According to the tutorials.
1. Remove GRUB 2
sudo apt-get purge grub2 grub-pc
The system will be unbootable until another bootloader is installed!
2. Install GRUB 0.97
sudo apt-get install grub
3. With grub installed, the user must still create the menu.lstand stage1/stage2 files by running the following two commands.
sudo update-grub
Generates menu.lst
Tab to “Yes” when prompted.
sudo grub-install /dev/fd0
Everything seems o'k.
But when I started to install the Legacy GRUB during installation begins upgrade of the old with the new loader and I can have escaped upgade and voila again we have new GRUB2.

Indeed, the floppy disk has increasingly little use and will really need to drop it.
I guess I'll use good old LILO. maybe

and many thanks to oobetimer for this link.
sgosnell wrote: Why not to use LILO BootFloppy? ..  
viewtopic.php?f=42&t=56726&p=324837&hilit=lilo#p324834
but most likely will try to install bootloader on USB flafh drive. I would be very grateful if someone gave me a link to a working resource how to work it that idea.
oobetimer

Re: GRUB2 on BootFloppy it is posibile?

Post by oobetimer »

koan wrote: but most likely will try to install bootloader on USB flafh drive. I would be very grateful if someone gave me a link to a working resource how to work it that idea.
Here you are .. :D

http://forums.linuxmint.com/viewtopic.p ... 70#p304874

Click the picture and watch a video .. :D

Image
mccauley

Do It By Hacking the Grub2 Rescue Floppy Image

Post by mccauley »

koan wrote:
sgosnell wrote:If you've had success using legacy grub, why not just continue to use it? You don't have to use grub2, you can always install the old version. When you're doing things unconventionally, you sometimes have to use more unconventional methods. It's very unusual these days to boot from a floppy, and floppy support is slowly but surely being phased out, because modern machines don't even have floppy drives. It's not difficult to put grub or grub2 on a USB drive, though, and using one of those might work better for you.
Well, To use the same old GRUB was the first idea I decided to try.

Let's start. According to the tutorials.
1. Remove GRUB 2
sudo apt-get purge grub2 grub-pc
The system will be unbootable until another bootloader is installed!
2. Install GRUB 0.97
sudo apt-get install grub
3. With grub installed, the user must still create the menu.lstand stage1/stage2 files by running the following two commands.
sudo update-grub
Generates menu.lst
Tab to “Yes” when prompted.
sudo grub-install /dev/fd0
Everything seems o'k.
But when I started to install the Legacy GRUB during installation begins upgrade of the old with the new loader and I can have escaped upgade and voila again we have new GRUB2.

Indeed, the floppy disk has increasingly little use and will really need to drop it.
I guess I'll use good old LILO. maybe

and many thanks to oobetimer for this link.
sgosnell wrote: Why not to use LILO BootFloppy? ..  
viewtopic.php?f=42&t=56726&p=324837&hilit=lilo#p324834
but most likely will try to install bootloader on USB flafh drive. I would be very grateful if someone gave me a link to a working resource how to work it that idea.
Not sure whether you still need help getting a custom GRUB2 boot floppy, but I experienced the same type of problems the original poster (koan) had. No easy way to do it anymore.

I finally came up with a way to make a custom boot floppy under Debian 6 and Ubuntu 10.10 by modifying the contents of the grub rescue floppy image. (The technique I used should work with any debian-derived distro using GRUB2, so long as the grub-rescue-pc package is available. See addendum below for a link to the mint package containing the original "rescue" floppy image that I started with.)

What I mean by a "custom boot floppy" is a floppy I can configure to boot a particular OS (e.g., Windows 7 or Debian 6).

I started with the rescue floppy image installed by the package grub-rescue-pc. The floppy image is installed at: /usr/lib/grub-rescue/grub-rescue-floppy.img.

Embedded in grub-rescue-floppy.img is a generic grub.cfg file. To make it specific to my system, I had to modify grub-rescue-floppy.img to suit my own needs. What I did was to find where the contents of grub.cfg were stored within the image. I replaced it with my own custom grub.cfg, padded as necessary to match the size of the grub.cfg I was replacing. My own grub.cfg had only the entries that reflected the operating systems on my computer. (The original image had "generic" entries for a bunch of OSes, starting with GNU Hurd at the top.) Then I wrote grub-rescue-floppy.img, as modified, to a floppy using dd, and presto, I had a custom boot floppy.

The time consuming part of this was finding the exact byte range within grub-rescue-floppy.img that contained grub.cfg. It starts at byte offset 79872, with a length of 1635 bytes.

You can display it with the following command:

dd if=/usr/lib/grub-rescue/grub-rescue-floppy.img skip=79872 count=1635 bs=1

A little arithmetic gives the size of each piece:

(1) Offset 0 Length 79872
(2) Offset 79872 Length 1635
(3) Offset 81507 Length 1362333

I padded my custom grub.cfg file with whitespace or comments, so as to have a length of 1635 bytes. Using dd, I created the individual parts:

dd if=/usr/lib/grub-rescue/grub-rescue-floppy.img count=79872 bs=1 of=grf_p1.dat
dd if=/usr/lib/grub-rescue/grub-rescue-floppy.img skip=79872 count=1635 bs=1 of=grf_p2.dat
dd if=/usr/lib/grub-rescue/grub-rescue-floppy.img skip=81507 count=1362333 bs=1 of=grf_p3.dat

Then, to create the "custom" rescue floppy, I cat'ed the first piece, the custom grub.cfg file, and the third piece, to make a complete image file:

cat grf_p1.dat grub.cfg grf_p3.dat > custom-grub-rescue-floppy.img

I made one floppy with a grub.cfg set to boot windows and another floppy with a grub.cfg set to boot linux.

Now, by inserting the right floppy before booting, I can boot my headless workstation to either Ubuntu or Windows, as necessary, and access it remotely, even though I do not have a keyboard or monitor attached.

As an example, here is my grub.cfg for the floppy that boots Debian, as the default, with an option, if I had a keyboard attached, to boot Windows.

--- BEGIN CUT HERE ---
#
# GRUB configuration file
# CWM 2011.02.18
#

# Boot automatically after 15 secs.
set timeout=15

# By default, boot the first entry.
set default=0

# Fallback to the second entry.
set fallback=1

# For booting GNU/Linux
menuentry "GNU/Linux" {
set root=(hd0,1)
linux /vmlinuz root=/dev/sda1
initrd /initrd.img
}

# For booting Microsoft Windows
menuentry "Microsoft Windows" {
set root=(hd0,2)
chainloader +1
}

# For booting Memtest86+
menuentry "Memtest86+" {
set root=(hd0,1)
linux16 /memtest86+.bin
}

######################################################################
# THIS SPACE IS RESERVED #############################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
######################################################################
#####################################################
--- END CUT HERE ---

The extra stuff at the end of the file is there so that it matches the exact length of the "generic" grub.cfg embedded in the rescue image, i.e., 1635 bytes.

I know that this is confusing. I'll try to answer any questions you have, if I have not provided a clear explanation.

Addendum 1. Get the original floppy image by installing this package: http://community.linuxmint.com/software ... -rescue-pc

Addendum 2. The md5sum of grub-rescue-floppy.img should be 1966048d667c7adbbb3fc005f2081a2f. This will confirm that you are starting with the same source I used.

Addendum 3. I think that this will keep up with kernel upgrades automatically. I am pretty sure I have gone through one kernel upgrade since adopting this hack.
wayne128

Re: GRUB2 on BootFloppy it is posibile?

Post by wayne128 »

@koan
but most likely will try to install bootloader on USB flafh drive. I would be very grateful if someone gave me a link to a working resource how to work it that idea.
Until now I always install the boot loader on a floppy disk. I Just do not want GRUB to writes on my MBR-a. which is currently used bootloader Windows 7, on another drive and partition I have LinuxMint 10 DebianEdition.
We should note that the standard commands and ideas how to do this with GRUB for new GRUB2 not be apply. For example, there is no menu.lst stage1 stage2, etc.

I read that you do not want to have boot loader on MBR.
But floppy would disappear someday.

My learning over multi boot with mixtures of bootloader such as LILO, grub legacy, grub2 etc, seeing many issues mixing OSes, eventually I stay with Grub legacy for some reasons:
1. Easy to learn, just need to edit menu.lst
2. Easy to chainload any partitions that has Windows OS, BSD, Linux.. oh I do not have Mac to play.
3. Easy to write chainload stanza. Always can memorise, as follow for windows OS
title windows OS at sda1
root (hd0,0)
chainloader +1
and chainload linux OS at sdb8
title Linux OS on second drive sdb8
root (hd1,7)
chainloader +1
4. Easy to maintain, hardly need to change , even when Grub2 OS upgrade kernel, upgrade grub, etc the grub legacy chainload stanza does not need to change.
Also can just copy menu.lst and keep in all Linux partitions so that if one get corrupted , I can copy from another one. Anyway it is quite easy to type out those line as above.

5. Easy to repair MBR, and PBR or partition boot sector/record, just a few commands

Code: Select all

root (hdx,y)
setup (hdx) for MBR, setup (hdx,y) for PBR 
quit
This is needed when windows decides to wipe MBR.
I also find no trouble installing Grub legacy on any internal or external hard disk's MBR, I have USB drive that is also multi boot with many OSes and so I can move it to someone else computer, boot it, run and demonstrate Linux OSes..

So I would recommend you give Grub legacy another review.

Also review the real reason you want to avoid writing it onto MBR.
Of course each time when you run Windows OS, you stand a chance that Windows decides to wipe MBR and then all your Linux become non-bootable.
However, as I list on item 5, it is very easy to repair MBR using Grub legacy DVD/CD or USB. Those Grub legacy OS that I used for repairing MBR are:
PCLinuxOS, all desktops
Mepis /antiX
Fedora, Fedora remix ( many OSes)
Pardus
some others

Of course, before you become comfortable about putting boot loader , you can always consider using a external USB stick to have grub legacy.

Instead of just having a grub legacy installed on the USB stick, as most USB stick has very large in capacity , such as 4G ( I got my 4G flash at USD9 each). It would be a waste to have a 4G drive, capable of running a OS, to just store a boot loader which is likely just about less than 40Mbytes.

Since it had 4G, my as well just load a full OS inside with persistent. One good thing about it is, if your hard disk someday decide to take a break, you are still going to be alright running the computer with the USB flash!
This happened recently to my 6-year old laptop, the hard disk suddenly quite forever. So I just use the stick and let the kid continue to use ( just slower) until I replace the internal hard disk with a new one and install OS.

I can just install a 'slim os' that had grub legacy, so that each time when I boot up I am presented with a Grub menu, and all the selection of each partition, than I just select, enter to boot the OS of choice.
Locked

Return to “Installation & Boot”