error: malformed file.

Asked by mark

Try to re boot CPU while holding down SHIFT key to get into Grub

Get this message top L corner of black screen.

error: malformed file.
Press any key to continue

How do I resolve this ?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
mark
Solved:
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

If you press a key, does the boot process successfully continue?

Maybe the same problem as https://askubuntu.com/questions/473230/malformed-file-warning-on-boot

Revision history for this message
mark (rockcliff) said :
#2

Yes. When I press a key the boot process is successful.
Still can't get into grub while holding down shift key.

Revision history for this message
mark (rockcliff) said :
#3

The malformed file is stopping me from getting into grub while holding down SHIFT key. Doesn't matter how many times I reboot my CPU it is still the same. malformed file press any key to continue

Revision history for this message
Manfred Hampl (m-hampl) said :
#4

I suggest that you boot your system and reconfigure grub that the grub menu is always shown.
You do that by editing some settings in /etc/default/grub
...
# GRUB_HIDDEN_TIMEOUT=0
# GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
...
and then issuing the command "sudo update-grub"

Revision history for this message
mark (rockcliff) said :
#5

This read out after entering those commands.

Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-81-generic
Found initrd image: /boot/initrd.img-4.4.0-81-generic
Found linux image: /boot/vmlinuz-4.4.0-79-generic
Found initrd image: /boot/initrd.img-4.4.0-79-generic
Found linux image: /boot/vmlinuz-4.4.0-78-generic
Found initrd image: /boot/initrd.img-4.4.0-78-generic
Found linux image: /boot/vmlinuz-3.13.0-119-generic
Found initrd image: /boot/initrd.img-3.13.0-119-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done

Revision history for this message
mark (rockcliff) said :
#6

error: malformed file.
Press any key to continue
Still shows when trying to reboot for grub holding down SHIFT key

Manfred. I'm guessing those commands are done in Terminal as that is what I did and got that read out mentioned above.

Revision history for this message
Manfred Hampl (m-hampl) said :
#7

What is the output of the command (to be executed in a terminal window):

cat -n /etc/default/grub

Revision history for this message
mark (rockcliff) said :
#8

1 # If you change this file, run 'update-grub' afterwards to update
     2 # /boot/grub/grub.cfg.
     3 # For full documentation of the options in this file, see:
     4 # info -f grub -n 'Simple configuration'
     5
     6 GRUB_DEFAULT=0
     7 GRUB_HIDDEN_TIMEOUT=0
     8 GRUB_HIDDEN_TIMEOUT_QUIET=true
     9 GRUB_TIMEOUT=10
    10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    11 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    12 GRUB_CMDLINE_LINUX=""
    13
    14 # Uncomment to enable BadRAM filtering, modify to suit your needs
    15 # This works with Linux (no patch required) and with any kernel that obtains
    16 # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
    17 #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
    18
    19 # Uncomment to disable graphical terminal (grub-pc only)
    20 #GRUB_TERMINAL=console
    21
    22 # The resolution used on graphical terminal
    23 # note that you can use only modes which your graphic card supports via VBE
    24 # you can see them in real GRUB with the command `vbeinfo'
    25 #GRUB_GFXMODE=640x480
    26
    27 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    28 #GRUB_DISABLE_LINUX_UUID=true
    29
    30 # Uncomment to disable generation of recovery mode menu entries
    31 #GRUB_DISABLE_RECOVERY="true"
    32
    33 # Uncomment to get a beep at grub start
    34 #GRUB_INIT_TUNE="480 440 1"
output of the command: cat -n /etc/default/grub

Revision history for this message
Manfred Hampl (m-hampl) said :
#9

My advice was to edit that file and do the following modifications:
...
# GRUB_HIDDEN_TIMEOUT=0
# GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
...
I cannot see them in your current output.

Revision history for this message
mark (rockcliff) said :
#10

1 # If you change this file, run 'update-grub' afterwards to update
     2 # /boot/grub/grub.cfg.
     3 # For full documentation of the options in this file, see:
     4 # info -f grub -n 'Simple configuration'
     5
     6 GRUB_DEFAULT=0
     7 GRUB_HIDDEN_TIMEOUT=0
     8 GRUB_HIDDEN_TIMEOUT_QUIET=true
     9 GRUB_TIMEOUT=10
    10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    11 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    12 GRUB_CMDLINE_LINUX=""
    13
    14 # Uncomment to enable BadRAM filtering, modify to suit your needs
    15 # This works with Linux (no patch required) and with any kernel that obtains
    16 # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
    17 #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
    18
    19 # Uncomment to disable graphical terminal (grub-pc only)
    20 #GRUB_TERMINAL=console
    21
    22 # The resolution used on graphical terminal
    23 # note that you can use only modes which your graphic card supports via VBE
    24 # you can see them in real GRUB with the command `vbeinfo'
    25 #GRUB_GFXMODE=640x480
    26
    27 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    28 #GRUB_DISABLE_LINUX_UUID=true
    29
    30 # Uncomment to disable generation of recovery mode menu entries
    31 #GRUB_DISABLE_RECOVERY="true"
    32
    33 # Uncomment to get a beep at grub start
    34 #GRUB_INIT_TUNE="480 440 1"
Did it again and still don't see it in my outptut

Revision history for this message
mark (rockcliff) said :
#11

I tried these commands with and with out "sudo" in front of them.

# GRUB_HIDDEN_TIMEOUT=0
# GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
and then issuing the command "sudo update-grub"

Not sure why we are not getting the results you are hoping for.

Revision history for this message
Manfred Hampl (m-hampl) said :
#12

It seems that you misunderstood my instructions "You do that by editing some settings in /etc/default/grub"

You have to edit the configuration file /etc/default/grub and modify lines 7, 8 and 9, and not just type the text as commands into a terminal window.

Issue the command (in a terminal window)
sudo gedit /etc/default/grub
Provide your password as conformation for an administrative action if asked for it
In the editor that opens put a comment indicator ('#') in front of lines 7 and 8 (those containing HIDDEN_TIMEOUT) and set the timeout in line 9 to a suitable value (I suggest using 5).
Save the file and close the editor, and then issue the command
sudo update-grub
Finally reboot and check whether you finally see the grub menu.

Revision history for this message
mark (rockcliff) said :
#13

I'm stuck in grub rescue right now. I'll have to figure out how to correct this if possible. Tried some commands and ended up in grub rescue. Damn it.

Revision history for this message
Manfred Hampl (m-hampl) said :
#14

You could try booting your computer in a live system (an Ubuntu installer on DVD or bootable stick booted with selecting "try Ubuntu without installing") and then reinstall grub, see https://help.ubuntu.com/community/Grub2/Installing#via_the_LiveCD_terminal

Revision history for this message
mark (rockcliff) said :
#15

Will try later. Off to work now. Thank you.

Revision history for this message
mark (rockcliff) said :
#16

I re installed Ubuntu alongside my original installation using a USB stick. My mistake. I can get into grub now so can I now get my original installation running instead of the new one ? How ? Everything I use and do is on the original installation.

Revision history for this message
Manfred Hampl (m-hampl) said :
#17

The link in my previous comment should contain everything that you need.

First step must be to find out what the partitioning scheme now is
What is the output of the commands

sudo fdisk -l
sudo lsblk
sudo blkid

Revision history for this message
mark (rockcliff) said :
#18

Disk /dev/sda: 447.1 GiB, 480103981056 bytes, 937703088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5c731c99

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 63 477001979 477001917 227.5G 83 Linux
/dev/sda2 477002041 937701375 460699335 219.7G 5 Extended
/dev/sda5 477002043 488392064 11390022 5.4G 82 Linux swap / Solaris
/dev/sda6 488392704 937701375 449308672 214.3G 83 Linux

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 447.1G 0 disk
├─sda1 8:1 0 227.5G 0 part /
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 5.4G 0 part [SWAP]
└─sda6 8:6 0 214.3G 0 part
sr0 11:0 1 1024M 0 rom

Revision history for this message
mark (rockcliff) said :
#19

Would like my CPU to automatically boot up every time with the line Ubuntu 16.04.2 LTS (16.04) (on/dev/sda1)
How to do it is my question.
Thank you.

Revision history for this message
Manfred Hampl (m-hampl) said :
#20

What happen now, when you try booting?
Which options does the grub menu offer?

Revision history for this message
mark (rockcliff) said :
#21

Grub Menu Choice's

*Ubuntu
Advanced options for Ubuntu
Memory test (memtest86+)
Memory test (memtest86+, serial console 115200)
Ubuntu 16.04.2 LTS (16.04) (on/dev/sda1)
Advanced options for Ubuntu 16.04.2 LTS (16.04) (on/dev/sda1)

Top line *Ubuntu is highlighted and boots every time upon re-boot
I would like the 5th line down to boot every time: Ubuntu 16.04.2 LTS (16.04) (on/dev/sda1)
or even the last line.

I read an article saying I won't be able to do that because I re-installed Ubuntu along side the original installation and that it will always re-boot to the Newest Installation.

Revision history for this message
Manfred Hampl (m-hampl) said :
#22

If you want to have the fifth line automatically selected in the grub boot menu, you have to edit /ect/default/grub and set GRUB_DEFAULT=4 and run "sudo update-grub".

But the question is, what partition the first entry now has as its root directory.

Revision history for this message
mark (rockcliff) said :
#23

Not sure what partition.

Also not sure of the step by step commands to set GRUB_DEFAULT=4 and do I need to figure out the partition first.

Revision history for this message
Manfred Hampl (m-hampl) said :
#24

That are two different things.

1. To have the fifth entry automatically selected you have to edit the grub config file and change the value for GRUB_DEFAULT
sudo gedit /etc/default/grub
change line 6 from GRUB_DEFAULT=0 into GRUB_DEFAULT=4
save the file, close the editor and issue the command
sudo update-grub

2. What happens if you try selecting the first entry ("Ubuntu") from the grub menu during booting?

Revision history for this message
mark (rockcliff) said :
#25

First entry goes to the New Install not my Original Install.

When I do (sudo gedit /etc/default/grub) I see this :

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

GRUB_DEFAULT="Ubuntu 16.04.2 LTS(16.04)(on/dev/sda1)"
GRUB_HIDDEN_TIMEOUT="0"
GRUB_HIDDEN_TIMEOUT_QUIET="true"
GRUB_TIMEOUT="10"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL="console"

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE="640x480"

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID="true"

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

GRUB_SAVEDEFAULT="false"

Revision history for this message
Manfred Hampl (m-hampl) said :
#26

Some of the values in your /etc/default/grub file are strange.

on 2017-06-27 the contents were
...
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
...

and I recommended to change them into
...
GRUB_DEFAULT=0
# GRUB_HIDDEN_TIMEOUT=0
# GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
...

and later recommended to change to
...
GRUB_DEFAULT=4
(rest unchanged)
...

but now you have
...
GRUB_DEFAULT="Ubuntu 16.04.2 LTS(16.04)(on/dev/sda1)"
GRUB_HIDDEN_TIMEOUT="0"
GRUB_HIDDEN_TIMEOUT_QUIET="true"
GRUB_TIMEOUT="10"
...

I do not know what there is going on.

Revision history for this message
mark (rockcliff) said :
#27

I don't either. Wish I could just start fresh. At least I can get into my original install.

Revision history for this message
mark (rockcliff) said :
#28

Would Boot- Repair be of any help with my situation - see link

https://help.ubuntu.com/community/Boot-Repair

or someone else within the Ubuntu Forum

Revision history for this message
Manfred Hampl (m-hampl) said :
#29

boot-repair does not much more than midifying the /etc/default/grub configuration file and executing grub-install and update-grub.

You can try using grub-repair, but you can also use manual commands. It is your choice.

Revision history for this message
mark (rockcliff) said :
#30

Grub repair did what we were trying to do. My original install now boots upon re-boot.

https://help.ubuntu.com/community/Boot-Repair