LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 08:56 AM   #1
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908
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 08:57 AM. Reason: clarification
 
Old 12-30-2015, 09:52 AM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
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-30-2015, 11:08 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
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, 07:26 AM   #4
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908

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 08:14 AM. Reason: more
 
Old 01-02-2016, 07:53 AM   #5
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
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, 08:05 AM   #6
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908

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 08:14 AM. Reason: final clarification
 
  


Reply

Tags
grub2, install, liveusb



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 10:34 AM
How to boot from an USB stick without BIOS support using Grub2? vimico Linux - Laptop and Netbook 11 02-25-2012 05:19 PM
Booting a USB stick with GRUB2 and Labels ljones0 Slackware 1 02-14-2011 07:53 PM
[SOLVED] Create independent Grub2 boot loader menu in USB stick. cr4321 Linux - General 27 07-18-2010 12:48 PM
Grub2 (1.96) loopback problem on usb-stick ganimo Linux - General 4 10-01-2009 07:26 AM

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

All times are GMT -5. The time now is 06:09 AM.

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
Open Source Consulting | Domain Registration