SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2013-02-11 15:31:51

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Create your own GRUB2 rescue disk in a jiffy.

Copy following script to a directory in your PATH and make it executable.
e.g. name it rebuild-my-grub-iso

#!/bin/sh
set -e

wk_dir=$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")
mkdir -p ${wk_dir}/boot/grub

# copy your /boot/grub/grub.cfg file to the work dir
cp -v /boot/grub/grub.cfg ${wk_dir}/boot/grub

# run grub-mkrescue should create new image grub.iso in the current dir
grub-mkrescue --modules="ext2 lvm" -o ./grub.iso ${wk_dir}

rm -rf ${wk_dir}

cd to a dir of your choice and run the command
rebuild-my-grub-iso
It will create a file grub.iso in your current dir.

Copy the iso image to a CD-ROM or a thumbdrive using dd.

Boot from the CD-ROM or  the thumbdrive and... tada you get the same (more or less - you may be used to colors or a grub theme) GRUB menu as if you had booted from HD. It allows you to boot into your system of choice.

This works for me on a system with grub-pc version 1.99-27.
Should work for grub 2 versions too, and for efi systems, but I can not test that on my old rig.

Edit: Oh, and it works for LVM too.

Lots of grubbing fun...

Last edited by xaos52 (2013-02-11 15:32:48)

Offline

Be excellent to each other!

#2 2013-02-11 15:44:18

CBizgreat!
#! Die Hard
Registered: 2011-07-27
Posts: 1,865

Re: Create your own GRUB2 rescue disk in a jiffy.

As usual Professor ...

Always informative and interesting. Had need to just such a thing not too long ago. Settled for using super grub disk. Would've much preferred doing it the way you describe here though. Long babble short ... thanks and bookmarked for future emergencies. smile


Vll !

Last edited by CBizgreat! (2013-02-11 15:44:50)


Some common cbiz abbreviations. This will save me time and yet @ same time tell folks what the babble is supposed to mean.

Vll ! = ( Viva la gnu/Linux !)    Vl#!! = ( Viva la #! !)    Last but not least, UD ... OD ! = ( Use Debian ... or die !) tongue

Offline

#3 2013-02-11 18:52:15

dura
Bloated Gimp
From: interzone
Registered: 2012-09-15
Posts: 2,108

Re: Create your own GRUB2 rescue disk in a jiffy.

Nice! Must remember this before iminent doom.

Offline

#4 2013-02-14 11:56:26

Resident Bot
#! Die Hard
From: The Netherlands
Registered: 2012-02-17
Posts: 638

Re: Create your own GRUB2 rescue disk in a jiffy.

must do this as a precaution but could you give an example dd command to copy the iso to a usb as i have never used the command before


Troll = not a fanatic
slave of #!  and arch

Offline

#5 2013-02-14 12:56:29

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: Create your own GRUB2 rescue disk in a jiffy.

No problem.

WARNING: dd is sometimes referred to as 'data destroyer' or something in that vain, because it can cause loss of data when used with the wrong arguments.

The crucial part is finding out the device name for your thumbdrive:
After inserting the thumbdrive, run

dmesg|grep sd

I ran the command just now on my system, with following output:

[    1.127595] ACPI: Invalid Power Resource to register!<5>[    1.141982] sd 0:0:0:0: [sda] 156301488 512-byte logical blocks: (80.0 GB/74.5 GiB)
[    1.142140] sd 0:0:0:0: [sda] Write Protect is off
[    1.142145] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    1.142182] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.153279]  sda: sda1
[    1.153704] sd 0:0:0:0: [sda] Attached SCSI disk
[    6.444945] sd 0:0:0:0: Attached scsi generic sg0 type 0
[    8.006720] sd 4:0:0:0: Attached scsi generic sg2 type 0
[    8.007971] sd 4:0:0:0: [sdb] 3907029168 512-byte logical blocks: (2.00 TB/1.81 TiB)
[    8.008725] sd 4:0:0:0: [sdb] Write Protect is off
[    8.008734] sd 4:0:0:0: [sdb] Mode Sense: 23 00 00 00
[    8.009611] sd 4:0:0:0: [sdb] No Caching mode page present
[    8.011233] sd 3:0:0:0: Attached scsi generic sg3 type 0
[    8.011504] sd 2:0:0:0: Attached scsi generic sg4 type 0
[    8.011733] sd 2:0:0:1: Attached scsi generic sg5 type 0
[    8.011851] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[    8.013347] sd 3:0:0:0: [sdc] 15138816 512-byte logical blocks: (7.75 GB/7.21 GiB)
[    8.015356] sd 4:0:0:0: [sdb] No Caching mode page present
[    8.016434] sd 3:0:0:0: [sdc] Write Protect is off
[    8.016440] sd 3:0:0:0: [sdc] Mode Sense: 2f 00 00 00
[    8.016471] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[    8.018476] sd 3:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[    8.021741] sd 2:0:0:0: [sdd] Attached SCSI removable disk
[    8.023226] sd 2:0:0:1: [sde] Attached SCSI removable disk
[    8.025505]  sdc: sdc1
[    8.030749] sd 3:0:0:0: [sdc] Attached SCSI removable disk
[    8.037268]  sdb: sdb1
[    8.039974] sd 4:0:0:0: [sdb] No Caching mode page present
[    8.041035] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[    8.042159] sd 4:0:0:0: [sdb] Attached SCSI disk
[  558.200108] sd 5:0:0:0: Attached scsi generic sg6 type 0
[  558.202494] sd 5:0:0:0: [sdf] 1981440 512-byte logical blocks: (1.01 GB/967 MiB)
[  558.203497] sd 5:0:0:0: [sdf] Write Protect is off
[  558.203505] sd 5:0:0:0: [sdf] Mode Sense: 43 00 00 00
[  558.204492] sd 5:0:0:0: [sdf] No Caching mode page present
[  558.204502] sd 5:0:0:0: [sdf] Assuming drive cache: write through
[  558.208986] sd 5:0:0:0: [sdf] No Caching mode page present
[  558.208996] sd 5:0:0:0: [sdf] Assuming drive cache: write through
[  558.411507]  sdf: sdf1
[  558.414972] sd 5:0:0:0: [sdf] No Caching mode page present
[  558.414982] sd 5:0:0:0: [sdf] Assuming drive cache: write through
[  558.414990] sd 5:0:0:0: [sdf] Attached SCSI removable disk

You should be looking for the last lines displayed.
Those are kernel messages triggered by discovering a device.
In my case the device is sdf.

If the device is automounted on your system then unmount it first.

Now for the copy command itself:
WARNING: Running this command will destroy all data that is currently on the thumbdrive.

sudo dd if=/path/to/the/iso/file/you/want/to/copy of=/dev/sdx
sync

replace /path/to/the/iso/file/you/want/to/copy by the correct path, e.g ./grub.iso
replace /dev/sdx by your device name.

Offline

#6 2013-02-14 13:46:05

Resident Bot
#! Die Hard
From: The Netherlands
Registered: 2012-02-17
Posts: 638

Re: Create your own GRUB2 rescue disk in a jiffy.

Thanks for all the help and tips - I was just expecting the
dd command -should be no problems now  smile


Troll = not a fanatic
slave of #!  and arch

Offline

#7 2013-02-14 13:53:35

Resident Bot
#! Die Hard
From: The Netherlands
Registered: 2012-02-17
Posts: 638

Re: Create your own GRUB2 rescue disk in a jiffy.

hmm must be stuff missing from my waldorf version as i ran the command rebuild-my-grub-iso and got

/usr/bin/grub-mkrescue: 323: /usr/bin/grub-mkrescue: xorriso: not found

I installed xorriso and the grub.iso was made, thanks will now put it on usb

Last edited by Resident Bot (2013-02-14 13:56:42)


Troll = not a fanatic
slave of #!  and arch

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo