Grub4dos Beginner's Guide-1

Source: Internet
Author: User

for most Windows users who have little or no access to Linux, the menu is inseparable from the first use of grub. In other words, before using grub, we need to prepare the Menu.lst file.
Let's talk about some of the most common commands.
Help
used to show the use of other commands, examples:
Help Root
default
Specifies the default menu item, starting with 0, example: default 0 The command must be specified before the first title
Timeout
The default wait time, if no key is pressed at the specified time (in seconds), the default menu item is started, example: timeout 10 The command must be specified before the first title
Root
used to specify the root device, example: root (hd0,0)
rootnoverify
The command can also be used to specify the root device. Root before you set up the root device, test the partition's file system for recognition, and rootnoverify omit the test. Rootnoverify (hd0,0)
Chainloader
load the contents of the boot sector into memory, parameter +1 refers to the first sector of the partition, example: Chainloader +1
Boot
start the operating system. Before using this command, the system kernel or boot sector/boot file must be loaded into memory with kernel or chainloader. Example: Boot
you do not need to use this command in the configuration file. This is because grub automatically adds boot after all the commands for the menu item are executed. This command is typically used in the command line interface.


Grub4dos Advanced Features
Virtual Disk
The virtual disks in the Grub4dos are implemented by the map command. The functions of the map command are described below:
Disk Swapping
The Map command also exists in the Grub legacy as a disk exchange.
For example, you have two hard drives, but you have a bootable system on all two drives. When booting on the first hard drive, no special processing is required and the boot sector can be mounted directly with Chainloader. However, if you want to start from the second hard disk, then the use of Chainloader alone is not enough, because many operating systems are default from the first hard drive to mount the required files, if the file is not on it, the system will not be able to read successfully, resulting in a failure to start.
An original workaround is to modify the boot order in the BIOS and put the hard drive that needs to be started to the front. Then, after restarting the computer, the hard drive becomes the first hard drive, which can start normally, but this method is obviously cumbersome.
the map command in Grub can swap disks at run time without having to modify the BIOS. For example:


Title Boot first Partition on Second Disk

Map (hd0) (HD1)

Map (HD1) (hd0)

Chainloader (hd1,0) +1

Boot


In this example, the map command was used to Exchange (hd0) and (HD1). Note that the exchange takes effect only after the command is boot. So in the Chainloader command, the second hard drive is still being read.


Establish virtual disks
In Grub4dos, the use of the map command is greatly expanded. Use this command to create a virtual disk, for example:
Map the Aa.dsk file under the (hd0,0) root directory to the second hard drive and start with the system on the original hard disk:

Title Create Virtual Disk

Map (hd0,0)/aa.dsk (HD1)

Root (hd0,0)

Chainloader +1

Boot

(In this example, the Aa.dsk file in the (hd0,0) root directory is mapped to the first hard disk, and the original first is mapped to the second hard disk.) )

Booting from a virtual disk in the Aa.dsk:

Title Boot from Virtual Disk

Map (hd0,0)/aa.dsk (hd0)

Map (hd0) (HD1)

Map--hook

Root (hd0,0)

Chainloader +1

Boot

As mentioned above, mapping of MAP commands does not work immediately. But to start from the virtual disk, you have to read the data from it, so you need to make the mapping work early. The role of map--hook is to make the mappings specified by the previous Map command take effect immediately.

Map the Aa.img file under the (hd0,0) root directory to the first virtual floppy disk and start it from:

Title Boot from Virtual Floppy

Map (hd0,0)/aa.img (fd0)

Map--hook

Root (FD0)

Chainloader +1

Boot
After mapping in this way, the contents of the virtual disk and the contents of the image file are synchronized, that is, if you modify the contents of the virtual disk, the image file is also updated. If you restart the machine, the effect of the modification still exists.
When mapping using this method, the image file must be contiguous on disk .

The virtual disks created in the Grub4dos, including the memory disks described below, are implemented by intercepting the int 13来. Therefore, after booting the operating system, if the system is to access the disk through the int 13来, such as various DOS, then the virtual disk can still be accessed after entering the system. If the system uses other methods to access the disks, such as the Linux, Unix, and Winnt family of operating systems, then the virtual disk cannot be accessed after entering the system. But the classical system Win9x series is special, normally it uses the protected mode driver to access the disk, but if the appropriate driver is not found, Win9x uses the int 13来 to access the disk, so the virtual disk can also be accessed under Win9x.

Set up virtual memory disk
The use of map can also establish virtual memory disk, its usage is similar to the above, you just need to add the--mem parameter in the map to create a virtual disk command. Using this mapping method, the content of the image file is loaded into memory before mapping . So you have to have enough memory to hold the image and boot the system. Also, virtual disks and image files are detached, and changes made to the vdisk are not updated to the image file.
In this mapping, the storage of the image file on disk does not need to be contiguous.

Example: Map the Aa.dsk file (hd0,0) in the root directory to the first hard disk, the original first is mapped to the second hard disk, and is booted from the virtual disk in the Aa.dsk:

Title Boot from Virtual Disk

Map--mem (hd0,0)/aa.dsk (hd0)

Map (hd0) (HD1)

Map--hook

Root (hd0,0)

Chainloader +1

Boot


Map the Aa.img file under the (hd0,0) root directory to the first virtual floppy disk and start it from:

Title Boot from Virtual Floppy

Map--mem (hd0,0)/aa.img (fd0)

Map--hook

Root (FD0)

Chainloader +1

Boot



Automatically generate MBR
There are two types of image files. One is a file system image, which contains only data from one file system. The other is the disk image, which contains a structure similar to the physical hard disk, that is, the image begins with the MBR, then the file system data. For virtual memory disks, the structure is similar to a real hard disk, so you should use disk imagery when mapping using the map command.
Grub4dos considered the problem. To make the user's use more convenient, grub4dos made the following improvements: When the disk image is read into memory, the program detects its structure and, if it finds a file system image, automatically generates an MBR in front of it and turns it into a disk image. Therefore, regardless of whether the user chooses to use a file system image or a disk image, it will become the correct format when loaded into memory.
Automatic generation of MBR.

Another application is to generate virtual disks directly from the Mount partition on the hard disk. For example:
Title Load Partition from Disk

Map--mem (hd0,0) +1 (hd0)

(Note: In the map command, (hd0,0) +1 refers to the entire (hd0,0) partition, not the first sector (hd0,0). This representation is only applicable in the map command, in other places, (hd0,0) +1 is the original meaning. )

Map (hd0) (HD1)

Map--hook

Root (hd0,0)

Chainloader +1

Boot
The function of this menu is to load the first partition on the hard disk into memory and automatically precede it with an MBR-generated virtual disk. The virtual disk is then mapped to the first hard disk, and the original hard disk is mapped to the second hard drive. Finally, start from the virtual disk.

When you start using this menu, the contents of the system partition are the same as the original, but the virtual disk in memory is actually used. Changes to the partition disappear after restarting the machine.

The menu is to load the contents of the entire partition into memory, to determine that the memory is large enough, otherwise the command will not succeed.

Virtual Appliance (MD)
In Grub4dos, you can use the device (MD) to access the entire memory, just as with (ND) access the network device, using (CD) to access the disc similar.
Grub4dos also extends the cat command, which can be used with--hex for hexadecimal output, or--locate=string to search for strings in a file.
Example:
Cat--hex (hd0) +1 displays the MBR of the first hard disk in 16 binary form.
Cat--hex (hd0,0) +1 displays the boot sector for the first partition of the first hard drive in 16 binary form
The Cat--hex (MD) +2 Displays the contents of the memory start 1K in 16 binary form, which is actually the interrupt vector table.
The Cat--hex (MD) 0x800+1 displays memory in 16 binary form, from 0x800 * to 1M, starting with 512 bytes of content, which is 512 bytes from the expanded memory.
Virtual Appliance (RD)
The virtual device (MD) can access physical memory starting at address 0, while using (RD) can access memory starting at an address.
Map--rd-base=addr is used to set the start address (in bytes) of the (RD) memory device.
Map--rd-size=size the length (in bytes) used to set the (RD) memory device.
When booting Grub.exe as the Linux kernel, you can use the specified initial disk. After entering grub, the start address and length of the (RD) device are automatically set to the address and length of the initial disk. Therefore, you can access the initial disk in grub with (RD) devices.
Map--ram-drive=rd
The BIOS device name used to set the Access (RD) memory device. The default value is 0x7f, which indicates that the corresponding virtual disk (RD) is a floppy device. If the corresponding virtual disk (RD) is a hard disk device, you need to set up Rd, which makes 0x80< Rd < 0xFF.
Other parameters of Map
*--status
Used to display the current disk mapping. Map--status
*--floppies=m,--harddrives=n
Specifies the number of floppy disks/hard disks. Map--harddrvies=2 When you use this command, the number of local hard disks is set to 2.
*--memdisk-raw=raw
Raw takes a value of 0 or 1 (the default is 1). Raw=0, use int15/ah=87h to read extended memory.    Raw=1, use the internal function to read the extended memory. Map--memdisk-raw=0
*--SAFE-MBR-HOOK=SMH,--int13-scheme=sch
These two parameters are designed to work with virtual disks in Windows 9X.
SMH a value of 0 or 1 (the default is 1), you can try the following command when you have a problem using the virtual disk under Windows 9X: Map--safe-mbr-hook=0
The SCH value is also 0 or 1 (the default is 1), you can also try using the following command when you have a problem using the virtual disk in Windows 9X: Map--int13-scheme=0
*--read-only
With this parameter, the currently mapped disk is set to read-only mode. Map--mem--read-only (hd0,0)/aa.dsk (HD1)
*--fake-write
With this parameter, the disk that is currently mapped appears writable, but the content written is discarded. Map--mem--fake-write (hd0,0)/aa.dsk (HD1)

Grub4dos Beginner's Guide-1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.