Thanks for the response, Gene. Much appreciated. I didn't get all of it; mind if I follow on below? ldlinux.sys is ldlinux.bin without the VBR (Volume Boot Record) code.>Makes sense.> > 1. Where is the code that goes in the VBR or Block Group 0 padding? > > diskboot.inc. >which appears to be included in diskstart.inc. I will have to dig in and see how this all gets compiled (pointers always appreciated :-) ). An install on Linux (before I run "syslinux --install") actually doesn't have ldlinux.sys or ldlinux.bin anywhere. Are they embedded into the syslinux binary and it installs bytes, vs copying from the local filesystem?> > 2. What does it execute? Does it just find the ldlinux.sys and execute > it? > > Set up the basic environment, load blocks of ldlinux.sys, check > integrity (weakly but works well enough) and jump to a further point. > > The installer patches in a block map of ldlinux.sys into the VBR plus > ldlinux.sys.A blockmap into the VBR and ldlinux.sys into the VBR?> At least one record stating N sectors at volume offset M > needs to live in the VBR. Often, only 1 record is needed. >I didn't get this part. Record?> > > 3. How does it know to find the ldlinux.sys (and, at the least, > > ldlinux.c32) if it cannot read the filesystem? Does syslinux --install > copy > > them over and then read the filesystem to know precisely what blocks they > > are in and then embed the precise block number in the VBR? Where? And if > > so, does it not leave it vulnerable to the files being moved around? > > Files moving from directories shouldn't be an issue (unless it's a > copy/delete). It certainly is vulnerable to moving the underlying > blocks hence why ldlinux.sys resides in the special reserved space in > btrfs. >But wouldn't work in FAT32 (VBR = 512 bytes) or ext4 (1024 bytes in Block Group 0). Thanks again for the explanation. Avi
> An install on Linux (before I run "syslinux --install") actually doesn't > have ldlinux.sys or ldlinux.bin anywhere. Are they embedded into the > syslinux binary and it installs bytes, vs copying from the local filesystem? >The command line installers have the core module and the bootloader file, all embedded. If you don't have the ldlinux.sys file in your system, it would mean that you only have "binary" packages of SYSLINUX and/or EXTLINUX (and the bootloader has not been yet installed). Other Syslinux-related packages should include the core module (ldlinux.c32), but not necessarily the core bootloader file (ldlinux.sys). The upstream official archives include both, source code and binaries, including ldlinux.sys. See: _ www.syslinux.org/wiki/index.php/Install _ www.syslinux.org/wiki/index.php/Library_modules> But wouldn't work in FAT32 (VBR = 512 bytes) or ext4 (1024 bytes in Block > Group 0).FWIW, the VBR in FAT32 doesn't have to be 512 bytes; FAT32 has the possibility to use more than one sector for boot purposes. In fact, Microsoft's FAT32 VBR uses at least 3 sectors (IIRC, typically, 32 sectors). At any rate, yes, moving ldlinux.sys within a FAT32 boot volume could potentially affect the boot process when using SYSLINUX. In such case, executing the command line installer would be the simplest/quickest solution. Regards, Ady. PS: @Gene, lately I have noticed that incoming emails from the Syslinux Mailing List are delayed; I happen to see them in the public archive (sometimes several hours) before they actually arrive to my email inbox. I don't know whether it is just my case, nor whether it is worth starting an email thread for such issue to be openly discussed.
On Tue, Jan 2, 2018 at 1:03 PM, Avi Deitcher <avi at deitcher.net> wrote:> Thanks for the response, Gene. Much appreciated. I didn't get all of it; > mind if I follow on below? > >> ldlinux.sys is ldlinux.bin without the VBR (Volume Boot Record) code. > > Makes sense. > >> > 1. Where is the code that goes in the VBR or Block Group 0 padding? >> >> diskboot.inc. > > which appears to be included in diskstart.inc. I will have to dig in and see > how this all gets compiled (pointers always appreciated :-) ).Yes.> An install on Linux (before I run "syslinux --install") actually doesn't > have ldlinux.sys or ldlinux.bin anywhere. Are they embedded into the > syslinux binary and it installs bytes, vs copying from the local filesystem?As Ady said, embedded within the syslinux/extlinux installer.>> > 2. What does it execute? Does it just find the ldlinux.sys and execute >> > it? >> >> Set up the basic environment, load blocks of ldlinux.sys, check >> integrity (weakly but works well enough) and jump to a further point.Actually, mildly more complex but similar. Setup some basics, the first sector of ldlinux.sys, execute it. The first sector of ldlinux.sys sets up some more stuff, loads the rest of ldlinux.sys, checks integrity then continues.>> The installer patches in a block map of ldlinux.sys into the VBR plus >> ldlinux.sys.Actually, only the first sector of ldlinux.sys, computed after ldlinux.sys is copied and patched into the VBR by the installer. The block map is in ldlinux.sys.>> At least one record stating N sectors at volume offset M >> needs to live in the VBR. Often, only 1 record is needed. > > I didn't get this part. Record?It's more of a list. The list has rows or records. Each record indicates data about a block of the file ldlinux.sys. This data is in fields for offset sector number of start and how many sectors are within the block.>> > 3. How does it know to find the ldlinux.sys (and, at the least, >> > ldlinux.c32) if it cannot read the filesystem? Does syslinux --install >> > copy >> > them over and then read the filesystem to know precisely what blocks >> > they >> > are in and then embed the precise block number in the VBR? Where? And if >> > so, does it not leave it vulnerable to the files being moved around? >> >> Files moving from directories shouldn't be an issue (unless it's a >> copy/delete). It certainly is vulnerable to moving the underlying >> blocks hence why ldlinux.sys resides in the special reserved space in >> btrfs. > > But wouldn't work in FAT32 (VBR = 512 bytes) or ext4 (1024 bytes in Block > Group 0). > > Thanks again for the explanation. > AviCorrect, this technique of storing the entire boot loader in reserved space wouldn't work there. -- -Gene
Gene, thanks for doing "Reply-All". I only get digest, so this keeps me in the loop. Appreciated.> which appears to be included in diskstart.inc. I will have to dig in and > see > > how this all gets compiled (pointers always appreciated :-) ). > > Yes. >Is the build process documented? Or am I just going to have to plod through the makefiles?> As Ady said, embedded within the syslinux/extlinux installer. >Got it. And I did a byte comparison of ldlinux.bin/ldlinux.sys. Identical except for the first 1024 bytes. First 512 are the VBR, as you described, next 512 are all zeros (I assume for using with ext?).> Actually, mildly more complex but similar. Setup some basics, the > first sector of ldlinux.sys, execute it. > > The first sector of ldlinux.sys sets up some more stuff, loads the > rest of ldlinux.sys, checks integrity then continues. >So... VBR (i.e. first 512 bytes of ldlinux.bin) contains code that knows to find and load first sector of ldlinux.sys. That in turn knows how to find the rest of ldlinux.sys, and loads that. ldlinux.sys itself understands fat32 well enough to find the rest of its modules, syslinux.cfg, etc.> Actually, only the first sector of ldlinux.sys, computed after > ldlinux.sys is copied and patched into the VBR by the installer. The > block map is in ldlinux.sys. > > >> At least one record stating N sectors at volume offset M > >> needs to live in the VBR. Often, only 1 record is needed. > > > > I didn't get this part. Record? > > It's more of a list. The list has rows or records. Each record > indicates data about a block of the file ldlinux.sys. This data is in > fields for offset sector number of start and how many sectors are > within the block.Let me see if I get this. 1. Run installer 2. Installer loads ldlinux.sys onto the filesystem (and copies ldlinux.c32, but irrelevant for now). 3. Installer calculates which blocks in the filesystem contain ldlinux.sys 4. Installer modifies first sector of ldlinux,sys to contain a list of all of the other locations of ldlinux.sys 5. Installer puts the first 512 bytes of ldlinux.bin into the boot sector 6. Installer modifies code in VBR (a specific byte?) to indicate which block contains first 512 bytes of ldlinux.sys On boot: 1. VBR is run (first 512 bytes of ldlinux.bin) 2. VBR knows how to find first block of ldlinux.sys 3. VBR loads first block of ldlinux.sys into memory and executes it 4. Code in memory and executing has map of all other blocks of ldlinux.sys, so it loads them. 5. Now have all the code we need to read fat32 filesystem, so it does, reads syslinux.cfg, loads c32 files, etc. Is that roughly it? I assume extlinux does the same thing, just has some more knowledge about other filesystems? -- Avi Deitcher avi at deitcher.net Follow me http://twitter.com/avideitcher Read me http://blog.atomicinc.com