Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (No Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (No Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12th April 2012, 04:03 AM
axel2078 Offline
Registered User
 
Join Date: Jun 2010
Location: Fairview Heights, IL
Posts: 74
linuxchrome
Fedora 16 - easy grub2 update

I found online that a convenient way of updating grub2 without knowing the rather long command is to create a shorter alias to it. The command to update grub2 is
Code:
grub2-mkconfig -o /boot/grub2/grub.cfg
To make a global alias that is persistent after reboot, you can do this:

as root, open up /etc/bashrc like so

Code:
vi /etc/bashrc
Then, go to the end of the file and insert this line:

Code:
alias update-grub='grub2-mkconfig -o /boot/grub2/grub.cfg'
In theory, this change should be persistent after reboot and you should now be able to update grub by running update-grub as root or via sudo if you are in the sudoers file. However, this did NOT work for me, so this is what I did:

I created a file in /sbin called update-grub. I used vi but you can use whatever editor you want. Then I coded the file like so:
Code:
#!/bin/bash
# Custom file written to update grub - kpt

grub2-mkconfig -o /boot/grub2/grub.cfg
Then, I just did a chmod 750 on the file. Since /sbin is in root's path, I can invoke the command just by doing
Code:
sudo update-grub
I don't know why the alias trick didn't work, but this one definitely does.
Reply With Quote
  #2  
Old 12th April 2012, 04:46 AM
secipolla Offline
Registered User
 
Join Date: May 2011
Posts: 700
linuxfirefox
Re: Fedora 16 - easy grub2 update

Interesting. I remember for some time now all bash aliases I set didn't work (when using Debian too). I think I tried for update-grub too (in /root/.bashrc) and it didn't work.
I made a script like yours in /usr/local/bin but the issue I have is that I sometimes have to try two or three times for the console to run it (like opening other root bash sessions), usually two.
Reply With Quote
  #3  
Old 12th April 2012, 03:28 PM
axel2078 Offline
Registered User
 
Join Date: Jun 2010
Location: Fairview Heights, IL
Posts: 74
windows_xp_2003firefox
Re: Fedora 16 - easy grub2 update

Quote:
Originally Posted by secipolla View Post
Interesting. I remember for some time now all bash aliases I set didn't work (when using Debian too). I think I tried for update-grub too (in /root/.bashrc) and it didn't work.
I made a script like yours in /usr/local/bin but the issue I have is that I sometimes have to try two or three times for the console to run it (like opening other root bash sessions), usually two.
I haven't had this problem. Make sure you put your script somewhere in root's search path, but I'm pretty sure /usr/local/bin is. If you add yourself to the /etc/sudoer's file, you should just be able to
Code:
sudo update-grub
Reply With Quote
  #4  
Old 17th April 2012, 04:15 PM
secipolla Offline
Registered User
 
Join Date: May 2011
Posts: 700
linuxfirefox
Re: Fedora 16 - easy grub2 update

Here's how I 'solved' it and maybe it's the 'proper' way of doing it (although a custom script should have worked properly as well):

Create /etc/profile.d/update-grub.sh with just this in it:
Code:
alias update-grub='grub2-mkconfig -o /boot/grub2/grub.cfg'
(I don't know how to make it available in the same session, but in a next session it works)
Reply With Quote
  #5  
Old 17th April 2012, 06:35 PM
sea Online
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Confoederatio Helvetica (Swissh)
Age: 34
Posts: 3,624
linuxfedorafirefox
Re: Fedora 16 - easy grub2 update

Why not invoke the sudo command to the alias itself?
Like:
Code:
alias upd-grb2="sudo grub2-mkconfig -o /boot/grub2/grub.cfg"
... and place that alias in /etc/bashrc ?

EDIT:
Note to above post, placing a script in /etc/profile.d is a damm good way to slow down your operations
Those script gets called upon every console window opening, nbew console tab, login, logout.. etc.. bet you got the picture now
__________________
Laptop: Toshiba satellite p50-a-11 CPU: Intel i7 8*2400 MHz GPU: GeForce GT 745M RAM: 8192 MB Distro: Fedora (Rawhide) DE: Awesome
Guide: Windows 8+ & Fedora 20+ Dualboot
Repo (sea-devel) :: Text User Interface (TUI), Video Handler Script (VHS), efi-helper, grub2-circled-nasa-themes, Essentials (blame, p, rmtf, rnd, siggen, screenshot...), (BETA) Dev-Scripts, (BETA) Fedora Account Scripts (FAS)

Last edited by sea; 17th April 2012 at 06:37 PM.
Reply With Quote
  #6  
Old 17th April 2012, 07:23 PM
secipolla Offline
Registered User
 
Join Date: May 2011
Posts: 700
linuxfirefox
Re: Fedora 16 - easy grub2 update

Hi, sea.
Regarding the sudo thing, I don't use it.
I said that that could be the 'proper' way of doing it based on what I read on those files' headers. For instance, /etc/bashrc:
Code:
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
.
.
I see about the scripts being called, but I tried placing an alias in /root/.bashrc and IIRC it didn't work.
Reply With Quote
  #7  
Old 18th April 2012, 12:32 AM
sea Online
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Confoederatio Helvetica (Swissh)
Age: 34
Posts: 3,624
linuxfedorafirefox
Re: Fedora 16 - easy grub2 update

To place scripts in /etc/profile.d is only a good idea, if those scripts contain variables only.
If they contain actions, its the worst location to place them.

But you're right, the 'saver' way to place an alias, could be by writing the alias to a custom.sh which will be placed in /etc/profile.d.

Aliases placed in /root/.bashrc are only loaded if you 'login' (su) to root.
AFAIK, alias' in that file, will be available only if you had loged into su/root.

Late note....
Oh darn, i havent seen you wrote an alias too.. thought you execute the command with that file.. my bad.
__________________
Laptop: Toshiba satellite p50-a-11 CPU: Intel i7 8*2400 MHz GPU: GeForce GT 745M RAM: 8192 MB Distro: Fedora (Rawhide) DE: Awesome
Guide: Windows 8+ & Fedora 20+ Dualboot
Repo (sea-devel) :: Text User Interface (TUI), Video Handler Script (VHS), efi-helper, grub2-circled-nasa-themes, Essentials (blame, p, rmtf, rnd, siggen, screenshot...), (BETA) Dev-Scripts, (BETA) Fedora Account Scripts (FAS)
Reply With Quote
  #8  
Old 18th April 2012, 01:04 AM
glennzo Online
Un-Retired Administrator
 
Join Date: Mar 2004
Location: Salem, Mass USA
Age: 57
Posts: 14,813
linuxfirefox
Re: Fedora 16 - easy grub2 update

There is no reason an alias in your home .bashrc file wont work. I use several aliases in mine. Make sure you are in your home folder with the pwd command
PHP Code:
[glenn@b-satellite17 ~>$ pwd
/home/glenn 
Edit the .bashrc file.
Code:
vi .basrc  < --- Don't overlook the dot before the word bashrc
alias fuzzbomb='sudo grub2-mkconfig -o /boot/grub2/grub.cfg'
Save and exit. Source the file so the alias will be recognized.
PHP Code:
source ~/.bashrc 
Try the alias
PHP Code:
fuzzbomb
<password
Should work just fine.
__________________
Glenn
The Bassinator © ®

[SIGPIC][/SIGPIC]
Laptop: Just a couple of old single core units
Desktop: BioStar MCP6PB M2+ / AMD Phenom 9750 Quad Core / 4GB / Kingston HyperX 3K SSD 240GB SATA 3.0 / 1TB SATA / EVGA GeForce 8400 GS 1GB
Reply With Quote
  #9  
Old 18th April 2012, 01:42 AM
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 6,199
linuxchrome
Re: Fedora 16 - easy grub2 update

Quote:
alias fuzzbomb='sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Quote:
Should work just fine.
No, not without adding the closing single quote it won't.
Reply With Quote
  #10  
Old 18th April 2012, 08:57 AM
glennzo Online
Un-Retired Administrator
 
Join Date: Mar 2004
Location: Salem, Mass USA
Age: 57
Posts: 14,813
linuxfirefox
Re: Fedora 16 - easy grub2 update

Dang. I saw that I missed that when I was writing the reply and still didn't add it. That's what you get for sitting in front of the TV with the laptop. Lack of attention to one or the other.

Interesting. When I just edited the post the single quote was there but it wasn't being displayed. Changed the PHP tags to CODE tags and it appears.
__________________
Glenn
The Bassinator © ®

[SIGPIC][/SIGPIC]
Laptop: Just a couple of old single core units
Desktop: BioStar MCP6PB M2+ / AMD Phenom 9750 Quad Core / 4GB / Kingston HyperX 3K SSD 240GB SATA 3.0 / 1TB SATA / EVGA GeForce 8400 GS 1GB
Reply With Quote
Reply

Tags
easy, fedora, grub2, update

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Grub2, dev modifications from satndard grub2 install jakebpg Using Fedora 16 9th March 2012 09:39 AM
Easy question: yum update on FC6-x86_64 pescobar Installation, Upgrades and Live Media 1 24th December 2006 01:18 AM
The quick and easy way to update to firefox 1.5 agentsmith23 Using Fedora 6 20th January 2006 09:52 AM
Easy to update from fc2 to fc3? Knappen EOL (End Of Life) Versions 6 27th September 2004 01:52 PM


Current GMT-time: 01:38 (Thursday, 27-11-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Huntington Park Travel Photos on Instagram - Puerto Colombia Travel Photos on Instagram - Bordj el Kiffan Photos