Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to automatically run a script after grub-install (using Grub2) if it's possible?

Some context. The script will simply run grub-install /dev/sda1, grub-install /dev/sdb1, grub-install /dev/sdc1 as I want all three EFI boot partitions in sync.

share|improve this question
grub-install is a shell script, just edit it – warl0ck Oct 20 '12 at 0:04
@warl0ck: I think it will get removed when an update of grub-install occurs. Which might very well be just when I need it. – Deleted Oct 22 '12 at 17:46

You can simply put grub-install along with these three commands in a file and add it somewhere in the PATH so that you can run it whenever you need to.

Alternatively alias grub-install in root's ~/.bashrc (depending on what shell root uses) to grub-install && grub-install /dev/sd{a,b,c}1

share|improve this answer
My main concern is when doing apt-get dist-upgrade, I want all three HDD's to get updated then. I don't think .bashrc is read when running commands through sudo. Creating a script and putting it somewhere on roots path also doesn't help, as it's not only when I run it I want to make sure all three HDD's are addressed. – Deleted Oct 20 '12 at 19:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.