安装Windows和linux双系统的时候最好是先装Windows,然后安装linux。因为linux可以寻找硬盘下的Windows系统,从而显示引导菜,而先装linux再装Windows,Windows会重写MBR,导致Linux的启动项丢失。
ubuntu@ubuntu :~$ sudo -i #切换到root用户身份
显示结果类似如下信息:
Disk /dev/sda: 500.1 GB, 500107862016 bytes#此处的/dev/sda代表电脑硬盘
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf0b1ebb0
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3825 30724281 7 HPFS/NTFS
/dev/sda2 3826 60802 457661193 f W95 Ext'd (LBA)
Partition 2 does not end on cylinder boundary.
/dev/sda5 3826 11474 61440561 7 HPFS/NTFS
/dev/sda6 11475 26772 122881153+ 7 HPFS/NTFS
/dev/sda7 26773 42070 122881153+ 7 HPFS/NTFS
/dev/sda8 42071 54427 99257571 7 HPFS/NTFS
/dev/sda9 54428 54610 1464320 82 Linux swap / Solaris
/dev/sda10 54610 60802 49734656 83 Linux#此行为Linux分区,记下此Device名称
Disk /dev/sdb: 1977 MB, 1977614336 bytes#此处的/dev/sdb代表自启动U盘
61 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 3782 * 512 = 1936384 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00044e7e
Device Boot Start End Blocks Id System
root@ubuntu :~# mount /dev/sda10 /mnt#将/dev/sda10代表的Linux分区挂载到/mnt目录下
root@ubuntu :~# mount /dev/sda6 /mnt/boot#将(如果没有/boot单独分区这不跳过)
root@ubuntu :~# grub-install --root-directory=/mnt/ /dev/sda#安装grub,如果正常的话会显示如下信息。
(注意是/mnt/(此处有空格)/dev/sda)
Installation finished. No error reported.
5.重启
root@ubuntu :~# reboot#重启电脑,你将会看到熟悉的grub启动界面!
1、用安装Ubuntu的光盘启动live cd(如果原先是用u盘安装的同学,可以使用u盘启动盘代替live cd,效果一样,本人用的是thinkpad,在启动时按F12,选择从usb启动,按照默认进入linux系统)
ubuntu@ubuntu :~$ sudo -i #切换到root用户身份
root@ubuntu :~# fdisk -l#查看电脑磁盘分区情况,以下为显示结果,此结果因机器而异。在其中查找“System”列为“Linux”的分区,并记下Device名称,此处为“/dev/sda10”.
显示结果类似如下信息:
Disk /dev/sda: 500.1 GB, 500107862016 bytes#此处的/dev/sda代表电脑硬盘
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf0b1ebb0
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3825 30724281 7 HPFS/NTFS
/dev/sda2 3826 60802 457661193 f W95 Ext'd (LBA)
Partition 2 does not end on cylinder boundary.
/dev/sda5 3826 11474 61440561 7 HPFS/NTFS
/dev/sda6 11475 26772 122881153+ 7 HPFS/NTFS
/dev/sda7 26773 42070 122881153+ 7 HPFS/NTFS
/dev/sda8 42071 54427 99257571 7 HPFS/NTFS
/dev/sda9 54428 54610 1464320 82 Linux swap / Solaris
/dev/sda10 54610 60802 49734656 83 Linux#此行为Linux分区,记下此Device名称
Disk /dev/sdb: 1977 MB, 1977614336 bytes#此处的/dev/sdb代表自启动U盘
61 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 3782 * 512 = 1936384 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00044e7e
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 1021 1930680 c W95 FAT32 (LBA)
root@ubuntu :~# mount /dev/sda10 /mnt#将/dev/sda10代表的Linux分区挂载到/mnt目录下
root@ubuntu :~# mount /dev/sda6 /mnt/boot#将(如果没有/boot单独分区这不跳过)
root@ubuntu :~# grub-install --root-directory=/mnt/ /dev/sda#安装grub,如果正常的话会显示如下信息。
(注意是/mnt/(此处有空格)/dev/sda)
Installation finished. No error reported.
5.重启
root@ubuntu :~# reboot#重启电脑,你将会看到熟悉的grub启动界面!