HOWTO Networkless stage1 Install
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Contents |
[edit] Introduction
It's a fairly common problem. You want to do a stage1 install, but you don't have an Internet connection on that computer. Maybe it's because you don't have an Internet connection at home, or maybe your wireless drivers aren't supported natively by the Linux kernel. Some of you might be reading this because you don't want to sit while you download all the distfiles over your dial-up connection.
[edit] What To Do?
So you've decided to do a stage1 without a Linux-compatible NIC, huh? That's OK, it's pretty common, especially with wireless drivers. One example of such is myself: to install my wireless drivers, I need to emerge ndiswrapper. Trouble is, you can't emerge anything until your kernel is configured. So let's do it this way.
You'll need a Windows installation, whether on your computer (you're dual-booting with Gentoo) or on another computer. If you're not dual-booting, you'll need some kind of high-capacity removable media (like a recordable disc or external hard drive; be creative). Dual-booters can just save the files to their hard drive.
If another computer on your network is running Windows XP, share its Internet connection with Internet Connection Sharing (ICS) and then tell your Gentoo box to use it as a gateway. The purpose of this guide isn't to teach you how to set up ICS, so do your own homework. If you're successful, close this window. You don't need this guide. Do the Gentoo installation as instructed.
[edit] You will need...
- The Windows version of wget. The latest version as of this writing is 1.9.1. Google for it, it's pretty easy to find.
- Someplace for your distfiles that's accessible from Windows and Gentoo alike. Any folder on your hard drive will work, or a CD or external hard drive. It must be read/write for Windows and read-only for Gentoo.
- Someplace to write a small file (~1 MB). A floppy disk or USB key works well here. It must be read/write to Windows and Gentoo.
- The stage1 tarball and the latest copy of the Portage tree.
- Time and patience. Even on high-speed Internet, this will take some time to download, especially if virus scanners kick in to check each file automatically as it's downloaded. Don't try to defeat the virus scanners; your university/library/friend might not like that.
[edit] Assumptions
Okay. Now, let me make a couple assumptions about your system.
- Your Windows partition is mounted read-only at /mnt/gentoo/mnt/windrive. Your distfiles are kept in C:\Downloads\distfiles, which in Linux terms is /mnt/gentoo/mnt/windrive/Downloads/distfiles.
- Your read/write storage is at /mnt/gentoo/mnt/usbdrive.
[edit] Let's Go!
[edit] Windows: The Software Menace
[edit] Download tarballs
Firstly, download the stage1 tarball for your architecture and save it somewhere. Do the same for the Portage tarball. For the sake of clarity, we'll download them to C:\Downloads.
[edit] Print this page!
Print out this page before rebooting, since you won't have a network connection! Once your printer spits out this page, insert the LiveCD and reboot, making sure your BIOS is set to boot from a CD.
[edit] Gentoo: A New Hope
[edit] Extract the tarballs
- Follow the instructions in the Gentoo Handbook up until you start downloading the stage1 tarball.
- Create a mountpoint and then mount your Windows partition there:
mkdir -p /mnt/gentoo/mnt/windrive; mount -t ntfs -o ro /dev/hda1 /mnt/gentoo/mnt/windrive
- You should be in folder /mnt/gentoo. Extract the stage1 tarball:
tar -xvjpf mnt/windrive/Downloads/stage1-x86-2005.0.tar.bz2
- Cool. Now extract the Portage tree. Get a directory listing of /mnt/gentoo/mnt/windrive/Downloads if you forget the filename.
tar -xvjf mnt/windrive/Downloads/portage-[insert the date here].tar.bz2 -C usr/
| FIXME: mirrorselect cannot be used on a networkless installation. Please provide a workaround. |
- Did that work? All right, continue the steps in the Gentoo Handbook. Make sure you chroot like you're supposed to. Also edit your /etc/make.conf, setting your USE flags now! Don't skip over mirrorselect.
[edit] Bootstrapping
- If all goes well, it should be time to bootstrap. Since that needs an Internet connection, we're going to do this instead:{
/usr/portage/scripts/bootstrap.sh --fetchonly --pretend 2> /mnt/usbdrive/download.lst
- When this command finishes, you should have a list of files to download. Note that the files are listed several times, once for each mirror. This is normal--leave it as is.
- exit the chroot-ed environment and reboot the system. Take out the LiveCD!
[edit] Windows: Attack of the Gates
[edit] Prepare to fetch the files
- Move download.txt into the same folder as wget.
- wget likes its files separated by newlines. Our files are space-delimited. If you don't have a C++ compiler, then manually edit the file and replace all spaces with newlines, saving it as download.new.lst. If you do have a C++ compiler (I used Dev-C++), run this code in the folder with wget:
| Code: Replace all spaces with newlines |
#include <fstream>
using namespace std;
int main() {
ifstream infile("download.lst");
ofstream outfile("download.new.lst");
while (infile.good() && outfile.good() && char ch = infile.get(ch)) {
if (ch == ' ')
outfile.put('\n');
else
outfile.put(ch);
}
infile.close();
outfile.close();
return 0;
} |
- If you are using Mac OS X instead, you can use this Ruby script to accomplish the same task as the C++ code above:
| Code: Replace all spaces with newlines |
#!/usr/bin/ruby
output = File.open('download.new.lst', 'w')
File.open('download.lst').each_byte do |b|
ch = b.chr
if ch == ' ' then
output.write("\n")
else
output.write(ch)
end
end
output.close
|
- Or simply use bash script using cat and tr commands.
| Code: Replace all spaces with newlines |
#!/bin/bash cat "download.lst" | tr " " "\n" > download.new.lst |
Alternatively you can copy the following code into an blank html document. Open the HTML file and copy the contents of the download.lst file into the textarea and click the button. Copy the result back into the text file and save.
<html>
<head>
<!--Crude alternative but works.-->
<!--Updated code so it won't crash browser for longer lists-->
<script>
function runFormat(){
var text = "te"
text = document.getElementById('te').value
var newText = new Array()
newText = text.split(' ')
document.getElementById('asdf').innerHTML = ""
text = ""
for (x = 0; x < newText.length; x++){
text = text + newText[x] + "<br>";
}
document.getElementById('asdf').innerHTML = text;
}
</script>
</head>
<body>
<textarea rows="20" cols="100" id="te">
</textarea>
<br />
<input type="button" value="Format" onclick="runFormat()" />
<br />
<div id="asdf" style="background-color:green">Text will be outputted here</div>
</body>
</html>
/*Another good idea is using a Python script.*/
[edit] Fetch the files
- Go to a DOS box and execute this command to start downloading:
wget -c -nc -i download.new.lst -P C:\Downloads\distfiles
- Now sit back while your distfiles are downloaded!
- If wget got each file successfully, we're ready to head back to Gentoo. Put in the LiveCD and reboot. See you there!
[edit] Gentoo: The Penguin Strikes Back
[edit] Copy over the downloaded files
- Welcome back. Remount your partitons and proc, reactivate your swap, chroot back to where you were and put yourself in /usr/portage. Now, copy over your distfiles:
cp -L /mnt/windrive/Downloads/distfiles/* distfiles/
- Heh. All right. Now, bootstrap the system as you normally would. This could take anywhere from three hours to multiple days. If you want to time it, prefix the command with time, as in:
time scripts/bootstrap.sh
- Hope your bootstrap went well. Now, let's get a file listing for your empty-tree emerge:
emerge --deep --emptytree --newuse --pretend --fetchonly system 2> /mnt/usbdrive/download2.lst
- Reboot.
[edit] Windows: Revenge of the Microsoft
[edit] Prepare to fetch the files
- Once again, move download2.lst into the same folder as wget.
- wget still likes its files separated by newlines. Our files are still space-delimited. Take the program you built before and use it again.
[edit] Fetch the files
- Go to a DOS box and execute this command to start downloading:
wget -c -nc -i download2.new.lst -P C:\Downloads\distfiles
- Now sit back while your distfiles are downloaded!
- If wget got each file successfully, we're ready to head back to Gentoo. Put in the LiveCD and reboot. See you there!
[edit] Gentoo: Return of the Penguins
[edit] Copy over the downloaded files
- Welcome back. Remount your partitons and proc, reactivate your swap, chroot back to where you were and put yourself in /usr/portage. Now, copy over your distfiles:
cp -L /mnt/windrive/Downloads/distfiles/* distfiles/
[edit] Finally!
Cool! Now just emerge your system like you normally would and continue with installation as normal. If you need to emerge more packages, repeat the above steps. (This is why I told you to get everything at once!)
Concerns or Compliments? Please use the Discussion section.
