It is currently Tue Sep 02, 2014 10:55 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Potential problem with ubcd2usb
PostPosted: Sun Jan 12, 2014 7:34 pm 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1284
Note: I received this from ady via PM and thinks it is suitable for discussion on the forum for future reference.

Quote:
I think I found a potential problem with ubcd2usb.cmd. I usually don't use it, but lately I have seen a couple of reports about booting UBCD, so I took a look at the script.

The script should install the SYSLINUX bootloader in

/boot/syslinux/ldlinux.sys

, but when the directory doesn’t yet exist, then the result depends on the version of SYSLINUX (the behavior has changed over the time / releases, and it is inconsistent between installers under different OS).

Additionally, the script copies the files only after the installation of the SYSLINUX bootloader, and only if that installation succeeds. And here we have 2 potential issues:
1_ when the bootloader is installed to the root (because the

/boot/syslinux/

directory doesn't yet exist), the procedure is considered successful anyway, not a failure; and,
2_ a file is then copied to

/boot/syslinux/ldlinux.sys

as part of the procedure that copies files to the USB drive.

So, depending on the initial state of the drive, and depending on the Syslinux version, the resulting USB drive *might* fail to boot UBCD.

Currently, one reason to execute the installation of the bootloader before copying the rest of the files is that the former is faster than the latter; so if it fails then the user doesn't have to wait for all the files to be copied just to find out that something has failed.

So to cover these cases, one possible solution could be to perform the installation of the bootloader twice, one before the copy of the files, and one after it.

The alternative is to swap the order, copy the files first, and if that succeeds, only then install the bootloader.


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Sun Jan 12, 2014 7:43 pm 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1284
@ady: Thanks for bringing this up.

How about creating the directory right before the syslinux command:

Code:
:_gomkbt2
if exist "%a2%\boot\syslinux" goto _gomkbt2a
mkdir "%a2%\boot\syslinux"
:_gomkbt2a
echo UBCD2USB: Making USB KEY bootable...
"%~dp0\syslinux" -f -ma -d boot\syslinux %a2%
if errorlevel 0 goto _gomkbt3
%0 : _error 'syslinux.exe' failed


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Sun Jan 12, 2014 9:20 pm 
Offline

Joined: Sat May 08, 2010 5:26 am
Posts: 762
Victor Chew wrote:
How about creating the directory right before the syslinux command


I thought about that possibility before, but it doesn't solve the second potential problem I mentioned: a file is then copied to
/boot/syslinux/ldlinux.sys
during the "xcopy" procedure. This *could* be a problem.

The UBCD ISO images include this
/boot/syslinux/ldlinux.sys
file, and it is copied during the "copying files" phase of the script.

Although this file is not strictly necessary in the ISO image, it can be helpful in some cases, so I am not recommending removing it from the UBCD ISO images. Moreover, the ubcd2usb script can be executed from a different media such as a removable drive (not just from extracting the original content of the ISO image or from an optical media). This means that the script should still consider the possibility that
<ubcd_extracted>/boot/syslinux/ldlinux.sys
would be copied over to the USB media, even if official UBCD ISO images wouldn't include it (and, to be clear, I am still in favor of including this file in the ISO image).

Now, executing the SYSLINUX installer before copying the rest of the files also improves the chances for the ldlinux.sys file to be located in a relatively low LBA, which potentially helps when booting buggy BIOS. So this is the second reason to execute the SYSLINUX installer before copying the rest of the files.

If the SYSLINUX installer is executed *again* after the files are copied (which is one of my proposals posted above), I am unsure whether this file would still occupy a low LBA (or as low as when the first time it was installed).

OTOH, if the SYSLINUX installer is only executed once, after the files are copied, we miss (lose) the two aforementioned advantages that we currently have.

So, a more-complete solution would be to:
1_ As you suggested, add a step for the creation of the directory before executing the SYSLINUX installer; then,
2_ Add code to the "xcopy" command so to copy all files *except*
<ubcd_extracted/boot/syslinux/ldlinux.sys>
.

I currently don't remember if there are such xcopy arguments available without over-complicating the current script. If such xcopy argument exists (I'll have to take a look), and if adding it doesn't imply making a “mess” of the xcopy section of the script, I think this would be the best solution.

BTW, some time ago someone posted in this UBCD forum a suggested new alternative ubcd2usb.cmd script. The potential problems I am describing here are also relevant to that other script too.


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Mon Jan 13, 2014 11:48 am 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1284
Quote:
2_ Add code to the "xcopy" command so to copy all files *except*

<ubcd_extracted/boot/syslinux/ldlinux.sys>
Noted: This can be done using the "/exclude" command.


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Mon Jan 13, 2014 5:13 pm 
Offline

Joined: Sat May 08, 2010 5:26 am
Posts: 762
The way I understand the "
/exclude:
" parameter for xcopy is:
1_ Add a text file, which contains a list of strings (part of a path, part of a file name,...) that are a match to the files to be excluded from the copy process.
2_ Point "
/exclude:
" to that additional text file.

I performed a non-thorough test, and I couldn't make it work as expected. Can someone else test it?

We should also consider the potential case where the original
<ubcd_extracted>/boot/syslinux/ldlinux.sys
might not exist. I mean, if such case happens, the script should still be able to success, not error out.

BTW, the current ubcd2usb script includes 2 "setlocal" commands. Is this intentional?


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Wed Jan 15, 2014 4:45 pm 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1284
Quote:
I performed a non-thorough test, and I couldn't make it work as expected. Can someone else test it?
I got it to work, just as you described. Created a file called 'exclude.lst" with the single line "ldlinux.sys". Then issue xcopy with "/exclude:exclude.lst".

Quote:
BTW, the current ubcd2usb script includes 2 "setlocal" commands. Is this intentional?
No, the second SETLOCAL is redundant and will be removed.


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Wed Jan 15, 2014 5:18 pm 
Offline

Joined: Sat May 08, 2010 5:26 am
Posts: 762
Where (in which directory) exactly the exclude.lst should be added?

I think that the exclude.lst should better contain the path to ldlinux.sys too, not just the file name. At least a relative path like
boot\syslinux\ldlinux.sys
.

Also, what happens if the
<extracted_ubcd>/boot/syslinux/ldlinux.sys
file is not present? Does the script fail?

According to your answers, I'll try to find out why my prior test failed, so to avoid such potential situation.

TIA,
Ady.


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Wed Jan 15, 2014 9:47 pm 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1284
Quote:
Also, what happens if the

<extracted_ubcd>/boot/syslinux/ldlinux.sys

file is not present? Does the script fail?
No, it doesn't fail. It is just excluding files of certain names, and does not mind at all if the file is absent.


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Wed Jan 15, 2014 11:19 pm 
Offline

Joined: Sat May 08, 2010 5:26 am
Posts: 762
The question about the adequate location of "exclude.lst" is relevant, because a user could launch the ubcd2usb script while the working directory is not
<ubcd_extracted>\ubcd\tools\win32\ubcd2usb
. In such case, using
/exclude:exclude.lst
might cause a potential error (exclude.lst is not found).

Additionally, it might be worth adding to the content of exclude.lst the following lines too:
Code:
[BOOT]
boot.images


(note: I have not tested the above addition yet).


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Tue Jan 28, 2014 11:26 am 
Offline

Joined: Sat May 08, 2010 5:26 am
Posts: 762
I am still wondering about the location of "exclude.lst", and about adding
Code:
BOOT]
boot.images


to it.

In the meantime, I'd like to suggest changing your first:

Code:
:_gomkbt2
if exist "%a2%\boot\syslinux" goto _gomkbt2a
mkdir "%a2%\boot\syslinux"
:_gomkbt2a
echo UBCD2USB: Making USB KEY bootable...
"%~dp0\syslinux" -f -ma -d boot\syslinux %a2%
if errorlevel 0 goto _gomkbt3
%0 : _error 'syslinux.exe' failed


to:

Code:
:_gomkbt2
if not exist "%a2%\boot\syslinux\nul" mkdir "%a2%\boot\syslinux\"
echo UBCD2USB: Making USB KEY bootable...
"%~dp0\syslinux" -f -ma -d boot\syslinux %a2%
if errorlevel 0 goto _gomkbt3
%0 : _error 'syslinux.exe' failed


The reasons are:
_ It uses "nul", avoiding a potential confusion (in a customized <ubcd_extracted>,) between "
%a2%\boot\syslinux
" file (the Linux-based SYSLINUX installer) and the "
%a2%\boot\syslinux
" *directory*.
_ Avoids the extra "goto _gomkbt2a" (and the ":_gomkbt2a" itself).

My only doubt (because I have not specifically checked it) is whether the errorlevel changes in *any* way between your initial suggestion (using an extra goto) and this new one.


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Thu Feb 27, 2014 1:28 am 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1284
Thanks for the suggestion. After some testing, the new code becomes:

Code:
:_gomkbt2
if not exist "%a2%\boot\syslinux\nul" mkdir "%a2%\boot\syslinux\"
echo UBCD2USB: Making USB KEY bootable...
"%~dp0\syslinux" -f -ma -d boot\syslinux %a2%
if errorlevel 0 goto _gomkbt3
%0 : _error 'syslinux.exe' failed
:_gomkbt3
echo UBCD2USB: Copying files to USB KEY...
rmdir /q /s "%a1%\[BOOT]" 2> NUL
rmdir /q /s "%a1%\boot.images" 2> NUL
xcopy "%a1%\*" %a2% /s /h /q /exclude:%~dp0\exclude.lst
if errorlevel 0 goto _gomkbt4
%0 : _error 'xcopy.exe' failed

Note the addition of %~dp0 to make the full path to exclude.lst.

I can understand the addition of "[BOOT]" to exclude.lst (artifact from 7za extraction), but how about "boot.images"?


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Thu Feb 27, 2014 3:35 am 
Offline

Joined: Sat May 08, 2010 5:26 am
Posts: 762
Victor Chew wrote:
I can understand the addition of "[BOOT]" to exclude.lst (artifact from 7za extraction), but how about "boot.images"?


"[BOOT]" is to "7zip", what "boot.images" is to "IZArc".

If you take a look at the ubcd2iso scripts, you added (years ago) "boot.images" (to the tasks performed on "[BOOT]") so to support performing the extraction by means of IZArc (as alternative to 7zip).

I am just suggesting the same equivalent support for both, 7zip and IZArc, in the new ubcd2usb's exclude.lst too.

The background reason to support alternatives to 7zip is because there are certain cases where 7zip is "too strict" with certain "non-standard" archives (or images), so it fails to complete the extraction. Alternatives such as IZArc can help in those situations (among others).

On another matter (still regarding ubcd2iso), is there any interest (as in *real* need) on adding a Linux-based ubcd2usb.sh script too?


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Fri Feb 28, 2014 4:08 pm 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1284
Got it. Will add "boot.images".

Quote:
On another matter (still regarding ubcd2iso), is there any interest (as in *real* need) on adding a Linux-based ubcd2usb.sh script too?
Haven't seen much talk about this, so I gather there isn't much interest? Maybe the existing instructions is clear enough for Linux users, who are typically more technical.


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Sun Mar 02, 2014 4:49 am 
Offline

Joined: Sat May 08, 2010 5:26 am
Posts: 762
I think the line:
Code:
"%~dp0\syslinux" -f -ma -d boot\syslinux %a2%

should rather be
Code:
"%~dp0syslinux" -f -ma -d boot\syslinux %a2%

Note that the former includes a backslash and the latter does not.

Am I wrong?


Top
 Profile  
 
 Post subject: Re: Potential problem with ubcd2usb
PostPosted: Sun Mar 02, 2014 4:55 pm 
Offline

Joined: Mon Feb 21, 2005 10:59 pm
Posts: 1284
The extra backlash in the expanded line _is_ redundant, but does improve readability in the script, IMHO.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group