Article Title: Automatic OS switching on a dual-boot Linux System. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Using the techniques described in this article, we can automatically switch from one operating system to another on a dual-boot machine without any manual intervention. You can use the script provided in this article to copy the script on your own machine and run Linux at the same time? And Windows? .
Since we can switch the operating system directly and manually, why do we still want to automate this operation? The simple answer is that automated processes make it much easier to use multiple operating systems. For example, if you want to test software on multiple operating system platforms, this function is particularly useful.
This article introduces these tips, assuming that you have installed the operating system and configured multiple boot with GRUB. GRUB is short for GRand uniied Bootloader. It is loaded when the machine starts, and the control of the machine is transferred to the OS Kernel software. For more information about how to deploy GRUB, see references later in this article.
The skills described in this article can be applied:
Microsoft? Windows XP Professional Microsoft Windows Server 2003 Debian Linux 3.1 (Sarge)
Red Hat Enterprise Server (RHES) 3 GRUB 0.97; although GRUB of this version is successfully used, other bootloaders cannot be used. Step 1. Set Disk Partitions
Before you start configuring the system, make sure that you have an up-to-date system backup and a CD for assistance. If problems occur during these steps, the machine may fail to start. If you find that your risks are unacceptable, do not proceed with the following steps.
Create a Bootcontrol Partition
Create a Small Partition on a hard disk. A file system must be created in this partition: all operating systems to be switched can load the file system and write the file. We chose FAT32. although the entire Bootcontrol system only requires less than 1 MB of disk space, FAT32 is limited to 256 MB by default, which wastes some space.
If you do not have enough unallocated space, you can narrow down or delete existing partitions to create this space. In Linux, you can use the GNU parted command to implement this function. If the order of the existing partitions changes after the parted operation is executed, you may need to update the/etc/fstab file. For more information, see the parted documentation.
When you use parted to create the required partition on the test machine, you will see the results shown in Listing 1:
List 1. Create required partitions
Reton :~ # Cat/etc/fstab
#/Etc/fstab: static file system information.
#
Proc/proc defaults 0 0
/Dev/hda2/ext3 defaults 0 1
/Dev/hda6/home ext3 defaults 0 2
/Dev/hda7/opt ext3 defaults 0 2
/Dev/hda5 none swap sw 0 0
/Dev/hdc/media/cdrom0 iso9660 ro, user, noauto 0 0 0
/Dev/fd0/media/floppy0 auto rw, user, noauto 0 0
Reton :~ # Umount/home
Reton :~ # Parted
Using/dev/hda
(Parted) print
Disk geometry for/dev/hda: 0.000-57231.562 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 18412.734 primary ntfs boot
2 18418.271 25085.874 primary ext3
3 25085.874 57231.562 extended
5 25085.905 26458.615 logical linux-swap
6 26458.646 49999.174 logical ext3
7 49999.206 57231.562 logical ext3
(Parted) resize 6 26458 49739
(Parted) mkpartfs logical fat32 49739 49999
(Parted) print
Disk geometry for/dev/hda: 0.000-57231.562 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 18412.734 primary ntfs boot
2 18418.271 25085.874 primary ext3
3 25085.874 57231.562 extended
5 25085.905 26458.615 logical linux-swap
6 26458.646 49740.314 logical ext3
8 49740.346 49999.174 logical fat32
7 49999.206 57231.562 logical ext3
(Parted) q
Reton :~ # Mount/home
Mount Linux partitions
After creating a space for the control partition, You need to mount it to Linux so that you can see the partition in Linux. In this example, we add the following content to/etc/fstab:
# /Dev/hda8/boot/control vfat umask = 022, dmask = 022, fmask = 022 0 2 and then use the following command to create a mount point and mount the file system:
Mkdir/boot/control mount/boot/control
You also need to update the maintenance information of GRUB on the partition result. In this test system, we use the following command: grub-install/dev/hda.
Mount Windows partitions
By Manually restarting Windows, verify that the preceding partition editing step does not disrupt the Windows boot process. Then assign a drive character to the created Bootcontrol volume. On Modern Windows, you can use Computer Management MMC snap-in (right-click My Computer and choose Manage ). In previous versions, you can select Start> Administrative Tools.
[1] [2] Next page