Showing posts with label grub. Show all posts
Showing posts with label grub. Show all posts

Monday, July 3, 2017

Debian 7 Increase Boot Speed By Reducing GRUB Timeout

Debian 7 Increase Boot Speed By Reducing GRUB Timeout


The following script changes the timeout for the Grub startup menu to just 1 second.

SEARCH="set timeout=.*"
REPLACE="set timeout=1"
FILEPATH="/boot/grub/grub.cfg"
sudo sed -i "s;$SEARCH;$REPLACE;g" $FILEPATH
If you ever do need to use the menu, just keep hammering the up/down keys during startup to stop the timeout.

Alternatively, execute the command below:

curl -s https://scripts.programster.org/scripts/8?output=raw | bash
Read more »

Friday, May 19, 2017

Dedicated grub 2 partition

Dedicated grub 2 partition


Dedicated GRUB 2 Partition:  How To Build It
This is straightforward, much easier than in GRUB Legacy.

1   Create the GRUB 2 partition.
Create a partition to be used as your dedicated GRUB 2 partition and format it.  I use GParted Live CD to do this.  At that time, you may if you wish, again using GParted, set a Label  on your partition;  e.g., �GRUB2� (without the quotation marks) (in GParted, use Partition > Labels).
(Check the size of the /boot/grub folder to determine how big to make the partition.  GRUB 2 files use just 572 KB (96 files, including 12 old ones) on my installation.)

2   Create grub.cfg.
In your home directory, create a text file called grub.cfg and build your custom boot menu for the dedicated GRUB 2 partition.  (For a sample, see below.)
(To create the text file, two ways:  (1) Right-click on your Desktop, Create New > Text File; or (2) open text editor Kate to an empty document by typing at Konsole  kate  and save it under the name grub.cfg in your home directory only!  To do this as root, use kdesudo kate or gksu gedit, but that is not necessary at this point.)
Caution:  You may want to completely build your boot menu now and have it ready to go.  To make your boot entries in your grub.cfg, see the subsection above "4 Ways To Boot an OS."

3   Install GRUB 2 to the MBR.
From your Kubuntu OS, install GRUB 2 to the Master Boot Record (of your first BIOS boot drive) using GRUB 2 files set up in your dedicated GRUB 2 partition.
Example
Suppose sdb1 is your dedicated GRUB 2 partition, and assume it is mounted as /media/sdb1 (or, if you set the label GRUB2 on sdb1, this might be /media/GRUB2).  And suppose you wish to install GRUB 2 to the MBR of sda which is set in BIOS to be your first boot drive.
Do it this way:
sudo grub-install �root-directory=/media/sdb1  /dev/sda
See:   http://grub.enbug.org/FranklinPiat/grub-install.manpage
(That will also build the directory /boot/grub for you in your GRUB 2 partition.)

4   As root, copy your grub.cfg from your home directory to the GRUB 2 partition under the folder /boot/grub.  (To do this in GUI, open your file manager as root and work from there; e.g., kdesudo konqueror or kdesudo dolphin.)

5  Set the boot flag on your dedicated GRUB 2 partition and re-boot to test it.

Set the boot flag on the dedicated GRUB 2 partition:
Do that using GParted either from your OS (K > System > Partition editor) or from the GParted Live CD.  If you do it using the GParted Live CD, you might go this way now:
After completing Step 4 (copying the grub.cfg file into the partition), put the GParted Live CD in the CD tray, let it be recognized, re-boot into GParted Live, set the boot flag on your dedicated GRUB 2 partition (Partition > Manage Flags), GParted > Quit, then double click GParted (large menu at top) to quit and re-boot, when prompted remove the GParted Live CD, and let the PC re-boot (and it will now be using your dedicated GRUB 2 partition), and see if it works.

CAUTION:  Remember to keep Super Grub Disk live CD handy.

4 Ways To Boot an OS
   configfile,  symlinks,  direct booting,  chainloader

You can use these methods
--   in a boot menu
--   at a grub> prompt (at the GRUB CLI)
to boot OSs.  If you use them at the GRUB CLI, you must type the command boot at the end to make the methods symlinks, direct booting and chainloader work.  You do not need the command boot in a configfile menu.  You do not need the boot command in grub.cfg (it is implied there).

NOTE:  These are done the same as in GRUB Legacy but with a new format.
But see the note on configfile below.

NOTE:  Each boot entry starts with a line
menuentry "...some text..." {
and ends with
 }

>>>   Configfile booting
This is easy and flexible; however, theres a caveat:
Both OSs must use the same version of GRUB--both the OS you are working in (where the main boot menu is kept) and the OS you are booting.

For example, consider these two statements in a menuentry:
set root=(hd1,2)
configfile /boot/grub/grub.cfg

An equivalent way of doing it is this:
configfile  (hd1,2)/boot/grub/grub.cfg

That tells your GRUB 2 to access partition (hd1,2), find the file /boot/grub/grub.cfg, show you that file so you can make a choice of which OS to boot, then boot the OS you choose.  The GRUB doing the work is your native GRUB, the one you are using, not the GRUB in (hd1,2).  Your native GRUB must be able to interpret the commands it finds in the grub.cfg of the OS you wish to boot.

When to avoid configfile
When there is a mixture of GRUB versions on your PC, it is best to avoid using configfile.
Instead, use chainloader or symlinks.

Example (Taken from a grub.cfg.  The # sign indicates a comment.)

#  Kubuntu 8.04.3 on sdb2, by configfile
menuentry �Kubuntu 8.04.3 on sdb2, by configfile�  {
set root=(hd1,2)
configfile /boot/grub/grub.cfg
 }


>>>   Symlinks used in a boot entry
Symlinks are like shortcuts, and they direct control from the link to the file they point at.  Symlinks for the kernel and initrd files are already set up for you.  Look for yourself.  List all files (-a) in long or detailed form (-l) under your root partition (/) by issuing the following command at Konsole:

ls -a -l  /
lrwxrwxrwx   1 root root    33 2009-08-02 11:01 initrd.img -> boot/initrd.img-2.6.24-24-generic
lrwxrwxrwx   1 root root    33 2009-04-19 17:14 initrd.img.old -> boot/initrd.img-2.6.24-23-generic
lrwxrwxrwx   1 root root    30 2009-08-02 11:01 vmlinuz -> boot/vmlinuz-2.6.24-2 4-generic
lrwxrwxrwx   1 root root    30 2009-04-19 17:14 vmlinuz.old -> boot/vmlinuz-2.6.24-23-generic

The symlink for the kernel is vmlinuz, and vmlinuz points at the NEWEST kernel.
The symlink for the initrd is initrd.img, and initrd.img points at the NEWEST initrd.

NOTE:   The "l" at the left indicates "link."  Note how the links point at their target files following the symbol ->.  Note that the symlinks are stored in your OS at the root level.

NOTE:   If you wish to make a boot entry for the older kernel and initrd, you must use the symlinks for them, vmlinuz.old and initrd.img.old.

If you use direct booting, you have to write out the exact kernel and initrd names:
linux /boot/vmlinuz-2.6.24-24-generic root=UUID= vb687f89-ggjd-6ach-7755-77241i4b4fk3 ro quiet splash
initrd /boot/initrd.img-2.6.24-24-generic

With symlinks, vmlinuz starts at root and points at  vmlinuz-2.6.24-24-generic  and  initrd.img  starts at root and points at  initrd.img-2.6.24-24-generic, so you can write more simply,
linux /vmlinuz  root=UUID= vb687f89-ggjd-6ach-7755-77241i4b4fk3 ro quiet splash
initrd /initrd.img

However, to simplify this when you are in an emergency trying to boot at the GRUB prompt (grub>), do it this way:
Suppose this OS is Kubuntu 9.10 in (hd0,8) = sda8.  Then youd have

menuentry �Kubuntu 9.10 on sda8, by symlinks�  {
set root=(hd0,8)
linux /vmlinuz root=/dev/sda8 ro quiet splash
initrd /initrd.img
}

or even simpler, when you cant remember the kernel options  "ro quiet splash":

menuentry �Kubuntu 9.10 on sda8, by symlinks�  {
set root=(hd0,8)
linux /vmlinuz root=/dev/sda8
initrd /initrd.img
}

(ro = Read-Only and is the default.  Thanks to dibl for this information.)

NOTE about the paths
Notice the paths to the symlinks start at root / (since the symlinks are stored under root /); whereas the paths to the actual kernel & initrd files start at /boot (since the kernel and initrd are stored under /boot)

Another Example

# Kubuntu 9.10 on sdb7 symlinks, normal mode
menuentry �Kubuntu 9.10 on sdb7, by symlinks�  {
set root=(hd1,7)
linux /vmlinuz root=/dev/sdb7 ro quiet splash
initrd /initrd.img
}

This is normal mode.  If you want recovery mode (single user),
replace the kernel options �ro quiet splash� with �ro single� (without quotes)


>>>   Direct booting
In direct booting, you use the actual kernel and initrd file names in the boot menuentry.
NOTE
If you use direct booting at the GRUB CLI, ie., at grub> prompt, you may use TAB completion to make your job easier.
For example,
grub>linux /boot/<Press TAB key now>
and you will get some choices, such as vmlinuz-2.6.24-24-generic

Example

#   Kubuntu 8.04 on sdb3, direct booting
menuentry "Kubuntu 8.04 on sdb3, direct booting" {
set root=(hd1,3)
linux   /boot/vmlinuz-2.6.24-24-generic root=UUID=db287e84-cbdd-4ca1-8745-85241a3b3fe2 ro quiet splash
initrd   /boot/initrd.img-2.6.24-24-generic
}


>>>   Chainloader booting
When you boot an OS by chainloading, you use the chainloader command to pass control of the booting from your native GRUB to some other bootloader located in the MBR of a disk somewhere or in the
boot sector of a partition.

NOTE:  For this to work, a bootloader must first be installed to the target MBR or a partition boot sector.

A Linux example

menuentry �Kubuntu 9.10 on sdb7, by chainloader�  {
set root=(hd1,7)
chainloader +1
}

"chainloader +1" says to go to sector 1 (of (hd1,7)) and turn control over to the bootloader found there.

For this example to work, a bootloader (e.g., GRUB 2) must be installed to the partition (hd1,7).
To install GRUB 2 to the boot sector of partition sdb7 (=(hd1,7)):
sudo grub-install /dev/sdb7

This is another way to write the same boot entry:
menuentry �Kubuntu 9.10 on sdb7, by chainloader�  {
chainloader  (hd1,7)+1
}

Another Linux example

menuentry �Drive sdc = hd2 by chainloader�  {
chainloader  (hd2)+1
}

If a bootloader (e.g., GRUB 2) has been installed to the Master Boot Record of drive sdc (= hd2), the menuentry will boot that hard drive by turning control over to the bootloader in its MBR.

For this example to work, a bootloader (e.g., GRUB 2) must be installed to the Master Boot Record of drive sdc (= hd2).  To install GRUB 2 to the Master Boot Record of drive sdc:
sudo grub-install /dev/sdc

Example

Windows XP on sda1
menuentry �Windows XP on sda1, by chainloader�  {
set root=(hd0,1)
chainloader +1
}
Read more »

Monday, April 10, 2017

Deepin os does not start dual boot with windows 8 or 10 GRUB error solution

Deepin os does not start dual boot with windows 8 or 10 GRUB error solution


 if you are having problem like windows is not getting started after dual booting with ubuntu then the same solution will work provide here


You�ll need to boot from a live CD or USB drive, switch deepin fail safe mode.
 above. Ensure the version of deepin on from a live CD or USB drive, as in the graphical method above. Ensure the version of Ubuntu on
the CD is the same as the version of Ubuntu installed on your computer � for example, if you
have deepin 15.03 installed, ensure you use a deepin os 15.03  live CD or usb drive.


Open a terminal after booting into the live environment. Identify the partition deepin is
installed on using one of the following commands:



sudo fdisk -l


sudo blkid


Here�s the output of both commands. In the fdisk -l command, the deepin partition is identified
by the word Linux in the System column. In the blkid command, the partition is identified by its
ext4 file system.Run the following command to mount the deepin partition at /mnt, replacing /dev/sdX# with
the device name of your deepin partition from the above commands:

 For example, use /dev/sda1 for the first partition of the first hard disk device.

 Mount the partition your deepin Installation is on. If you are not sure which it is, launch GParted (included in the Live CD) and find out. It is usually a EXT4 Partition. Replace the XY
with the drive letter, and partition number, for example: sudo mount /dev/sda1 /mnt.


 sudo mount /dev/sdXY /mnt


 Now bind the directories that grub needs access to to detect other operating systems, like so.



sudo mount --bind /dev /mnt/dev &&
sudo mount --bind /dev/pts /mnt/dev/pts &&
sudo mount --bind /proc /mnt/proc &&
sudo mount --bind /sys /mnt/sys

 Now we jump into that using chroot.

sudo chroot /mnt

Now install, check, and update grub.
This time you only need to add the drive letter (usually a) to replace X, for example: grub-install /dev/sda, grub-install �recheck /dev/sda.

grub-install /dev/sdX


 grub-install --recheck /dev/sdX

update-grub

Now grub is back, all that is left is to exit the chrooted system and unmount everything.



exit &&
 sudo umount /mnt/sys &&

sudo umount /mnt/dev/proc &&

sudo umount /mnt/dev/pts &&

sudo umount /mnt/dev &&

sudo umount /mnt




Shut down and turn your computer back on, and you will be met with the default Grub2 screen.
You may want to update grub or re-install burg however you like it.
Congratulations, you have just Repaired/Restored/Reinstalled Grub 2 with a deepin Live CD!
Read more »