Author Topic: restore mbr scripts  (Read 1392 times)

Offline slax

  • Sr. Member
  • ****
  • Posts: 391
    • PCLinuxOS Gnome Edition
restore mbr scripts
« on: May 05, 2011, 12:09:27 PM »
neither redo-mbr nor restore-mbr works... i've tried it both and it's the same error. scripts needs to be updated/corrected. I'm haven't tried for xfce and lxde, but i believe they don't work either...


Code: [Select]
+ M1='The bootloader configuration of the chosen partition will displayed\n\nYou can edit the the configuration and save your changes\n\nYou will be asked if you want to recreate your bootloader'
+ '[' -eq 1 ']'
/usr/sbin/redo-mbr: line 272: [: -eq: unary operator expected
+ rm -f /tmp/redo-mbr.8547



Offline Sproggy

  • Hero Member
  • *****
  • Posts: 1484
Re: restore mbr scripts
« Reply #1 on: May 05, 2011, 12:21:32 PM »
Hi Slax ... i have just tested on my fully updated Phinx install for xfce-restore-mbr and all works well here


Code: [Select]
[root@localhost kori]# xfce-restore-mbr
+ newline='
'
+ type mapdevfs
+ '[' 0 '!=' 0 ']'
+ DIA=gdialog
+ TMP=/tmp/redo-mbr.1160
+ mkdir -p /mnt/loop
+ fdisk -l
+ grep '^/dev.*Linux$'
+ tr -d '*'
+ read dev x x size x
+ mount /dev/sda6 /mnt/loop
++ cat /mnt/loop/etc/mandrake-release
++ awk '{print $1 }'
++ tr '[:upper:]' '[:lower:]'
+ distro=
+ '[' '' = pclinuxos ']'
+ umount /mnt/loop
+ read dev x x size x
+ mount /dev/sda7 /mnt/loop
++ cat /mnt/loop/etc/mandrake-release
++ awk '{print $1 }'
++ tr '[:upper:]' '[:lower:]'
+ distro=pclinuxos
+ '[' pclinuxos = pclinuxos ']'
+ size=72621801
+ echo /dev/sda7 /dev/sda7 off
+ umount /mnt/loop
+ read dev x x size x
+ mount /dev/sdc5 /mnt/loop
mount: /dev/sdc5 already mounted or /mnt/loop busy
mount: according to mtab, /dev/sdc5 is already mounted on /mnt/loop
++ cat /mnt/loop/etc/mandrake-release
++ awk '{print $1 }'
++ tr '[:upper:]' '[:lower:]'
+ distro=pclinuxos
+ '[' pclinuxos = pclinuxos ']'
+ size=49199031
+ echo /dev/sdc5 /dev/sdc5 off
+ umount /mnt/loop
+ read dev x x size x
+ mount /dev/sdc6 /mnt/loop
++ cat /mnt/loop/etc/mandrake-release
++ tr '[:upper:]' '[:lower:]'
++ awk '{print $1 }'
+ distro=
+ '[' '' = pclinuxos ']'
+ umount /mnt/loop
+ read dev x x size x
++ wc -l
+ NUMPCLOS=2
++ cat /tmp/redo-mbr.1160
+ PCLOSPART='/dev/sda7 /dev/sda7 off
/dev/sdc5 /dev/sdc5 off'
+ T1='PCLinuxOS partition selection'
+ M1='No PCLinuxOS installation could be found on your hard disks. The script will be terminated.'
+ '[' 2 -eq 0 ']'
+ '[' 2 -gt 1 ']'
+ M1='More than one PCLinuxOS installation found, Please select the one you want to reinstall mbr from'
+ gdialog --title 'PCLinuxOS partition selection' --radiolist 'More than one PCLinuxOS installation found, Please select the one you want to reinstall mbr from' /dev/sda7 /dev/sda7 off /dev/sdc5 /dev/sdc5 off
++ cat /tmp/redo-mbr.1160
+ FSCHOICE=/dev/sdc5
+ M1='No partition chosen. The script will be terminated.'
+ '[' -z /dev/sdc5 ']'
+ dev=/dev/sdc5
+ NUMPCLOS=1
+ TR=/mnt/loop
+ grub-install --recheck --no-floppy /dev/null
++ grep '(hd0)' /boot/grub/device.map
++ awk '{print $2}'
+ GRUB_MBR=/dev/sda
+ dd if=/dev/sda count=1 bs=512
+ grep -iw grub
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0180269 s, 28.4 kB/s
Binary file (standard input) matches
+ x=0
+ '[' 0 '!=' 0 ']'
+ BOOTLOADER=GRUB
+ M1='The bootloader configuration of the chosen partition will displayed\n\nYou can edit the the configuration and save your changes\n\nYou will be asked if you want to recreate your bootloader'
+ '[' 1 -eq 1 ']'
+ mount /dev/sdc5 /mnt/loop
+ '[' GRUB = WINDOWS ']'
+ gdialog --title Edit --msgbox 'The bootloader configuration of the chosen partition will displayed\n\nYou can edit the the configuration and save your changes\n\nYou will be asked if you want to recreate your bootloader' 15 80
+ '[' GRUB = LILO ']'
++ grep -v /dev/sdc5
++ grep -v MS
++ grep -v Win
++ wc -l
++ os-prober
+ NUMLINUX=0
+ '[' 0 '!=' 0 ']'
+ mousepad /mnt/loop/boot/grub/menu.lst
+ M1='Do you want to reset your bootloader?'
+ gdialog --title 'PCLinuxOS partition selection' --yesno 'Do you want to reset your bootloader?' 15 80
+ x=0
+ '[' 0 '!=' 0 ']'
+ mount -t proc none /mnt/loop/proc
+ mount -t none /dev /mnt/loop/dev -o bind
+ '[' GRUB = LILO ']'
+ chroot /mnt/loop boot/grub/install.sh


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]
grub> root (hd2,4)
 Filesystem type is ext2fs, partition type 0x83
grub> setup --stage2=/boot/grub/stage2 (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  17 sectors are embedded.
succeeded
 Running "install --stage2=/boot/grub/stage2 /boot/grub/stage1 d (hd0) (hd0)1+17 p (hd2,4)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.
grub> quit
+ umount /mnt/loop/dev
+ umount /mnt/loop/proc
+ rm -f /tmp/redo-mbr.1160

Kori

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: restore mbr scripts
« Reply #2 on: May 05, 2011, 01:34:50 PM »
neither redo-mbr nor restore-mbr works... i've tried it both and it's the same error. scripts needs to be updated/corrected. I'm haven't tried for xfce and lxde, but i believe they don't work either...


Code: [Select]
+ M1='The bootloader configuration of the chosen partition will displayed\n\nYou can edit the the configuration and save your changes\n\nYou will be asked if you want to recreate your bootloader'
+ '[' -eq 1 ']'
/usr/sbin/redo-mbr: line 272: [: -eq: unary operator expected
+ rm -f /tmp/redo-mbr.8547

Try changing line 272 of the redo-mbr script from this

Code: [Select]
if [ $NUMPCLOS -eq 1 ]; then
to this

Code: [Select]
if [ "$NUMPCLOS" -eq "1" ]; then
and see if it works .......

Offline slax

  • Sr. Member
  • ****
  • Posts: 391
    • PCLinuxOS Gnome Edition
Re: restore mbr scripts
« Reply #3 on: May 06, 2011, 08:58:10 AM »
no progress, now it exits with:


Code: [Select]
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0137014 s, 37.4 kB/s
Binary file (standard input) matches
+ x=0
+ '[' 0 '!=' 0 ']'
+ BOOTLOADER=GRUB
+ M1='The bootloader configuration of the chosen partition will displayed\n\nYou can edit the the configuration and save your changes\n\nYou will be asked if you want to recreate your bootloader'
+ '[' '' -eq 1 ']'
/usr/sbin/restore-mbr: line 272: [: : integer expression expected
+ rm -f /tmp/redo-mbr.10643



Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1317
Re: restore mbr scripts
« Reply #4 on: May 07, 2011, 04:57:15 AM »
no progress, now it exits with:


Code: [Select]
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0137014 s, 37.4 kB/s
Binary file (standard input) matches
+ x=0
+ '[' 0 '!=' 0 ']'
+ BOOTLOADER=GRUB
+ M1='The bootloader configuration of the chosen partition will displayed\n\nYou can edit the the configuration and save your changes\n\nYou will be asked if you want to recreate your bootloader'
+ '[' '' -eq 1 ']'
/usr/sbin/restore-mbr: line 272: [: : integer expression expected
+ rm -f /tmp/redo-mbr.10643


This example show what happens:
Code: [Select]
#!/bin/sh
# Here numpclos is uninitialized - throws error "integer expression expected"
if [ "$NUMPCLOS" -eq "1" ]; then
 echo Yup
else
 echo No
fi

# Here numpclos is uninitialized - but adding a dummy value make sure there is a value on both sides - resulting in No1
if [ "$NUMPCLOS"1 -eq "1"1 ]; then
 echo Yup1
else
 echo No1
fi

NUMPCLOS=1
# Here numpclos is instantiated to 1 - no problems - resulting in Yup2
if [ "$NUMPCLOS"1 -eq "1"1 ]; then
 echo Yup2
else
 echo No2
fi

NUMPCLOS=2
# Here numpclos is instantiated to 2 - no problems - resulting in No3
if [ "$NUMPCLOS"1 -eq "1"1 ]; then
 echo Yup3
else
 echo No3
fi

Changing the line to:
if [ "$NUMPCLOS"1 -eq "1"1 ]; then

does not throw an error.

cheers,
MBantz

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: restore mbr scripts
« Reply #5 on: May 07, 2011, 05:23:50 AM »
Why does NUMPCLOS have no value assigned at the time of this check? ......  in Slax's case ....  is it due to a failure to read a partition?

If that is the case then I expect there should be an indication of it in an earlier part of the script output.

Offline slax

  • Sr. Member
  • ****
  • Posts: 391
    • PCLinuxOS Gnome Edition
Re: restore mbr scripts
« Reply #6 on: May 07, 2011, 02:01:20 PM »
i haven't mentioned the script was run from livecd, not from installed system. but than again, the whole point is to be run from livecd



Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1317
Re: restore mbr scripts
« Reply #7 on: August 09, 2012, 02:52:57 AM »
Just had this issue and looked at lxde-redo-mbr script and found the culprit!

The script finds all PCLinuxos flavors on the disk devices and put them in menu.lst - and it does this by examining the first word/argument in the file /etc/mandrake-release on the found devices.
If the first word/argument in this file does not contain the word PCLinuxOS (upper and lower case is ok it converts them) then the OS is not recognized.

It is the awk line in the redo-mbr scripts that picks out the first word/argument (print $1)

Putting pclinuxos as the first word in /etc/mandrake-release fixes it (or changing the awk command)

cheers
MBantz

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10625
  • MLUs Forever!
Re: restore mbr scripts
« Reply #8 on: August 09, 2012, 03:09:20 AM »
Just had this issue and looked at lxde-redo-mbr script and found the culprit!

The script finds all PCLinuxos flavors on the disk devices and put them in menu.lst - and it does this by examining the first word/argument in the file /etc/mandrake-release on the found devices.
If the first word/argument in this file does not contain the word PCLinuxOS (upper and lower case is ok it converts them) then the OS is not recognized.

It is the awk line in the redo-mbr scripts that picks out the first word/argument (print $1)

Putting pclinuxos as the first word in /etc/mandrake-release fixes it (or changing the awk command)

cheers
MBantz


I have a KDE install .....  is it true to say that PCLinuxOS is not the first word in that file for versions other than KDE?
Is that the problem?

Sorry, this is some time past so any info I had then is long gone  :D

I see there are two files ......  mandrake-release and mandrakelinux-release  and both are links to    pclinuxos-release.
« Last Edit: August 09, 2012, 03:10:55 AM by Just18 »
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1317
Re: restore mbr scripts
« Reply #9 on: August 09, 2012, 03:25:20 AM »
Just had this issue and looked at lxde-redo-mbr script and found the culprit!

The script finds all PCLinuxos flavors on the disk devices and put them in menu.lst - and it does this by examining the first word/argument in the file /etc/mandrake-release on the found devices.
If the first word/argument in this file does not contain the word PCLinuxOS (upper and lower case is ok it converts them) then the OS is not recognized.

It is the awk line in the redo-mbr scripts that picks out the first word/argument (print $1)

Putting pclinuxos as the first word in /etc/mandrake-release fixes it (or changing the awk command)

cheers
MBantz


I have a KDE install .....  is it true to say that PCLinuxOS is not the first word in that file for versions other than KDE?
Is that the problem?

Sorry, this is some time past so any info I had then is long gone  :D

I see there are two files ......  mandrake-release and mandrakelinux-release  and both are links to    pclinuxos-release.


Yep, it is why some redo-mbr scripts fail - not sure if it's an issue on all DE's

cheers,
MBantz