How to install Grub to a USB memory device

Asked by LEGOManiac

I have a microSD card installed in a USB dongle. I want to install Grub (and only Grub) to it.

When the card is inserted in the PC, Ubuntu sees it and can read and write files to it so I know Ubuntu can access it.

Looking at /etc/fstab:

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/sda1
UUID=5304a540-91fb-49f0-a8be-26a33e20d2e2 / ext3 relatime,errors=remount-ro 0 1
# /dev/sda5
UUID=91cdd2d1-0c44-fbb5-450f-90f939fb37d2 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0

I don't see anything that corresponds to the USB memory.

As I pasted that I just noticed the first comment line saying "static file system information" and I wonder if that's part of my problem; removable media wouldn't be considered static, would it? Then again, the CDRom IS listed.

I suspect I'm not looking in the right place.

Looking at "System->Administration->Create a USB startup disk", under "USB disk to use" it says my USB memory is "/dev/sdf1"

Looking at "Applications->System Tools->KGRUBEditor" then clicking on "tools->View Devices Info" it says my USB memory is "/dev/sdf1" so I'm guessing I'm on the right track.
Also within KGRUBEditor if I click on "Tools->Install/Restore GRUB" then select "Install GRUB on a Hard Disk Drive/Partition" I then get to choose where I want to install GRUB. The "Suggestions" button lists "/dev/sdf" as a location to install GRUB to but if I enter "/dev/sdf" "/dev/sdf0" or "/dev/sdf1" as the installation location I get the following error:

"grub-install returned unknown exit code 1. An error could have occured"

"unknown exit code 1" sounds like one of those pointless, non-descript error messages Windows is famous for.

Running GRUB from a console, any reference I make to "sdf", "sdf0" or "sdf1" returns "Error while parsing number".

Can anyone tell me how to do this correctly?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub-installer Edit question
Assignee:
No assignee Edit question
Solved by:
Sam_
Solved:
Last query:
Last reply:
Revision history for this message
Joker Wild (lajjr-deactivatedaccount) said :
#1

I would like to help you out. I need a little more info....Ok you want it to have grub on it right? My question is? Is this, when you want it installed on there do you want it to be your boot or do you want Gnu/Linux Ubuntu on it to?

boot= to allow you to use to choose different drives etc.

Revision history for this message
Tom (tom6) said :
#2

I think he just wants grub there without any OS

SliTaz installs it's full OS to fill a 100Mb space but the Grub part of that is much smaller. On a Usb stick even just 100Mb means a lot.
http://distrowatch.com/table.php?distribution=slitaz

Revision history for this message
LEGOManiac (bzflaglegomaniac) said :
#3

Exactly Tom, thanks. I am just looking for Grub to be on the memory by itself.

I was able to achieve this by installing Ubuntu to an unused PC and, while selecting the installation options, selecting Grub to be installed to a memory stick while the OS went onto the hard disk. This worked successfully, so it's obviously possible but I can't figure out how to do it without installing a full OS on a spare disk.

I'm pretty sure one *should* be able to do it with either KGRUBEditor or the GRUB command itself but I can't figure it out.

Revision history for this message
Joker Wild (lajjr-deactivatedaccount) said :
#4

pretty to do but what do you want it to do later down the road.

My brother has a hp laptop I made him a grub stick to make his second drive secret.

Vista says there is only one. He puts in the grub stick with a grub a small script it allows him to boot from the second drive only with Back track. But it can be anything is that what might be the course here?

Revision history for this message
LEGOManiac (bzflaglegomaniac) said :
#5

Essentially, yes.

Revision history for this message
Tom (tom6) said :
#6

@ Leo
i think your brothers way has the Vista disk as the Master drive? So either he has changed the MBR on the Vista drive or else he physically reconnects the drives so that his second drive becomes master?

Revision history for this message
LEGOManiac (bzflaglegomaniac) said :
#7

Tom:

Just an FYI. The master/slave relationship applies to Parallel ATA (PATA) drives where two drives can share the same ribbon cable. The master/slave jumper trick would work there. The computer in question here is strictly SATA (Serial ATA) where there is only 1 cable per drive and no Master/Slave/CS jumper. I haven't experimented with it yet, but I suspect that the SATA ports are polled sequentially for drives and the "first" drive is the one on the first non-empty SATA channel.

Don't quote me on that. It's based on my observation that Ubuntu's installation CD, when told to boot from the "first" hard disk will boot Vista on my system if the drive is in the first drive bay and Ubuntu if the first bay is empty.

Revision history for this message
LEGOManiac (bzflaglegomaniac) said :
#8

As much as anything else, this is a learning exercise for me.

I have already installed GRUB on two microSD cards and booted the laptop. One card is on my keychain and the other is in my phone. I've done it this way because I don't want to lose the ability to access Ubuntu if the first hard disk crashes, or for some reason the boot sector gets overwritten.

What bother's me is that the only way I could get GRUB onto the microDS cards was to install an OS on a spare PC and specify that GRUB should be installed on a separate device. This at least proved to me that it could be done.

I'm sure there has got to be an easier, faster and more direct way to install GRUB on a USB device and that's what I'm trying to learn.

Revision history for this message
Joker Wild (lajjr-deactivatedaccount) said :
#9

Tom,

To answer your question...

My brother's computer boots into vista only no other drive found unless you go the disk management. Then of course it sees it.

My brother works for a IT firm they use the laptops to test networks I supplied him with this option and it is on a USB thumb drive to boot from second disk.

He was told he can have Backtrack 3 disk and use it, but hated to keep update the live disk and on shutdown all info gone.

I told him to make it a dual boot or put to thumb drive, but he wanted to be different.

Revision history for this message
Tom (tom6) said :
#10
Revision history for this message
LEGOManiac (bzflaglegomaniac) said :
#11

Leo,

>My brother works for a IT firm they use the laptops to test networks I supplied him with this option and it is on a USB thumb drive to boot from second disk.

It sounds like you've already done what I"ve just started doing. The problem is my method of getting GRUB on the thumb drive was very inefficient.

Care to fill me in on how you did it?

Revision history for this message
Joker Wild (lajjr-deactivatedaccount) said :
#12

Ok I will walk you through what I did, but I need some info again sorry.

1. Is the usb SD disk(card) used for anything else?
2. Does the usb SD have space left and how much?
3. Is it the only thing will be on it. Or is there other stuff on?

Revision history for this message
Best Sam_ (and-sam) said :
#13
Revision history for this message
LEGOManiac (bzflaglegomaniac) said :
#14

<smack!> <smack!> (the sound of me slapping myself)

I've been forgetting to type "sudu" before "grub"!

Thanks Sam for, pointing me in the right direction. I had to see it in print. I've visited other sites where I followed the same instructions for actually using GRUB but they were obviously assuming I knew the type "sudo" first or that I was logging in as root.

I knew it was easy to do. For anyone down the road who's looking through the trouble tickets looking for the same solution, it's:

sudu grub

root (hd2,0)

setup (hd2)

quit

Thanks a million Sam.

Leo: with the commands shown above, it pretty much doesn't matter what you have on the drive since the space required for GRUB is very minimal.

Revision history for this message
LEGOManiac (bzflaglegomaniac) said :
#15

Thanks Sam, that solved my question.

Revision history for this message
Joker Wild (lajjr-deactivatedaccount) said :
#16

LegoManiac,

Hehehe lol. I placed that on ticket #59481 of yours..funny. kewl glad you got it working...

sudo grub