Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

USB drive boot manager

Name: Anonymous 2012-07-13 20:00

Hi /prog/

I have windows installed to one HDD, and *nix to another. ATM i use the BIOS to switch between drives at boot. This is because I want each drive to remain bootable on its own [eg if i brick one of the two OSes]. Obviously this isn't very efficient.

I'd like to have a boot manager installed on a USB drive to select between which to boot, but I want to avoid doing anything that modifies the drives so that they become unbootable without the USB stick either.

Can you point me in the direction of some software that can do this? I've looked at Plop, YUMI, GRUB and LILO but i'm not really sure which best suits my needs, and if its possible to use them in the way i describe [from USB stick, with USB keyboard and without modifying their MBR etc].

Name: Anonymous 2012-07-13 20:01

SICP chapter 3.

Name: Anonymous 2012-07-13 20:05

Make a bootsector that performs the following:
— Ask which drive to boot.
— Relocate the next part of itself elsewhere in memory.
— Load the chosen MBR into 0:7c00 and jump there.

Name: Anonymous 2012-07-13 20:06

RELOCATE MY ANUS

Name: Anonymous 2012-07-13 20:23

>>3
thanks but I'm not really trying/able to make this myself yet; I came here because /g/ is pretty terrible at helping with this kind of thing. I would have imagined that there was software out there to do this already, or that the software I listed could be used in this way.

Again my main concern is that the HD's remain bootable when the USB stick is removed.

Name: Anonymous 2012-07-13 21:08

>>5
Why don't you just configure the bootloader in the *nix partition to boot everything?

Name: Anonymous 2012-07-13 21:15

BOOT DRIVE MY ANUS

Name: Anonymous 2012-07-13 21:25

>>6
I'd rather keep the bootloader separate from any specific OS/hard drive. for example, if i have to remove the *nix drive and put in a win XP drive, I'd have to go back to using the BIOS to select the boot device.

Name: Anonymous 2012-07-13 22:00

Grub can chainload into another drive.

Set the bios to always boot from the *nix drive, and have an option (with e.g. a 5-second timeout) in grub to chainload into the other drive.

Name: Anonymous 2012-07-13 22:18

>>9
Thanks, this is the closest to what I'm looking for so far, but as I said I'd rather not have the boot manager on any particular hard drive.

Presumably I can acheive the same result by putting some tiny lunix distro on the USB drive though?

Name: Anonymous 2012-07-13 22:27

>>10
You can use a dedicated grub partition and chainload. You don't need more than 8MB. That's what I do to boot different linux distributions.

Name: Anonymous 2012-07-13 22:38

>>11

Ok thanks, that sounds pretty much like what I want (the usb stick is only 16mb). Assume I'm your average /g/tard though and that my knowledge of technology is limited to hating on other peoples choice of operating system, what are the steps i need to perform?

I'm going to guess that first is to make the USB stick bootable?
then install grub to it?
then configure grub?
finally set BIOS to boot USB stick first?

Name: Anonymous 2012-07-13 22:51

>>12
I think you'll find many guides by googling "dedicated grub partition" and "grub chainload".
The steps you described are pretty much all you need to do. Oh and don't use GRUB 2 for that.

Name: Anonymous 2012-07-13 23:01

Name: >>14 2012-07-13 23:01

Disclaimer: I fucking love syslinux.

Name: Anonymous 2012-07-13 23:04

>>12
But it might be too much of a hassle for your particular needs.
You could just default boot on the linux HD with the multiboot properly configured. (I think Windows has to be chainloaded anyway).
If the linux HD dies, the second disk will be booted. Windows is not aware of a multiboot. I did that exact configuration for a friend.

Name: Anonymous 2012-07-13 23:31

>>16
I was just looking into SYSLINUX as it happens; as with grub its not exactly super-easy and filled with disconcerting caveats on every other line. Still, if its not hard its not worth doing (apparently).

I considered what you describe with the *nix drive, but again, the situation I'm concerned about is when I have to remove the drive with the bootloader. then I'm back to having to use the BIOS (eg if i want to choose between 2 windows drives). If anything what I want is to be able to remove the USB [boot manager] drive so I can go back to using the BIOS to select boot device in worst case scenario without any HD being unbootable.

>>13
Thanks, I've been doing some searching along those lines for a little while, unfortunately as with most *nix topics, the assumption is that I have been using it all my life and that its not as easy as one wrong command to brick everything. I've used it a little in VMs (mostly backtrack and k/ubuntu) but this is the first time I've installed it (PC-BSD) properly.

I'll do some more searching and post anything useful/confusing as it arises I guess.

Name: Anonymous 2012-07-13 23:37

Name: Anonymous 2012-07-13 23:39

for example I'm reading though this

http://www.troubleshooters.com/linux/grub/grubpartition.htm

it all pretty much makes sense up to the 'Making it happen at boot time' section. i take it have to do things a bit differently here, because the MBR the author refers to in my case would be the MBR of the USB drive, correct?.

I'm also a bit confuse by the whole 'adding a new distro' part.

>Booted into the latest distro, signed in as root, it would go something like this:
>steps

my other distro is windows?

Name: Anonymous 2012-07-14 0:04

>>19
the MBR the author refers to in my case would be the MBR of the USB drive, correct?.
Yes.

I'm also a bit confuse by the whole 'adding a new distro' part.
Don't be confused. The guys wants to show off because he just learned basic vi commands. It's just a textfile to edit.

Here's mine:
# (0) Arch Linux
title Arch Linux
rootnoverify (hd0,4)
chainloader +1

# (2) Windows 7
title Windows 7
rootnoverify (hd0,1)
makeactive
chainloader +1

# (3) FreeBSD
title FreeBSD
rootnoverify (hd0,2)
chainloader +1

# (4) Ubuntu/OpenGenera
title OpenGenera
root (hd0,7)
kernel  /vmlinuz root=/dev/sda8
initrd /initrd.img

In your case you will have hd0 and hd1.

Name: Anonymous 2012-07-14 1:24

Ok thanks, now before i can get round to making the menu.lst file, i actually need to install grub to the USB stick. However i'm using PC-BSD (the ubuntu equivalent of Free-BSD), so the grub-install command doesn't work, i assume because PC-BSD doesnt use GRUB.

So i went to the grub website, and downloaded version 1.99 (as earlier post suggested this would be sufficient/more appropriate), but i'm not sure how to install it to the USB drive; I get the impression that just extracting the contents of the archive to the drive isn't going to be enough, so can i do this?

Name: Anonymous 2012-07-14 1:36

ok so i installed grub2 to my BSD using pkg_add -r grub2

seems to have gone ok



then I ran

sudo grub-install --recheck --root-directory=/media/12MB /dev/da0s1

and got:
/usr/local/sbin/grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR.  This is a BAD idea..
/usr/local/sbin/grub-setup: warn: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and its use is discouraged..
/usr/local/sbin/grub-setup: error: if you really want blocklists, use --force.


most instruction show something along the lines of 'root-directory=/mnt/usb' but /mnt/ is empty on my system.

Name: Anonymous 2012-07-14 1:57

I used the --force option and it seems to have created the /boot/ folder and /grub/ folder within this, but it still complains that

/usr/local/sbin/grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR.  This is a BAD idea..

however it also says

Installation finished. No error reported.

I can see why people prefer grub1, the .cfg file for grub2 seems unnecessarily complex for this task.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2012-07-14 7:35

It'll probably take you less than an hour to learn how to write your own chainloader. All it has to do is relocate itself, wait for a key to be pressed, and load the first sector of the appropriate drive and jump into it. Any existing solutions are going to be much more than you need.

Name: Anonymous 2012-07-14 12:48

>>24
fuck off

Name: Anonymous 2012-07-14 12:51

>>1
Why not add a bootloader to both HDDs, with each bootloader knowing how to boot both OSes?

Name: OP 2012-07-15 6:30

Ok so i got bored of flogging a dead horse; i wiped PCBSD and installed unbuntu studio on half the disk. conveniently, unbuntu studio is polite enough to ask where you want the bootloader installed, so I installed it to the USB stick and pretty much got the effect I wanted (im not sure if unbuntu will boot without the USB stick in, but at this point i barely care).

then i re-installed PCBSD on the other half of the disk. but it doesnt show in grub at boot time (ubuntu still does though and boots ok), how do i go about adding it to the menu.lst? When I browse the USB stick it appears empty. I gather at boot I should be able to edit the menu from the grub> command line.
worst case I'll re-install ubuntu seeing as it ought to auto-detect PCBSD and add it to the grub menu, but thats pretty inefficient.

>>26
that slows down the boot time (which is already painfully long because my board has 2 different ACHI controllers it needs to initalise). Plus won't one of them pretty much be redundant/useless when I replace/insert a new disk?

>>24
you make it sound so easy. perhaps you'd like to show me how its done?


Also, what is the best way to access my nix partions (ufs and ext3) from windows? I noted that someone pointed out that 'then you loose all the linux security: everyone can access your (encrypted password), your (encrypted) ssh key'. Would it be better than to have a shared NTFS drive for data instead/only? What do YOU do?

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2012-07-15 7:41

>>27
Not tested, it's been a while since I worked with this stuff, but should print '?' and wait for you to press 0-3. It then tries to load the boot sector of the specified hard drive and runs it, printing an 'X' and waiting for you to try again indefinitely.


@h7c00
:start
 ; make sure we are executing at 0000:7c00
 jmpf h00007c05
 ; setup stack to 0000:7a00, right below relocated boot sector
 cli | xor ax ax | mov ss ax | mov sp h7a00 | sti
 ; make sure segment registers set correctly
 push cs | push cs | pop ds | pop es
 ; relocate to 7a00...
 mov si :stuborig | mov di :stubnew | mov cx 256 | rep movsw
 jmp h7a00 ; ... and continue there
:stuborig
@h7a00
:stubnew
 mov ax h0a3f | xor bx bx | mov cx 1 | int h10 ; write '?' prompt
:readloop
 mov ah 0 | int h16 ; wait for key
 cmp al h30 | jb :readloop | cmp al h33 | ja :readloop ; valid values: '0' ~ '3'
 ; prepare for read call
 add al h50 | xor dx dx | mov dl al | mov cx 1 | mov bx h7c00
 mov ax h0201 ; read from hard disk 0 ~ 3
 push dx      ; save dl
 int h13
 pop dx       ; restore dl to pass to chainloaded boot sector
 jnc h7c00 ; read successful, run new boot sector directly
 mov ax h0a5a | xor bx bx | mov cx 1 | int h10 ; write 'X' to indicate error
 jmp :readloop ; ...and try again
.pos 510
 dw haa55      ; MBR validation signature

Name: Anonymous 2012-07-15 12:15

>>28
wow ok thanks, thats a little above my head though; i'm guessing its assembly but i wouldn't know if it were AMD or AT&T, how to compile it or what to do with it afterwards (I sort of assumed the fact that I'm using PCBSD and ubuntu would have hinted at that ;P )

Name: Anonymous 2012-07-15 18:19

>>28
Interesting code, I don't think you can push/pop into segment registers and you may not be saving the driver Id but maybe I'm wrong

>>29
Your assembler should be as, the syntax is Intel (with a lot of spelling mistakes), after compiling it I guess you'd need to inflate it to fit a 512 byte sized boot sector with ld instructions such as
OUTPUT_FORMAT("binary")
OUTPUT_ARCH(i386:x86-64)
SECTIONS
{
   .start16 0x0000 : AT(0x10000) {
      start16.o (.text)
      start16.o (.rodata)
      start16.o (.data)
      . = NEXT(16);
   }
   .text   0x10000+SIZEOF(.start16) : AT(0x10000+SIZEOF(.start16)) { *(.text) }
   .rodata ALIGN(16) : { *(.rodata) }
   .data   ALIGN(16) : { *(.data) }
   .bss    ALIGN(16) : {
      __bss_start = .;
      *(.bss)
      *(COMMON)
      . = ALIGN(16);
      __bss_end = .;
   }
   __bss_quads = SIZEOF(.bss)>>3;
}

and finally to commit a lonely sector do the usb stick I can't help you with, ouch

Name: Anonymous 2012-07-15 18:21

>>30
wrong ld file ofc, silly me, here's the correct one:
OUTPUT_FORMAT("binary")
SECTIONS
{
  .vbr 0x7C00 : {
    *(.text)
    *(.rodata)
    *(.data)
    . = 510;
    SHORT(0xAA55)
  }
}

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2012-07-16 4:18

>>29
I was just giving an example. That's in ros16 format, a RosAsm derivative I used when I worked with that stuff. The idea isn't for you to copy, assemble, and use it directly, but to understand how it works and create your own.

>>30
See positions 06, 07, 0E, 0F, 16, 17, 1E, and 1F in the opcode map. I am not saving the drive number, if that's what you mean, because it doesn't matter from where this boot sector is loaded, only where it goes to. That's passed to the chainloaded boot sector as usual.

Name: Anonymous 2012-07-16 6:06

Check emo

Name: Anonymous 2012-07-16 9:29

hum and how do you go around copying the sector to the usb stick ?

Name: Anonymous 2012-07-16 9:30

>>34
Use dd (POSIX disk destroyer).

Name: Anonymous 2012-07-16 13:58

nasm or nothing.

Name: Anonymous 2012-07-16 17:41

>>36
*masm or nothing

Don't change these.
Name: Email:
Entire Thread Thread List