LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   Installing grub on /dev/sdb or /dev/sdc (https://www.linuxquestions.org/questions/ubuntu-63/installing-grub-on-dev-sdb-or-dev-sdc-741064/)

Skaperen 07-18-2009 04:20 PM

Installing grub on /dev/sdb or /dev/sdc
 
When I install Ubuntu to /dev/sda, all works well. However, when I install Ubuntu to an SD card on /dev/sdb or a USB memory key on /dev/sdc, it still puts GRUB on /dev/sda. I didn't see any option to change that. What's really annoying is /dev/sda becomes unbootable unless /dev/sdb or /dev/sdc is present after that is done. I can fix /dev/sda. But it doesn't accomplish the real goal which is to make /dev/sdb and /dev/sdc independently bootable even when /dev/sda is wiped to binary zero (or otherwise corrupt, or contains something else like Windows).

So how can I get Ubuntu to (1) do NOT touch /dev/sda at all, even if it thinks it sees GRUB already there, and (2) install everything, including GRUB, onto the target device (/dev/sdb or /dev/sdc)?

I know the details of how to do this, and could do it by manually copying data around, etc. I've done such things in Slackware. But I want to do this in Ubuntu AND use Ubuntu's installation tools exclusively. I know I can cheat, after the fact, but that's not what I'm looking for.

linus72 07-18-2009 04:33 PM

Alright
The way I did this is I unhooked my hardrive from motherboard

I booted up the ubuntu livecd
at desktop I inserted clean ext3 4gb usb
and opened nautilus as root
sudo nautilus

the usb automounted and I then created a boot/grub folders
mkdir -p /media/disk/boot/grub
and installed grub to usb, recognized as only hd by grub

grub-install --root-directory=/media/disk /dev/sda

it sees my usb as sda, with hd hooked up it would say sdb

then, to make sure, get the grub prompt
grub
root (hd0,0)
setup (hd0)
quit

yeah, now it's simmering:)

that's it

What's the Bonus of this little cheat??
Grub will always think it's booting the first hd
thus even on a pc/lappy that won't boot from usb
will be able to on most if you use plop bootmanager

on pc's that boot from usb it will again be reconized first and booted 1st

NOTE: when I did this on my HP PC, if I had my bios set to boot from floppy or cd
before hd, I would get a grub error when booting usb

if the bios was set to boot hd 1st, cdrom second, the usb boots right?

so, but if that's cheating I'll do it:)

scottro11 07-18-2009 06:11 PM

Note that in an Ubuntu installation, in the very last screen before installation begins, there's a little button on the lower right, marked Advanced. It gives you the opportunity to install grub somewhere else (and probably to further configure it, I'm not sure.)

If you already knew that, I apologize, but looking at the first post, it seems as if you may have, as I did the first couple of times playing with it, overlooked it.

Skaperen 07-18-2009 07:24 PM

If I unhook the harddrive, then the SD card will be sda, and if anything in the installation configured stuff to look for stuff in sda, then it won't be doing as intended. I want the SD card to work as sdb, and for everything that might be hard configured to the device node name to do so for sdb and not sda. That way I can put in the SD card and boot from it without accessing sda other than to see what's on it (and elsewhere, to defeat automounting it). Ideally, the only hard part is finding partitions to mount. That should be done by labels or UUID. Then everything else finds stuff by paths which will be as expected when the mounts are right.

linus72 07-18-2009 07:45 PM

OH, sorry for not re-iterating

once you hook the hd back up and rweboot
the usb will be recognized by YOUR pc as sdb1, etc
not sda

you see, we're tricking grub, not the pc

grub thinks it's 1st hd, doesn't matter sda, hda, etc


example, right now I'm running from my usb on fedora 11 persistent
and my pc sees the usb as sdb1
grub thinks it's first hd

only problem you will have is if you try to boot 1st hd from usb
you'll just reboot into the usb

meaning the only limitation it has is that you will have issues trying to
boot your hd from the sd card, which most people don't care about anyway

just try it dude an you'll see
I got 5 computers in all
3 won't boot from usb
all will boot the ext3 usb with grub
the 3 I have to use plop bootmanager cd, usb, or floppy

look here's my menu.lst and otuput of fdisk -l for usb

Code:

Disk /dev/sdb: 4045 MB, 4045930496 bytes
255 heads, 63 sectors/track, 491 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0005318e

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1  *          1        491    3943926  83  Linux

menu.lst
Code:

title Xtras - Menu
root (hd0,0)
configfile /boot/grub/xtras-menu.lst

title Super Grub DisK
root (hd0,0)
kernel /boot/syslinux/memdisk
initrd /boot/sgd/sgd.gz

title zorOS-3.6 IDE
root (hd0,0)
kernel /boot/syslinux/linuz TOOLSLANG=1 initrd=/boot/syslinux/full.img vga=788 load_ramdisk=1 ramdisk_size=53248 prompt_ramdisk=0 rw root=/dev/ram rootfstype=ext2 apm=off
initrd /boot/syslinux/full.img

title zorOS-3.6 SATA
root (hd0,0)
kernel /boot/syslinux/linuz TOOLSLANG=1 initrd=/syslinux/full.img vga=788 load_ramdisk=1 ramdisk_size=53248 prompt_ramdisk=0 rw root=/dev/ram rootfstype=ext2 apm=off libata.atapi_enabled=1 ide0=noprobe ide1=noprobe
initrd /boot/syslinux/full.img

title Grub bootloader - USB-Menu
root (hd0,0)
configfile /boot/grub/usb/grub-menu.lst

title Grub4DOS USB-Menu
root (hd0,0)
configfile /boot/grub/usb/usb-menu.lst

title PLOP Bootmanager USB
root (hd0,0)
kernel /boot/plpbt

title SystemRescueCD-1.2.2 - Menu
root (hd0,0)
configfile /boot/grub/sysrescue-menu.lst

title Fedora 11 Live
root (hd0,0)
configfile /boot/grub/fed-menu.lst

title Clonezilla Live 2009-jaunty
root (hd0,0)
configfile /live/clonez-menu.lst

title Sidux-2009-02
root (hd0,0)
configfile /boot/grub/sidux-menu.lst

title Mini-PartedMagic
root (hd0,0)
kernel /minipm/bzImage root=/dev/ram0 init=/linuxrc ramdisk_size=100000 vga=791
initrd /minipm/initrd

title PartedMagic - USB-Menu
root (hd0,0)
configfile /boot/grub/usb/pmagic-menu.lst

title ClamAV Anti-Virus LiveUSB
root (hd0,0)
configfile /boot/grub/usb/clamusb-menu.lst

title TinyCore_2.1 with JWM USB-Menu
root (hd0,0)
configfile /boot/grub/usb/tc-menu.lst

title RescuePuppy49 USB-Menu
root (hd0,0)
configfile /boot/grub/usb/pupusb-menu.lst

title NetbootCD 3.1.2 USB Net-install a Major Distro
root (hd0,0)
kernel /boot/kexec.bzI quiet base norestore nolocal waitusb=5
initrd /boot/nbinit3.gz

so, I don't see why it won't work on yours?


All times are GMT -5. The time now is 03:22 PM.