mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
[Translated] 20141118 How to boot on an ISO image from Grub.md
This commit is contained in:
parent
f23036007f
commit
e3cd20adeb
@ -1,113 +0,0 @@
|
||||
Translating by GOLinux!
|
||||
How to boot on an ISO image from Grub
|
||||
================================================================================
|
||||
If you need to use multiple Linux distributions, you do not have so many options. You can either install it, on your machine or in a virtual one, or you can boot on it from an ISO file in live mode. The second option, if less needy in hard drive space, is bothersome as you will need a USB stick or CD to hold the ISO file and boot from. However, there is a third alternative which is a bit of a compromise: have the ISO image on your hard drive, and boot into it in live mode at startup. Less needy in disk space than a full install, and fully functional, this seems to be a good alternative to a slow virtual machine. I will explain how to do this using the popular bootloader Grub.
|
||||
|
||||
### What do you need? ###
|
||||
|
||||
Obviously you will need to be using Grub, which is the case on pretty much all modern Linux distributions. You will also need to have an ISO file of the distribution of your choice, downloaded on your hard drive. Finally, you should know where your boot partition is, and how to express it in Grub language. For this, launch:
|
||||
|
||||
# fdisk -l
|
||||
|
||||
and the boot partition is the one with the '*'. For me it's /dev/sda1, which is written (hd0,1) in Grub language.
|
||||
|
||||
![](https://farm6.staticflickr.com/5606/15174383814_a92a4eda3e_z.jpg)
|
||||
|
||||
For reference, sda2 would be (hd0,2), sdb1 would be (hd1,1), etc. (You got the point).
|
||||
|
||||
### What do we edit? ###
|
||||
|
||||
First, open /etc/default/grub and check that the following line:
|
||||
|
||||
#GRUB_HIDDEN_TIMEOUT=0
|
||||
|
||||
is indeed commented with a '#' in front.
|
||||
|
||||
Save it and then go open /etc/grub.d/40_custom.
|
||||
|
||||
This file will be where you put the arguments to boot on an ISO. The structure is of the form:
|
||||
|
||||
menuentry "[Entry's title in the grub screen]" {
|
||||
set isofile="[path to ISO file]"
|
||||
loopback loop [boot partition in Grub language]$isofile
|
||||
[some specific] arguments
|
||||
}
|
||||
|
||||
For example, if you wish to boot Ubuntu from an ISO file, you want to append this to your 40_custom file:
|
||||
|
||||
menuentry "Ubuntu 14.04 (LTS) Live Desktop amd64" {
|
||||
set isofile="/boot/ubuntu-14.04-desktop-amd64.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=${isofile} quiet splash
|
||||
initrd (loop)/casper/initrd.lz
|
||||
}
|
||||
|
||||
![](https://farm8.staticflickr.com/7480/15608510369_ff50b28f5e_z.jpg)
|
||||
|
||||
If you would like to launch Gparted instead:
|
||||
|
||||
menuentry "GParted Live amd64" {
|
||||
set isofile="/boot/gparted-live-0.18.0-2-amd64.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
loopback loop $isofile
|
||||
linux (loop)/live/vmlinuz boot=live config union=aufs noswap noprompt ip=frommedia toram=filesystem.squashfs findiso=${isofile}
|
||||
initrd (loop)/live/initrd.img
|
||||
}
|
||||
|
||||
Or even Fedora:
|
||||
|
||||
menuentry "Fedora 20 Live Desktop x86_64" {
|
||||
set isofile="/boot/Fedora-Live-Desktop-x86_64-20-1.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
loopback loop $isofile
|
||||
linux (loop)/isolinux/vmlinuz0 root=live:CDLABEL=Fedora-Live-Desktop-x86_64-20-1 rootfstype=auto ro rd.live.image quiet rhgb rd.luks=0 rd.md=0 rd.dm=0 iso-scan/filename=${isofile}
|
||||
initrd (loop)/isolinux/initrd0.img
|
||||
}
|
||||
|
||||
Note that the arguments will change depending on the distribution. Hopefully, there are a few places where you can start looking. I like this one, but there are plenty of others. Also, take into consideration where you place your ISO files. If your home directory is encrypted or out of reach, you might prefer placing the files in your boot partition like in the example. But make sure that you have enough room first.
|
||||
|
||||
Finally, don't forget to save 40_custom and update grub with:
|
||||
|
||||
# sudo update-grub
|
||||
|
||||
to see your changes appear at the next boot.
|
||||
|
||||
![](https://farm8.staticflickr.com/7480/15795905012_47968033f7_z.jpg)
|
||||
|
||||
### What next? ###
|
||||
|
||||
Want more? Well by playing a bit with the arguments, you can boot on an ISO and have it do something instantly. For example, if you are completely paranoid and wish to have an option to erase your hard drive quickly, it is possible to set up something using [DBAN][1]. Now be really careful as this will wipe your disk without recovery option on startup:
|
||||
|
||||
menuentry "Darik's Boot and Nuke" {
|
||||
set isofile="/boot/dban.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/dban.bzi nuke="dwipe" silent
|
||||
}
|
||||
|
||||
Alternatively,
|
||||
|
||||
menuentry "Darik's Boot and Nuke" {
|
||||
set isofile="/boot/dban.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/dban.bzi
|
||||
}
|
||||
|
||||
will show you the DBAN's options and let you choose to wipe your drive. **Be careful as it is still very dangerous**.
|
||||
|
||||
To conclude, there are plenty of things to do with ISO files and Grub: whether you want a quick live session or prefer to destroy everything with the tip of your finger. The next step would be to launch some privacy focused distribution like [Tails][2] for example.
|
||||
|
||||
What do you think of booting on an ISO from Grub? Is it something you would consider doing? And why? Let us know in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/boot-iso-image-from-grub.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://www.dban.org/
|
||||
[2]:https://tails.boum.org/
|
@ -0,0 +1,111 @@
|
||||
用Grub启动ISO镜像
|
||||
================================================================================
|
||||
如果你需要使用多个Linux发行版,你没有那么多的选项。你可以安装到你的物理机或虚拟机中,也可以以live模式从ISO文件启动。第二个选择,如果对硬盘空间需求更少,就有点麻烦,因为你需要将ISO文件写入到USB棒或CD来启动。但是,这里有另外一个可选的折中方案:把ISO镜像放在硬盘中,然后以live模式来启动。该方案比完全安装更省空间,但是功能完备,这对于缓慢的虚拟机而言是个不错的替代方案。下面我将介绍怎样使用流行的Grub启动加载器来实现该方案。
|
||||
|
||||
|
||||
很明显,你将需要使用到Grub,这是几乎所有现代Linux发行版都使用的。你也需要你所想用的Linux版本的ISO文件,将它下载到本地磁盘。最后,你需要知道启动分区在哪里,并怎样在Grub中描述。对于此,请使用以下命令:
|
||||
|
||||
# fdisk -l
|
||||
|
||||
带有‘*’的就是启动分区。对于我,就是/dev/sda1,用Grub语言描述就是(hd0,1)。
|
||||
|
||||
![](https://farm6.staticflickr.com/5606/15174383814_a92a4eda3e_z.jpg)
|
||||
|
||||
作为参考,sda2就是(hd0,2),sdb1就是(hd1,1),以此类推。(你明白了吧。)
|
||||
|
||||
### 我们需要编辑什么? ###
|
||||
|
||||
首先,打开/etc/default/grub并检查以下行:
|
||||
|
||||
#GRUB_HIDDEN_TIMEOUT=0
|
||||
|
||||
需要在此行前添加‘#’进行注释。
|
||||
|
||||
保存,然后打开/etc/grub.d/40_custom。
|
||||
|
||||
在该文件中,你将添加启动到ISO的参数。结构如下:
|
||||
|
||||
menuentry "[Entry's title in the grub screen]" {
|
||||
set isofile="[path to ISO file]"
|
||||
loopback loop [boot partition in Grub language]$isofile
|
||||
[some specific] arguments
|
||||
}
|
||||
|
||||
例如,如果你想要从ISO文件启动Ubuntu,那么你就是想要添加该行到40_custom文件:
|
||||
|
||||
menuentry "Ubuntu 14.04 (LTS) Live Desktop amd64" {
|
||||
set isofile="/boot/ubuntu-14.04-desktop-amd64.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=${isofile} quiet splash
|
||||
initrd (loop)/casper/initrd.lz
|
||||
}
|
||||
|
||||
![](https://farm8.staticflickr.com/7480/15608510369_ff50b28f5e_z.jpg)
|
||||
|
||||
如果你想要启动Gparted:
|
||||
|
||||
menuentry "GParted Live amd64" {
|
||||
set isofile="/boot/gparted-live-0.18.0-2-amd64.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
loopback loop $isofile
|
||||
linux (loop)/live/vmlinuz boot=live config union=aufs noswap noprompt ip=frommedia toram=filesystem.squashfs findiso=${isofile}
|
||||
initrd (loop)/live/initrd.img
|
||||
}
|
||||
|
||||
或者甚至是Fedora:
|
||||
|
||||
menuentry "Fedora 20 Live Desktop x86_64" {
|
||||
set isofile="/boot/Fedora-Live-Desktop-x86_64-20-1.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
loopback loop $isofile
|
||||
linux (loop)/isolinux/vmlinuz0 root=live:CDLABEL=Fedora-Live-Desktop-x86_64-20-1 rootfstype=auto ro rd.live.image quiet rhgb rd.luks=0 rd.md=0 rd.dm=0 iso-scan/filename=${isofile}
|
||||
initrd (loop)/isolinux/initrd0.img
|
||||
}
|
||||
|
||||
注意,参数可根据发行版进行修改。有幸的是,有许多地方你可以查阅。我喜欢这一个,但是还有很多其它的。同时,请考虑你放置ISO文件的地方。如果你的家目录被加密或者无法被访问到,你可能更喜欢将这些文件放到像例子中的启动分区。但是,请首先确保有足够的空间。
|
||||
|
||||
最后,不要忘了保存40_custom文件并使用以下命令来更新grub:
|
||||
|
||||
# sudo update-grub
|
||||
|
||||
以便在下次启动时看到修改。
|
||||
|
||||
![](https://farm8.staticflickr.com/7480/15795905012_47968033f7_z.jpg)
|
||||
|
||||
### 接下来做什么? ###
|
||||
|
||||
想要更多东西?好吧,那就修改下参数来玩玩。你可以启动一个ISO文件,并让它持续做一些事情。例如,如果你是个彻头彻尾的妄想症患者,想要有个可以快速清除硬盘的选项,那么可以使用[DBAN][1]来进行一些设置。现在,真的要当心啊,因为此设置会清除你的硬盘,而且在启动时也没有恢复选项:
|
||||
|
||||
menuentry "Darik's Boot and Nuke" {
|
||||
set isofile="/boot/dban.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/dban.bzi nuke="dwipe" silent
|
||||
}
|
||||
|
||||
另外一个选择
|
||||
|
||||
menuentry "Darik's Boot and Nuke" {
|
||||
set isofile="/boot/dban.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/dban.bzi
|
||||
}
|
||||
|
||||
可以显示DBAN选项,让你选择清除驱动器。**当心,因为它仍然十分危险**。
|
||||
|
||||
小结一下,对于ISO文件和Grub有很多事情可做:从快速live会话到用你的指尖来破坏一切,都可以满足你。下一步是启动一些关注隐私的发行版如[Tails][2]。
|
||||
|
||||
你认为从Grub启动一个ISO这个主意怎样?这是不是你想要做的呢?为什么呢?请在下面留言。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/boot-iso-image-from-grub.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[GOLinux](https://github.com/GOLinux)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://www.dban.org/
|
||||
[2]:https://tails.boum.org/
|
Loading…
Reference in New Issue
Block a user