USB boot from Installer?

Hi,

I can boot my USB pen using the method of writing the anyboot img to the pen (win32diskimager).
But I can’t boot the pen if using the other method, i.e booting Haiku from another drive and using the Installer to the pen drive.
I really wish to use up the available space on the pen (the 650mB on the anuboot img is not really enough).

Is there any way I can copy what I need from the boot sector of the anyboot img to the bootsector of the other method ?
Or
Is there any app that can resize the partition of the anyboot img ?

It seems that, the Intel partitioning module in DriveSetup doesn’t work properly.

Please : open a ticket for this bug.

Best regards

When you install haiku on a pen drive via installer, it doesn’t write the MBR boot code, so the boot sequence stops before it finds the partition ( event if you made it bootable with installer or makebootable applications).
see
http://dev.haiku-os.org/ticket/5595
http://dev.haiku-os.org/ticket/5980
but it is the right method if you don’t want to loose some space on your pen drive.

so we’ll try to copy the boot code from the “anyboot.img” generated pen drive to the target

Start DriveSetup to find the actual device_path for your pen drives (source and target)

Open Terminal and type the following command to install the MBR boot code from the source pen-drive to the target drive (adapt the command, to your actual device_paths):

dd if=/dev/disk/USB/0/0/raw of=/dev/disk/USB/0/1/raw bs=440 count=1

if is your source USB pen drive device you booted from (you can replace it with the anyboot image file)
of is your target USB pen drive (the one you want to make bootable)
bs is the size of the block to copy - in bytes (here, the size of the boot code area). If you don’t want overwrite the partitions table, don’t exceed 440 bytes !
count is the number of block to copy

see also
http://www.haiku-os.org/community/forum/bootable_usb

I recently had some difficulty getting ‘Anyboot’ to install to a USB. I eventually managed to ‘install’ to a USB by running the install from within the iso. That is I booted the ‘anyboot’ cd and installed once the iso was running bypassing the initial invitation to install.

This method makes all the space available on the USB…did for me anyhow!

I need to point out that not all of my USB thumb drives work with Haiku.

Yes, I tried that already and it refused to boot. Somehow there’s some difference to the boot loader but I don’t know what it is.

Ok, I finally got it working.
The first 440 bytes of the MBR (boot code) was already identical because I used the same anyboot IMG on both pendrives.

I deleted the 650mb partition and created+initalised an active bigger partition to make use of the whole drive, and then did an ‘Install’ into it. And then compared the MBRs.

It was either ‘DriveSetup’ or ‘Installer’ that changed the latter part of the MBR (offset 446), i.e the partition table.

Original IMG partition table (boots) 80 FF FF FF EB FF FF FF 00 20 00 00 00 50 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

‘Installed’ partition table (no-boot)
80 00
00 00 EB 00 00 00 40 00 00 00 00 A8 FA 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

‘testdisk’ modified partition table (boots)
80 01
02 00 EB FE FF FE 40 00 00 00 FF C4 FA 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

I found the ‘testdisk’ program from the MBR wiki page;


You need to ‘Analyse’ it with type ‘*’ (bootable partition) and then just save the result.

(‘testdisk’ also has it’s own MBR boot code, if all else fails, you don’t really need it, but it also boots.)

As you can see, the main difference is that the original IMG uses 'FF’s for the partition CHS address, the ‘DriveSetup’ or ‘Installer’ uses ‘00s’ and the ‘testdisk’ program uses actual values (01,02,00).

(ticket http://dev.haiku-os.org/ticket/6301)

I have tried successfully two quick fixes for this (after Installer);

  1. If booted from a bootable usb drive,

    dd if=/dev/disk/usb/0/0/raw of=/dev/disk/usb/0/1/raw bs=450 count=1

    or
  2. An even simpler method is to use DiskProbe and stick in 3 'FF’s at offset 447,448,449 (assuming you created the partition structure inside DriveSetup).

Note that I have only experienced this with USB pen/card drives and only those that don’t
boot on either a via EPIA CN1000eg at home and an HP PC at work. I have not tried this with harddrives.

Be aware that, when you write “bs=450”, you write :

  1. the boot code area
  2. the disk ID
  3. a part of the first partition entry
handle with caution ...

Using 3 ‘FF’ implies, you have a GPT (GUID-partition table) present on your disk (an EFI-System-partitioned" disk) …which seems not to be the case.
‘EF FF FF’ would be better for an Intel partitioned disk (a classic MBR).

But since your partition begins below the 1024th cylinder you shouldn’t use neither ‘EF FF FF’ nor ‘FF FF FF’.
It seems your partition begins at the address ‘40 00 00 00’ (LBA-little indian), that is to say, the 0x00000040th sector.
If you compute the CHS address you get ‘01 01 00’ (the correct value)

Yet it is obvious!
8-(

Tks, I couldn’t find much info on those 3 bytes, I guess that different bios’ would interpret them differently.

(btw, since CHS sectors start from 1,
‘40’ is the hex of lba sector 64 which is the 65th sector.
With 63 sectors/track, this would be the 2nd head (head 01) and 2nd sector (02)
on cyliner 0 (00), making bits “01 02 00”.)