Changes between Version 24 and Version 25 of Developer/VirtualMachines/VirtualBox


Ignore:
Timestamp:
Feb 6, 2018, 5:21:19 PM (18 months ago)
Author:
Tony Richardson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Developer/VirtualMachines/VirtualBox

    v24 v25  
    195195= Booting RTEMS from a Virtual Drive =
    196196
    197 As an alternative to booting RTEMS applications from the virtual network via TFTP you can also boot them from a virtual drive.
    198 
    199 Although creating a virtual drive suitable for booting RTEMS is not trivial, booting RTEMS applications from the drive is almost as easy as booting them via TFTP.  A TFTP server is not required.
    200 
    201 A few methods for transferring files from the host to the virtual drive (and back) are discussed below.
     197As an alternative to booting RTEMS from the virtual network via TFTP it can also be booted from a virtual drive.
     198
     199Booting RTEMS from a virtual drive is almost as easy as booting it via TFTP.  A TFTP server is not required, but you will need some way to transfer files from the host to the virtual drive.  A few methods for doing this are discussed below.
    202200
    203201== Creating the Disk Image ==
    204202
    205 You will need a Linux SystemRescueCD image to partition the virtual drive, format the partition and install GRUB. http://www.system-rescue-cd.org/. You only need to attach this CD image to the virtual machine when you create the virtual drive.
    206 
    207 1) Create a new virtual machine with a fixed-size, VHD hard disk. Attach the SystemRescueCD image as the optical drive.
     203You will need a Linux [http://www.system-rescue-cd.org/ SystemRescueCD] image to partition the virtual drive, format the partition and install GRUB. You only need to attach this CD image to the virtual machine when you create the virtual drive.
     204
     2051) Create a new virtual machine with a fixed-size, VHD hard disk. (Be sure to create a VHD disk and not a VDI or VMDK disk.)  Attach the SystemRescueCD image as the optical drive.
    208206   
    209207   A) I created a 32-bit Ubuntu compatible machine.  (It has to have
     
    212210   after the disk is created.) 
    213211
    214    B) You can probably use a dynamically sized disk if you only
    215    want to mount the disk from Windows.  A VHD fixed-size disk
    216    is just a hard disk image with a footer, so you can mount
    217    it in Linux (via loopback) and/or access it with mtools (or other hard disk
    218    image manipulation tools).  I created a 50 MB hard disk.
    219 
    220 2) Boot the virtual machine from the SystemRescueCD.  Startup the graphical interface by typing "startx" at the command prompt.  Start the "GParted" tool from the "System" menu.  Create a "gpt" partition table on the disk (from the Device menu).  Create a new 1 MB primary, ext4 partition for grub (the boot manager). Align the partition to a cylinder. Create a second primary, FAT32 partition that takes up the remainder of the space.  Again, align the partition to a cylinder (not necessary if you don't intend to use mtools).  Be sure to apply the operations by clicking on the big green check mark.  Right-click on the first partition (/dev/sda1), select "Manage Flags" and click on "bios_grub". Right-click on the second partition (/dev/sda2) and format to FAT32. Close GParted.
     212   B) You can probably use a VHD dynamically sized disk if you only
     213   want to mount the disk from Windows (using the Disk Management tool). A VHD
     214   fixed-size disk is just a hard disk image with an added footer, so you can
     215   mount it in Linux (via loopback) and/or access it with mtools (or other hard
     216   disk image manipulation tools).  I created a 50 MB hard disk.
     217
     218   C) Fixed-size VDI or VMDK disks may also work.  If they are just disk images with an added header or footer they probably would.  In that case you can transfer files from the host using mtools or using a Linux loopback device.  Windows only has built-in support for attaching to VHD type disks, so that is what I chose.
     219
     2202) Boot the virtual machine from the SystemRescueCD.  When you get to a command prompt, startup the graphical interface by typing "startx".  Start the "GParted" tool from the "System" menu.  Create a "gpt" partition table on the disk (from the Device menu).  Create a new 1 MB primary, ext4 partition for grub (the boot manager). Align the partition to a cylinder. Create a second primary, FAT32 partition that takes up the remainder of the space.  Again, align the partition to a cylinder (not necessary if you don't intend to use mtools).  Be sure to apply the operations by clicking on the big green check mark.  Right-click on the first partition (/dev/sda1), select "Manage Flags" and click on "bios_grub". Right-click on the second partition (/dev/sda2) and format to FAT32. Close GParted.
    221221
    222222   A) I just used the default options during the SystemRescueCD boot.
     
    233233   prevents some mtools warnings that may occur later.
    234234
    235    E) You can choose filesystems other than FAT, but you want to choose something that is understood by both GRUB and the host operating system.
    236 
    237 3) From a terminal window, mount the new partition by entering:
     235   E) You can choose filesystems other than FAT, but you want to choose something that is understood by both GRUB and your host operating system.
     236
     2373) Open a terminal window and mount the new partition by entering:
    238238
    239239{{{
     
    277277
    278278=== mtools (Windows, Linux) ===
    279   Download the mtools archive (https://www.gnu.org/software/mtools/).  I use mtools from Windows, but you
    280   need a UNIX build environment.  I use cygwin.  My .mtoolsrc file
    281   looks like this:
     279Download the [https://www.gnu.org/software/mtools/ mtools] source code archive. Extract the source code and build and install the tools.  You will need a UNIX-like build environment.  I use Windows, and have successfully built and used mtools from cygwin. 
     280
     281You will want to create an .mtoolsrc configuration file in order to simplify using mtools with your virtual disk.  My .mtoolsrc file looks like this:
    282282
    283283{{{
     
    286286}}}
    287287
    288   I found the offset by opening the VHD file in a binary editor and
    289   searching for a string (mkfs.fat) in the boot sector.  The offset
    290   should be to the beginning of the boot sector not the string!  The
    291   offset should be a multiple of 512, so find the nearest multiple
    292   of 512 below the string location.
    293  
    294   The mtools work directly with the fat file system on the image.
    295   There is no need to mount the image.  mdir gives a directory
    296   listing of the current directory on the image. mcd changes
    297   current directories on the image.  mcopy copies files to and
    298   from the image.  mtype displays the contents of a file.  There
    299   is no medit, but you can copy a file from the image to the host,
    300   edit it and then copy it back.  Here are a few example commands:
     288I found the offset by opening the VHD file in a binary editor and searching for a string (mkfs.fat) in the boot sector.  The offset should be to the beginning of the boot sector not the string!  The offset should be a multiple of 512, so find the nearest multiple of 512 below the string location.
     289
     290The mtools work directly with the fat file system on the image. There is no need to mount the image.  mdir gives a directory listing of the current directory on the image. mcd changes current directories on the image.  mcopy copies files to and from the image.  mtype displays the contents of a file.  There is no medit, but you can copy a file from the image to the host, edit it and then copy it back.  Here are a few example commands:
    301291
    302292{{{
     
    310300}}}
    311301 
    312   I have not been able to get mtools to work properly when built from
    313   MSYS or MSYS2.  The directory tools and the tools that copy to the
    314   image seem to work fine, but I can't copy from the image to the host
    315   or use mtype to display the contents on the disk image.
     302I have not been able to get mtools to work properly when built from MSYS or MSYS2.  The directory tools and the tools that copy to the image seem to work fine, but I can't copy from the image to the host or use mtype to display the contents on the disk image.
    316303
    317304=== Disk Management Tool (Windows) ===
    318   Use the Disk Management Tool to attach the VHD to the system (from
    319   the Action menu).  Use the Windows Explorer to copy/edit files on
    320   the disk image.
     305Use the Disk Management Tool to attach the VHD to the system (from
     306the Action menu).  Use the Windows Explorer to copy/edit files on
     307the disk image.
    321308 
    322   Write-caching may cause files written to the image from the host to
    323   not be immediately visible in the Virtual Machine. However, when I
    324   try to turn write-caching off, Windows disconnects the image.  It
    325   is probably safest to detach the image after accessing it from the host.
    326   Sysinternals provides a "sync" command that can help with this issue.
     309Write-caching may cause files written to the image from the host to
     310not be immediately visible in the Virtual Machine. However, when I
     311try to turn write-caching off, Windows disconnects the image.  It
     312is probably safest to detach the image after accessing it from the host.
    327313
    328314=== Loopback Device (Linux) ===
    329   Enter the commands:
     315Enter the commands:
    330316   
    331317{{{
     
    334320}}}
    335321 
    336   or as a single command:
     322or as a single command:
    337323
    338324{{{ 
     
    340326}}}
    341327 
    342   You will need to find the correct offset to the start of the
    343   FAT partition.
     328You will need to find the correct offset to the start of the FAT partition.
    344329
    345330== Using GRUB ==
     
    348333
    349334{{{
    350         multiboot (hd0,2)/hello.exe
    351         boot
     335multiboot (hd0,2)/hello.exe
     336boot
    352337}}}
    353338       
     
    355340disk.
    356341
    357 It is a lot easier to use the grub menu.  Grub looks for a file named
    358 grub.cfg in the boot/grub directory.  I find it more convenient to
     342It is a lot easier to use the grub menu to load RTEMS.  Grub looks for a file named grub.cfg in the boot/grub directory.  I find it more convenient to
    359343keep my configuration file in the root directory of the image.  I do this
    360344by creating a grub.cfg file in the boot/grub directory that looks like
     
    362346
    363347{{{
    364     configfile (hd0,2)/grub.cfg
     348configfile (hd0,2)/grub.cfg
    365349}}}
    366350
     
    370354
    371355{{{
    372         menuentry "HELLO" {
    373           multiboot (hd0,2)/hello.exe
    374         }
    375 
    376         menuentry "tftp" {
    377           insmod chain
    378           set root=(fd0)
    379           chainloader +1
    380         }
    381 
    382         menuentry "reboot" {
    383           reboot
    384         }
     356menuentry "HELLO" {
     357  multiboot (hd0,2)/hello.exe
     358}
     359
     360menuentry "tftp" {
     361  insmod chain
     362  set root=(fd0)
     363  chainloader +1
     364}
     365
     366menuentry "reboot" {
     367  reboot
     368}
    385369
    386370}}}
     
    389373This allows you to either boot RTEMS applications from the virtual disk or via TFTP.
    390374
    391 = Serial Port Access =
     375= Serial Port Access (Linux Host) =
    392376
    393377