I am trying to work out a few details for a dual boot, public use (i.e. public library context) that runs Windows 7 and Linux.

I am using Windows 7 and Linux Mint. Windows 7 runs on a VHD file (filesystem image like squashfs in Linux). I need grub to copy different BCD and VHD files into place before it boots Windows.

The strategy is to copy a different BCD file into place to change the default boot from WinPE (used to boot Windows in a maintenance mode), to booting the VHD file that boots a snapshot (i.e. a baseline Windows configuration) and if I could do that within the grub2 bootloader it would be ideal.

I am using the free "Steadier State" (http://www.steadierstate.com/) as the basis for booting from VHD. It requires 2 boot cycles to insure that every system restart boots a consistent baseline.

Although out of the box SS does not provide a way for every reboot to start a baseline system, I added a system shutdown script that uses bcdedit to switch the default OS to boot. It switches it from booting the VHD file to booting WinPE, which evaluates conditions and if they're right removes then recreates the child "snapshot.vhd", then changes the default boot back to snapshot.vhd and then exits, causing the baseline Windows OS to be booted.

If grub2 could copy files, I could eliminate the need to boot WinPE just to recreate the snapshot.vhd and switch the default OS to boot.

BTW, grub2 always chainloads bootmgr if "Windows 7" is chosen. The /boot/BCD file tells bootmgr what to boot. There are only 2 boot entries in that BCD, one for "Windows 7" (i.e. it boots snapshot.vhd) or "Admins Only!" that boots WinPE. The timeout in the BCD is always set to zero so you never see the bootmgr menu.

The way maintenance is done is by inserting a USB stick which (when detected) changes the bootmgr to boot WinPE so updates to the baseline can be merged in.

  • I managed to find the info about how to build grub2 with the lua module (search for grub-extras), and I have been successful in running some lua code under grub2. However, I still haven't found a way to copy files under grub2 using lua. Lua is often used as a way to provide scripting capabilities to applications. The lua context provided by the application can be highly restricted or very unrestricted, depending on what application requires. Lua gets some things done via "os.execute", but in the case of grub2 which is an OS bootloader, there is no such call available. Need to find docs.
    – motech man
    Jun 13, 2016 at 16:32
  • I am doubtful file copying is possible with grub2, with or without lua support. moi.vonos.net/linux/Booting_Linux_on_x86_with_Grub2/… says grub2 doesn't implement file write functionality. The lua of "grub-extras" doesn't provide an "os" or "io" object. Most of the grub2 lua capabilities are provided by grub.run(<string>). So if grub2 doesn't provide file write capability then I highly suspect grub2's lua programs will also suffer from that limitation.
    – motech man
    Jun 13, 2016 at 17:57


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.