LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-30-2015, 09:56 AM   #1
sumeet inani
Member
 
Registered: Oct 2008
Posts: 902
Blog Entries: 26

Rep: Reputation: 49
installing grub2 on usb stick


hi ,
I have used legacy grub with ease .
Just edit /boot/grub/menu.lst manually and add/delete entries in bootloader .
Plain and simple .
The thing I like about grub2 is its fancy features at the cost of complexity .

My question
Now I want to install grub2 on USB stick and boot from it.
Actually I want just a single entry on my grub2 menu of USB stick

menuentry "Tiny Core 6.3" {
set root=(hd0,2)
linux /boot/vmlinuz63 waitusb=10 loop.max_loop=256
initrd /boot/core63.gz
}

My USB stick has 2 primary partitions - first fat32 of 10GB and second ext2 of 4GB .
ext2 partition will have boot folder containing linux and initrd files .

How should I proceed ?

Last edited by sumeet inani; 12-30-2015 at 09:57 AM. Reason: clarification
 
Old 12-30-2015, 10:52 AM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 8,150

Rep: Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624
Do you have a CD/DVD or flash drive with an OS containing Grub2? Take a look at the link below which explains installing from a Live CD or using chroot.

https://help.ubuntu.com/community/Gr...iveCD_terminal
 
Old 12-31-2015, 12:08 AM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 18,634

Rep: Reputation: 2789Reputation: 2789Reputation: 2789Reputation: 2789Reputation: 2789Reputation: 2789Reputation: 2789Reputation: 2789Reputation: 2789Reputation: 2789Reputation: 2789
For the most part, you install grub2 to a usb just as if it were an internal hard drive.

Might see if this page leads you to a solution maybe. https://askubuntu.com/questions/4658...grub-not-found
 
Old 01-02-2016, 08:26 AM   #4
sumeet inani
Member
 
Registered: Oct 2008
Posts: 902

Original Poster
Blog Entries: 26

Rep: Reputation: 49
To jefro
Your link is for legacy grub .

To yancek ,
i have a computer with backtrack (latest version called kali) installed . It is ubuntu based distro .
First I created /mnt/sdb2/etc/grub.d/41_tc (permission 777) file containing
My /mnt/sdb2 already has boot folder containing vmlinuz63 and core63.gz .
Code:
#!/bin/sh -e
echo "Adding tiny core Linux to GRUB 2"
cat << EOF
menuentry "Tiny Core 6.3" {
set root=(hd0,2)
linux /boot/vmlinuz63 waitusb=10 loop.max_loop=256
initrd /boot/core63.gz
}
EOF
I ran following command
#grub-install --root-directory=/mnt/sdb2/ /dev/sdb
Installation finished. No error reported.

Now the issue is
It created /mnt/sdb2/boot/grub folder containing a lot of files .
But no grub.cfg .

Now pendrive boots me to a prompt as follows
[log]
GNU grub version 1.98 -1ubuntu 13
minimal bash-like editing is supported .For the first word , TAB lists possible command completions , Anywhere else tab lists possible device or file completions.
grub>
[/log]

https://www.gnu.org/software/grub/ma...2dinstall.html tells me that grub-install is a script that uses grub-mkimage and grub-setup commands .
grub-mkimage help tells me that it uses images and modules of /usr/lib/grub/i386-pc by default .

I am beginning to think that scripts from grub.d are useful only in update-grub .
grub-mkconfig can make grub.cfg file but cannot be pointed to any device (like my removable usb) .

http://ubuntuguide.net/how-to-restor...ble-hard-drive offers hope.

Last edited by sumeet inani; 01-02-2016 at 09:14 AM. Reason: more
 
Old 01-02-2016, 08:53 AM   #5
colorpurple21859
Senior Member
 
Registered: Jan 2008
Location: florida panhandle
Distribution: slackware64-current, puppy, ubuntu
Posts: 2,507

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
you can create a /boot/grub/grub.cfg manually with any text editor and use your entry from above.
I have done this before and had to add insmod all_video at the beginning of the file for it work on my laptop so there may be someother options that will have to add to work like maybe insmod usb
 
Old 01-02-2016, 09:05 AM   #6
sumeet inani
Member
 
Registered: Oct 2008
Posts: 902

Original Poster
Blog Entries: 26

Rep: Reputation: 49
to colorpurple21859 ,
I used to do that earlier . I copied grub.cfg from installed OS then removed all irrelevant #BEGIN...#END entries . But grub2 is not manual editing friendly .
Here is my grub.cfg automatically generated (no significant change from script I provided , i would have arrived at same by manual editing as you suggested)
NOTE - /mnt/sdb2 (quoted for clarity) , i told above was actually /media/4gb .
Code:
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /media/4gb/etc/grub.d and settings from /media/4gb/etc/default/grub
#

### BEGIN /media/4gb/etc/grub.d/41_tc ###
Adding tiny core Linux to GRUB 2
menuentry "Tiny Core 6.3" {
set root=(hd0,2)
linux /boot/vmlinuz63 waitusb=10 loop.max_loop=256
initrd /boot/core63.gz
}
### END /media/4gb/etc/grub.d/41_tc ###
Here is the solution (with inputs from http://ubuntuguide.net/how-to-restor...ble-hard-drive)
Code:
#grub-install --root-directory=<mount-point-of-usb-stick-partition> <usb-stick-device>
edit /usr/sbin/grub-mkconfig and point sysconfdir to etc folder on above mountpoint
#grub-mkconfig -o  <mount-point-of-usb-stick-partition>/boot/grub/grub.cfg
Question SOLVED .
Thanks everyone .

Last edited by sumeet inani; 01-02-2016 at 09:14 AM. Reason: final clarification
 
  


Reply

Tags
grub2, install, liveusb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Grub2 on usb stick drimades Linux From Scratch 31 10-15-2012 11:34 AM
How to boot from an USB stick without BIOS support using Grub2? vimico Linux - Laptop and Netbook 11 02-25-2012 06:19 PM
Booting a USB stick with GRUB2 and Labels ljones0 Slackware 1 02-14-2011 08:53 PM
[SOLVED] Create independent Grub2 boot loader menu in USB stick. cr4321 Linux - General 27 07-18-2010 01:48 PM
Grub2 (1.96) loopback problem on usb-stick ganimo Linux - General 4 10-01-2009 08:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration