红联Linux门户
Linux帮助

Ubuntu下安装Windows7

发布时间:2014-08-15 15:22:16来源:linux网站作者:lainzq

同事拿来一台联想的笔记本,预装的Ubunt11.10,要我给他装个windows7系统。 电脑没有光驱,最先想到的是USB安装windows7。向另一同事要了个刻好了系统U盘,但面临一个问题,需要给硬盘分区。由于机子默认下把硬盘分为了3个区:"/"、"/swap"、"/home",没空余空间了。这时在Ubuntu自身系统下分区肯定是行不通的。我最先想到的是安装个puppy linux,然后在putty里进行分区。原本想把puppy装到U盘上的,后来想干脆直接在ubuntu下引导启动puppy。


关于如何ubuntu下引导启动puppy linux,参考下面:

其中引导项内容还应该添加一句:

set root=(hd0,msdos8)
search -f --fs-uuid --set <你的存放puppy的那个分区的uuid值>    //需添加这句
...

到这里,把分区的问题解决了。插入U盘,进入win7安装程序。问题又来了,进入安装见面后总提示CD/DVD驱动器无法找到。Google一搜,一大堆问题反馈,大概估计是U盘中安装文件损坏了。


接下来怎么办呢,重新创建一个usb win7安装器?

经历过各种情况下win7安装ubuntu、ubuntu引导win7、win7引导ubuntu...的我,想到了grub的强大,怕脑袋一想,能不能在ubuntu安装win7。 经过一翻搜索之后,发现还是可行的,还有人实践过,我在这里做个总结吧。


Ubuntu下安装Windows7:

下载grub4dos,解压,拷贝里面的grub.exe之任意分区的跟目录 挂载window7.iso文件,拷贝全部文件至某个ntfs或FAT32分区的根目录 重启电脑,进入系统引导菜单,先按下上下,让它停止自动进入系统。 停住后,按e键,今入命令行模式

set root =(hdx,y) //其中x代表硬盘ID,y代表分区ID。如我的是(hd0,0)
linux /grub.exe


此时进入grub,依旧是命令模式

grub>find --set-root /bootmgr
grub>chainloader /bootmgr
grub>boot

ok,现在进入windows安装程序。


由于我在创建新分区时,分割了/home所在的硬盘分区,导致ubuntu无法登录进入,后采用恢复模式使用shell进行文件的拷贝。

在Ubuntu恢复模式下使用shell安装Windows7

现在U盘中准备好window7 iso文件与grub.exe 进入系统引导菜单时选择恢复模式 在选择“Drop to root shell”。 进入root shell后,注意到整个文件系统都只读。这时要对配置文件做一些修改的话,必须将文件系统重新挂在为可读写的:

#mount -n -o remount,rw /


首先查看下U盘驱动器的位置

#fdisk -l

可以看到所以硬盘驱动器,找到U盘为:/dev/sdb1 挂载U盘:

#mkdir /mnt/usb
#mount -t auto /dev/sdb1 /mnt/usb


拷贝grub.exe至"/"目录:

#cp /mnt/usb/grub.exe /

挂载iso文件,并将所有文件拷贝至某个分区根目录(/dev/sda3,注意该分区格式必须为ntfs或FAT32,并且不是要安装win7的目标分区):


#mkdir /mnt/win7
#mount /mnt/usb/window7.iso /mnt/win7 -o loop
#mkdir /mnt/windows
#mount -t auto /dev/sda3 /mnt/windows
#cp -r /mnt/win7/ /mnt/windows

重启:

#reboot


Dual Boot Puppy Linux With Ubuntu

Lately I tried to install Puppy Linux alongside with my Ubuntu. It is not difficult at all, however it was not immediately obvious how to do it. I am noting down the steps, in case they may be useful for somebody else.

First of all, download lupu-528.003.iso from: http://distro.ibiblio.org/pub/linux/distributions/puppylinux/puppy-5.2.8/
Then mount it and copy its files to the directory /puppy/ on the root (/):

mkdir puppy_iso
sudo mount -o loop lupu_528.003.iso puppy_iso/
ls puppy_iso/

sudo mkdir /puppy
sudo cp puppy_iso/vmlinuz /puppy/
sudo cp puppy_iso/initrd.gz /puppy/
sudo cp puppy_iso/lupu_528.sfs /puppy/

sudo umount puppy_iso/
rmdir puppy_iso/

The installation of puppy is already finished, but we need a way to boot it. We can do this by adding a new menu entry on grub. It can be done like this:

Create a new file on /etc/grub.d/:

cd /etc/grub.d/
sudo cp 40_custom 07_puppy
sudo vim 07_puppy

Append these lines to 07_puppy:

menuentry 'Puppy Linux' --class puppy --class gnu-linux --class os {
set root=(hd0,msdos8)
linux /puppy/vmlinuz
initrd /puppy/initrd.gz
}

Update the grub config: sudo update-grub
Verify that the grub menuentry is correct: vim /boot/grub/grub.cfg
Make sure that the root of Puppy Linux is the same as that of Ubuntu, for example: set root=(hd0,msdos8) If not, then correct /etc/grub.d/07_puppy and run again update-grub .

Note: Ubuntu uses GRUB2, but some other systems may still have the old GRUB. In this case, you have to edit manually /boot/grub/grub.cfg and add some lines like this:

title Puppy Linux
rootnoverify (hd0,7)
kernel /puppy/vmlinuz root=/dev/ram0
initrd /puppy/initrd.gz

Now reboot the PC and enjoy Puppy.

References:

http://puppylinux.org/wikka/installationfrugal
http://puppylinux.org/wikka/InstallationFullHDD