Ubuntu dual system installation tutorial and troubleshooting, ubuntu Dual System

Source: Internet
Author: User
Tags root access gparted

Ubuntu dual system installation tutorial and troubleshooting, ubuntu Dual System
Preparations for dual-system installation

At least two USB flash drives are required. One is used as the ubuntu boot disk and the other is used as the windows 7 boot disk. The method can be rufus or UltraISO. We recommend the former. All images of the operating system are written into the USB flash disk. In advance, important data in the USB flash disk should be backed up. The USB flash disk will be formatted during the production process ., In windows, you can create a winpe boot disk to restore the ghost image.

Two Disks and two systems

There are many dual-disk installations. If the two systems are respectively mounted on two different disks, the simplest way is to make the two disks into disks with active partitions, install the two systems separately, and modify the startup sequence to guide the two systems during the boot. This is suitable for users who do not often switch the system. The installation is very simple and it is a little troublesome to use. Of course, you can also create a dual boot mode, which is similar to the multi-partition mode of the following disk.

Install the Windows system first and then ubuntu

This is very simple. Install the windows system with the windows USB flash drive. After the installation is successful, use the ubuntu USB flash drive to install the ubuntu system. The premise is that in the case of a disk, you need to prepare a suitable partition space for both systems.

Install ubuntu first and then windows

Windows is easy to install ubuntu, but how does one install windows under ubuntu to form a dual system? Next we will focus on this situation.

System Environment: ubuntu16.04LTS. Install windows 7-64 bits.

For the sake of insurance, we still need to back up important materials as follows. Linux system backup is simple, as shown below:

Backup and recovery of linux systems

(This step can be omitted if the information is not important)

Backup System

How can I back up my Ubuntu system? It's easy to use TAR just like backing up or compressing other things. Unlike Windows, Linux does not limit root access to anything. You can throw everything in the partition to a TAR file!

First become a root user:

$ sudo su

Then enter the root directory of the file system (if you do not want to back up the entire file system, you can also enter the directory you want to back up, including the remote directory or the directory on the mobile hard disk ):

# cd /

The following is the complete command used to back up the system:

# tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/media /

Let's take a simple look at this command:

"Tar" is of course the program used by the backup system. "Cvpfz" is the tar option, which means "create a file", "retain Permissions" (Retain the original permissions for everything), and "use gzip to reduce the file size ". “Backup.gz "is the file name of the file to be obtained. "/" Is the directory to be backed up. Here it is the entire file system. The directory that must be excluded from the backup is provided between the file name "backbackup.gz" and the directory name "/" to be backed up. Some directories are useless, such as "/proc", "/lost + found", and "/sys ". Of course, the “backup.gz file must be excluded, otherwise you may get some results beyond common sense. If "/mnt" is not excluded, other partitions mounted on "/mnt" will also be backed up. In addition, make sure that "/media" does not mount anything (such as a CD or a mobile hard disk). If there is a mount, "/media" must also be excluded. Some people may suggest you exclude the "/dev" directory, but I think this is very inappropriate. The specific reason is not discussed here. Before executing the BACKUP command, check whether the command you typed is what you want. It may take a short time to execute the BACKUP command. You must exclude such large files as image files that can be copied. After the backup is complete, a file named "backup. tgz" will be generated in the root directory of the file system. The file size may be very large. Now you can burn it to a DVD or put it somewhere you think is safe. At the end of the Backup command, you may see the following prompt: 'tar: Error exit delayed from previous
Errors, you can ignore it in most cases. You can also use Bzip2 to compress files. Bzip2 has a higher compression ratio than gzip, but it is slower. If the compression rate is important to you, you should use Bzip2, replace "z" in the command with "j", and give the file a correct extension "bz2 ". The complete command is as follows:
# tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 –exclude=/mnt –exclude=/sys /
Restore System

Be careful when restoring the system! If you do not know what you are doing, you may lose important data. Be careful!

Next, we use the example above. Switch to the root user and copy the file "backup. tgz" to the root directory of the partition.

One wonderful thing in Linux is that you can restore the system in a running system without using boot-cd for special guidance. Of course, if your system has crashed and cannot be started, you can use Live CD to start it. The effect is the same. You can also use a command to kill all files in Linux. Of course, I am not going to give this command here!

Run the following command to restore the system:

# tar xvpfz backup.tgz -C /

If your archive file is compressed using Bzip2, use:

# tar xvpfj backup.tar.bz2 -C /

Note: The preceding command overwrites all files in the partition with files in the archive file.

Before executing the recovery command, check whether the command you typed is what you want. It may take a short time to execute the recovery command.

At the end of the recovery command, your work has not been completed. Do not forget to recreate the directories excluded during Backup:

# mkdir proc# mkdir lost+found# mkdir mnt# mkdir sys

Wait, when you restart your computer, you will find everything is restored to the way you created the backup!

It is important that, if the recovered computer is not the original computer, you need to have a system with the backup system version one to the system on the computer to be restored, it is best to reinstall it, then, set/boot/, initrd. img and vmlinuz are backed up to other locations. After recovery, these locations are restored to the original location to prevent incorrect guidance caused by inconsistent uuid.

Disk space needs to be moved for windows systems

Ubuntu and windows should be installed in two different partitions of the hard disk. If you have idle partitions, you can skip the following section. If you have installed ubuntu on a whole hard disk, you need to make room for it on the hard disk when installing windows. You can use the disk partition tool of peat to adjust the disk partition size, or use the partition tool of ubuntu to adjust the partition size, as shown below:

First, plug in the ubuntu BOOT disk, BOOT into the boot menu (different computer interfaces), select USB items. You can use either ubuntu or ubuntu to install ubuntu. On the next page, select the following options and continue. Select the partition to be adjusted from the partition list displayed on the next page. Click change in the lower left corner. The edit partition dialog box is displayed. The size is the size you want to retain for the original system, that is, ubuntu. For example, if I have a total size of 150 GB and want to split Windows 7 into 50 GB, change to around GB here and click OK. Go back to the original page and select ubuntu for trial. Ctrl + alt + t open the terminal and run

sudo gparted

The gparted tool will be opened, right-click the gray unallocated area, create and format a file system in ntfs format (after the operation is complete, remember to click the application above the interface), and shut down.

Install win7

Plug in the boot disk of Windows 7 after shutdown. Similar to opening the boot disk of ubuntu, install Windows 7 in the new partition.

After the installation is complete, the system will automatically enter the windows system. If the system is restored by the ghost, it will not automatically enter the windows system. This will be the case later. That is, there is no more boot, and the startup item needs to be fixed.

Fix startup items

After shutdown, insert the ubuntu boot disk and enter the ubuntu Desktop.

Sudo fdisk-l (L in lower case)

Output content:

Disk/dev/sda: 119.2 GiB, 128035676160 bytes, 250069680 sectorsUnits: sectors of 1*512 = 512 bytesSector size (logical/physical ): 512 bytes/512 bytesI/O size (minimum/optimal): 512 bytes/512 bytesDisklabel type: dosDisk identifier: 0x04bcd6c6 device Start end sector Size Id type/dev/sda1 * 2048 234041343 234039296 111.6G 83 Linux/dev/sda2 234043390 250068991 16025602 7.7G 5 extension/dev/sda5 234043392 250068991 16025600 7.7G 82 Linux switch/SolarisDisk/dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectorsUnits: sectors of 1*512 = 512 bytesSector size (logical/physical): 512 bytes/512 bytesI/O size (minimum/optimal ): 512 bytes/512 bytesDisklabel type: dosDisk identifier: 0x853aba59 device Start end sector Size Id type/dev/sdb1 * 2048 167776255 167774208 80G 7 HPFS/NTFS/exFAT/dev/sdb2 167776256 976773119 808996864 385.8G f W95 extension (LBA) /dev/sdb5 167778304 976773119 808994816 385.8G 7 HPFS/NTFS/exFAT

I have two disks. We can see that they are all made into Boot disks.

Among them, sda is the first disk, sdaX is my ubuntu partition, sdb is the second disk, and sdaX is the win7 partition. Each person may have a different situation. Please identify it by yourself. /Dev/sdb1 is divided into 80 GB to install win7.

Next, enter the terminal

Sudo-I (get the root permission without entering the password for the following operations) mkdir/media/tempdir (the one used to mount sda1 is to create a tempdir and set its own name or something) mount/dev/sda1/media/tempdir (mount sda1 to tempdir) grub-install -- root-directory =/media/tempdir/dev/sda (reinstall the Master Boot Record from grub2 to hard disk (mbr ))

Successful Operation: Installation finished. No Error Reported.

After the restart, you can enter the original ubuntu system, but windows cannot be guided for the time being. The following is how to update grub2 so that it can Boot windows 7. Enter the system, open the terminal, and enter

sudo update-grub2  
Generating grub configuration file ...  Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.  Found linux image: /boot/vmlinuz-3.13.0-37-generic  Found initrd image: /boot/initrd.img-3.13.0-37-generic  Found memtest86+ image: /boot/memtest86+.elf  Found memtest86+ image: /boot/memtest86+.bin  Found Windows 7 (loader) on /dev/sda2  done  

Restart your computer to find the win7 boot menu and boot the system normally.

Grub missing Ubuntu boot Item Repair

GRUB is the default boot program used by most Linux systems. You can choose to enter different operating systems (if any) through the boot menu ).

When "/boot/grub. if the conf configuration file is lost, the key configuration is incorrect, or the boot program in the MBR record is damaged, only the "grub>" prompt appears after the Linux host is started, unable to complete further system startup process.

error : unknow filesystemgrub rescue>

This indicates that your grub2 configuration file is corrupted. Grub cannot find the boot item of the Ubuntu system, and thus enters the repair mode (grub rescue), also known as the rescue mode. In rescue mode, only a few commands can be used: set, ls, insmod, root, and prefix.

Command description set to view environment variables. Here you can view the startup path and partition ls to view the partitions specified by the device insmod loading module root for system startup, set the grub startup partition prefix in rescue mode to set the grub startup path

The repair procedure is as follows:

View partitions
Grub rescue> ls list disk partitions (hd0) (hd0, msdos9) (hd0, msdos8) (hd0, msdos7) (hd0, msdos6) (hd0, msdos5) (hd0, msdos2) (hd0, msdos1
Find the ubuntu Partition

Is to find the partition in which your Linux system is installed

grub rescue> ls (hd0,msdos1)/

If unknown filesystem appears, try the next one. If the name of the folder and file in your main ubuntu folder is displayed, It is the partition you are looking. You can use ls (hd0, msdosX)/boot/grub to view the specific content. Next, run the Set command to Set root and prefix.

Assume that the boot partition you found is (hd0, msdos8)

Enter the startup Item
Grub rescue> set // view the current grub rescue> root = (hd0, msdos5) grub rescue> prefix =/boot/grub // grub path setting grub rescue> set root = (hd0, msdos8) // modify grub rescue> set prefix = (hd0, msdos8) /boot/grubgrub rescue> insmod normal // start normal to start grub rescue> normal

Then you will see the familiar Start Menu Bar.

After you enter the system startup option interface, you still cannot enter it because you have not actually modified grub. You need to modify it in ubuntu to enter the system startup Item interface, and press C to enter the command line mode.

Grub> set root = hd0, msdos8grub> set prefix = (hd0, msdos8) /boot/grubgrub> linux/vmlinuz-xxx root =/dev/sda8 // you can press the Tab key in xxxx. If there is an acpi problem, add acpi = offgrub> initrd/initrd. img-xxx-xxxgrub> boot

If the grub configuration is not damaged, you can access the system normally. If the above method cannot start the system, you need to recreate grub. See the following.

Go to ubuntu to repair grub

In fact, the previous operation has restored the boot item. After we enter Ubuntu, we can update the GRUB boot item and run it on the terminal.

sudo update-grubsudo grub-install /dev/sda

/Dev/sda is an activated boot disk.

Recover from boot disk or reinstall GRUB

The premise of the previous method is that Grub boot can still be used, but the Ubuntu boot item is lost. If our Grub has been damaged or lost, you need to use a CD or USB flash drive to enter a Linux system that can be used or repaired to re-install GRUB.

Put the system CD into the optical drive or USB flash drive and restart the Linux system. press the "F2" key when the system starts, enter "linuxrescue" at the "boot:" prompt, and press enter to go to "emergency mode" to boot the Linux system on the CD.

Then, press the Enter key to receive the default language and keyboard format. The system prompts whether to set the NIC to "NO ", then the system will automatically find the Linux partition in the hard disk and try to mount it to the "/mnt/sysimage" Directory (select "Continue" to confirm and Continue ).

Next, pay special attention: when there is a warning window on whether to initialize the disk, You must select "NO" to avoid further damage to the hard disk data. finally, click OK to go To the Bash Shell environment with the sh-x.x # prompt.

If you are not at ease with this method, you can also select "Try ubuntu" when starting, that is, to load the system from the USB flash drive or optical drive, not from the hard drive.

If the MBR sector boot program is not damaged, check the mounting status of the Linux system partition to be repaired, and re-repair the grub. conf file without modification. See the following.

If the MBR sector boot program is corrupted, the system cannot be started even after the grub. conf configuration file is rebuilt. In this case, you can use grub-install to reinstall grub in the shell environment of emergency mode.

Next we will focus on the second case. In the first case, if you do not modify the grub. conf file, you can use this method.

Select the disk installed on Ubuntu. If you are not sure which disk the disk is on, run the following command to check the disk.

sudo fdisk -l

Mount the Ubuntu system to install the disk (my disk is 0th, so it is sda0)

sudo mount /dev/sda0 /mnt

Start to restore grub2 system boot

sudo grub-install --root-directory=/mnt/dev/sda

After the command is executed, if no error is reported, it is restored successfully and restarted.

After restoration, the previous system boot interface is displayed. If the newly installed system is not displayed on the page, you can go to the Ubuntu system, update grub/grub2, open the terminal, and enter

sudo update-grub2

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.