Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1634467
  • 博文数量: 124
  • 博客积分: 4078
  • 博客等级: 中校
  • 技术积分: 3943
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-21 11:28
个人简介

新博客:http://sparkandshine.net/

文章分类

全部博文(124)

分类: WINDOWS

2011-08-07 11:11:45

摘要:
    在PC装Ubuntu和Windows双系统,长时间运行之后,难免需要重装系统。基于这样的背景,本文分别介绍了重装Ubuntu和重装Windows,尤其是重装Windows后修复grub。


    在PC装Ubuntu和Windows双系统,一般的做法是先装Windows,再装Ubuntu。如果顺序相反,新装的Windows会破坏Ubuntu的grub,以致Ubuntu无法启动。长时间运行之后,难免需要重装系统。

一、重装Ubuntu
  这个就很简单了,跟一般安装一样。重装后不会破坏原有的Windows。但重装Windows就没那么乐观了。

二、重装Windows
  重装Windows有很多方法,这里仅介绍典型的两种:
2.1 用Ghost版本安装
  因为Ghost版本安装只是简单的拷贝,并没有破坏grub,不影响Ubuntu。所以装完,双系统皆可正常使用。
2.2 用安装版本安装
  要是遇到像我这样,找不到Ghost盘,手里只有安装版的,就比较麻烦了,需要重新写grub,具体操作如下:
步骤一:安装好Windows
步骤二:借助Ubuntu安装盘修复grub
(1) 运行Ubuntu live版
  我用的是Ubuntu 10.04LTS的盘,从光驱启动,选择Try Ubuntu 10.04LTS,运行Ubuntu live版
(2) 安装grub
live版,默认没有安装grub,需要先安装。打开终端,sudo apt-get install grub:
  1. ubuntu@ubuntu:~$ grub
  2. The program 'grub' is currently not installed. You can install it by typing:
  3. sudo apt-get install grub
  4. ubuntu@ubuntu:~$ sudo apt-get install grub
(3) 修复grub[1]
具体操作如下,重启之后即可。
  1. ubuntu@ubuntu:~$ sudo grub /*一定要sudo,否则后续操作会报错*/
  2. grub> find /boot/grub/stage1
  3. (hd0,7)
  4. grub> root (hd0,7) /*(hd0, 7)为上条命令find /boot/grub/stage1的结果*/
  5. grub> setup (hd0)
  6. Checking if "/boot/grub/stage1" exists... yes
  7. Checking if "/boot/grub/stage2" exists... yes
  8. Checking if "/boot/grub/e2fs_stage1_5" exists... yes
  9. Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 17 sectors are embedded.
  10. succeeded
  11. Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,7)/boot/grub/stage2
  12. /boot/grub/menu.lst"... succeeded
  13. Done.
  14. grub> quit
  15. ubuntu@ubuntu:~$ sudo reboot
(4) 其他问题
  经过上述操作后,应该就可以了。但我遇到另一个问题,重启进入Ubuntu之后,桌面没有任何东西(我本来桌面有很多文件),这个时候,应该想到是不是文件系统挂载错位。我的就是这样,因为我之前,在装好的双系统中,从Windows划一个分区增加到Ubuntu,以增大Ubuntu磁盘空间,见博文《》。可以通过命令sudo fdisk -l和sudo df -lh以及工具Gparted查看分区状况,在我机子上情况如下:
  1. ubuntu@ubuntu:/boot/grub$ sudo fdisk -l
  2. Disk /dev/sda: 160.0 GB, 160041885696 bytes
  3. 255 heads, 63 sectors/track, 19457 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0xf0b1ebb0
  8. Device Boot Start End Blocks Id System
  9. /dev/sda1 * 1 2432 19535008+ 7 HPFS/NTFS
  10. /dev/sda2 2433 19457 136753312+ f W95 Ext'd (LBA)
  11. /dev/sda5 2433 4982 20482843+ c W95 FAT32 (LBA)
  12. /dev/sda6 4983 8511 28346661 83 Linux
  13. /dev/sda7 8512 8760 2000061 82 Linux swap / Solaris
  14. /dev/sda8 8761 11249 19992861 83 Linux
  15. /dev/sda9 11250 19457 65924448+ 7 HPFS/NTFS

  1. jelline@jelline:~$ sudo df -lh
  2. Filesystem Size Used Avail Use% Mounted on
  3. /dev/sda8 19G 4.6G 14G 26% /
  4. none 493M 280K 493M 1% /dev
  5. none 498M 24K 498M 1% /dev/shm
  6. none 498M 104K 497M 1% /var/run
  7. none 498M 0 498M 0% /var/lock
  8. none 498M 0 498M 0% /lib/init/rw
  9. /dev/sda9 63G 57G 6.0G 91% /home
  10. /dev/sda6 27G 15G 12G 56% /media/479bf0d6-ab43-4f41-9d81-51ff6db4e17b
  11. /dev/sda1 19G 3.9G 15G 21% /media/24442CBA442C911A
  12. /dev/sda5 20G 286M 20G 2% /media/Software
  可以看到,我共用三个分区用于Ubuntu,分别是sda6、sda7、sda9。可以确定的是:sda8挂载到Ubuntu根目录,sda7是Swap分区,所以sda6本应该挂载到/home,但sda9(是NTFS格式,是我Windows的D盘)已经抢先挂到/home。
这样问题就简单了,将sda6挂载到/home,命令如下:
  1. jelline@jelline:~$ sudo mount /dev/sda6 /home
并修改/etc/fstab文件,将sda9改为sda6:
  1. jelline@jelline:~$ sudo vim /etc/fstab
  2. /dev/sda6 /home auto rw 0 0
重启系统reboot(注:必须重启,注销还不顶用),问题解决。


参考资料:
[1] 博文《》

阅读(3586) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~