- Timestamp:
-
12/14/19 20:58:04 (5 years ago)
- Author:
-
Tony Richardson
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v27
|
v28
|
|
218 | 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 | 219 | |
220 | | 2) 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. |
| 220 | 2) 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 an "msdos" 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. |
221 | 221 | |
222 | 222 | A) I just used the default options during the SystemRescueCD boot. |
223 | 223 | |
224 | | B) The default partition table type is "msdos", use the drop-down |
225 | | menu to change this to "gpt". An msdos (MBR) partition table works |
226 | | fine also and in that case you only need to create a single FAT32 |
227 | | partition, I just decided to go with the newer gpt table. |
228 | | |
229 | | C) The grub partition can be of any type (it won't be formatted), |
| 224 | B) The grub partition can be of any type (it won't be formatted), |
230 | 225 | I just used the default ext4. |
231 | 226 | |
232 | | D) Aligning the partitions to a cylinder instead of a Megabyte |
| 227 | C) Aligning the partitions to a cylinder instead of a Megabyte |
233 | 228 | prevents some mtools warnings that may occur later. |
234 | 229 | |
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. |
| 230 | D) 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 | 231 | |
237 | 232 | 3) Open a terminal window and mount the new partition by entering: |
… |
… |
|
249 | 244 | An "ls /mnt/custom" command should now show a "boot" directory. Shut down the virtual machine. |
250 | 245 | |
251 | | A) In order to use mtools you need to know the byte offset to the |
252 | | start of the FAT partition. You can probably calculate this |
253 | | offset using information from GParted or sfdisk. I find it |
254 | | easier to open the disk file in a binary editor (later - from within the host OS) and search for |
255 | | a particular string in the boot sector. The following command |
256 | | will display the boot sector in hex and ASCII: |
257 | | |
258 | | {{{ |
259 | | dd count=1 < /dev/sda2 | hexdump -C |
260 | | }}} |
261 | | (When I do this is see the string "mkfs.fat" starting at the |
262 | | fourth byte in the sector. This is the string I search for.) |
263 | | |
264 | | |
| 246 | |
265 | 247 | 4) Use the VirtualBox Virtual Media Manager to change the type of the VHD disk from "normal" to "immutable". This will prevent VirtualBox from opening the disk image with write-access. This detaches the disk from the Virtual Machine, so you will need to reattach it. Remove the SystemRescueCD from the machine. Restart the Virtual Machine (booting it from the new virtual drive now) and verify that it boots to a grub prompt. |
266 | 248 | |
… |
… |
|
269 | 251 | read-only is perhaps more desirable, VirtualBox will not allow you to use |
270 | 252 | the read-only type with hard disk images.) |
271 | | |
| 253 | |
| 254 | == Alternative Method (FreeDOS) == |
| 255 | The method above creates a single virtual disk that contains RTEMS applications. I find it convenient to install FreeDOS to a first (dynamically sized) virtual disk and then use a second (fixed size) disk to hold RTEMS applications. After installing FreeDOS, attach the virtual disk to a SystemRescueCD machine and install GRUB to the disk. You can use the methods below to copy RTEMS applications to the second disk. You can also boot FreeDOS to manage the files on the second disk. |
| 256 | |
| 257 | |
272 | 258 | == Accessing the Disk Image from the Host == |
273 | 259 | There are several ways to read and write files to the disk image |
… |
… |
|
286 | 272 | |
287 | 273 | I 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. |
| 274 | |
| 275 | Alternatively you can let mtools know that the image is a partitioned image and use a .mtoolsrc file like this: |
| 276 | |
| 277 | {{{ |
| 278 | drive r: |
| 279 | file="c:/Users/ar63/VirtualBox VMs/RTEMS/RTEMSGPT.vhd" |
| 280 | partition=2 |
| 281 | }}} |
| 282 | |
288 | 283 | |
289 | 284 | The 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: |
… |
… |
|
299 | 294 | }}} |
300 | 295 | |
301 | | mtools works fine under Cygwin on Windows. When using mtools from MSYS or MSYS2 on Windows you must use the -i option to specify the image. (You can not use drive letter notation because mtools can not differentiate between the image and a host drive.) |
| 296 | I've used mtools without problem under Cygwin and Msys2. When building under Msys2 be sure to use the Msys2 shell instead of one of the MinGW shells. |
302 | 297 | |
303 | 298 | === Disk Management Tool (Windows) === |