Difference between pages "ZFS Install Guide" and "PXE Network Windows Installation"

From Funtoo
(Difference between pages)
Jump to: navigation, search
(Create the zfs datasets)
 
(Creating a Setup Instruction File)
 
Line 1: Line 1:
== Introduction ==
+
''Howto use your Funtoo machine to serve a MS Windows installation over the network''
 +
In this guide we will assume that you have followed the [[PXE network boot server]] Wiki article and have a working network/pxe boot setup. As of now this guide will cover Windows XP. Soon it will be expanded to also cover Windows 7.
 +
==Prerequisites==
 +
#A working Funtoo installation
 +
#A working PXE Setup (DHCP, TFTP, PXELinux)
 +
#app-arch/cabextract
 +
#A legitimate copy of Microsoft Windows
 +
#Driver for your NIC - ''Suggested to use a complete driver pack with all major supported NIC hardware for the version of Windows to be installed.''
 +
#RIS Linux toolkit >=0.4
 +
#A working Samba server setup
  
This tutorial will show you how to install Funtoo on ZFS (rootfs). This tutorial is meant to be an "overlay" over the [[Funtoo_Linux_Installation|Regular Funtoo Installation]]. Follow the normal installation and only use this guide for steps 2, 3, and 8.
+
== Creating the Windows XP Image ==
  
=== Introduction to ZFS ===
+
*In the previous guide, [http://www.funtoo.org/wiki/PXE_network_boot_server PXE Network Boot Server], we used /tftproot as the working directory so we will also use it in this guide for convenience. If you chose to use a different working directory then please apply it where needed in place of the /tftproot we will be going by here.
  
Since ZFS is a new technology for Linux, it can be helpful to understand some of its benefits, particularly in comparison to BTRFS, another popular next-generation Linux filesystem:
+
First you will need to create an ISO from your Windows XP installation disc. If you already have the ISO image you may skip this step.  
 
+
* On Linux, the ZFS code can be updated independently of the kernel to obtain the latest fixes. btrfs is exclusive to Linux and you need to build the latest kernel sources to get the latest fixes.
+
 
+
* ZFS is supported on multiple platforms. The platforms with the best support are Solaris, FreeBSD and Linux. Other platforms with varying degrees of support are NetBSD, Mac OS X and Windows. btrfs is exclusive to Linux.
+
 
+
* ZFS has the Adaptive Replacement Cache replacement algorithm while btrfs uses the Linux kernel's Last Recently Used replacement algorithm. The former often has an overwhelmingly superior hit rate, which means fewer disk accesses.
+
 
+
* ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.
+
 
+
* ZFS handles internal fragmentation gracefully, such that you can fill it until 100%. Internal fragmentation in btrfs can make btrfs think it is full at 10%. Btrfs has no automatic rebalancing code, so it requires a manual rebalance to correct it.
+
 
+
* ZFS has raidz, which is like RAID 5/6 (or a hypothetical RAID 7 that supports 3 parity disks), except it does not suffer from the RAID write hole issue thanks to its use of CoW and a variable stripe size. btrfs gained integrated RAID 5/6 functionality in Linux 3.9. However, its implementation uses a stripe cache that can only partially mitigate the effect of the RAID write hole.
+
 
+
* ZFS send/receive implementation supports incremental update when doing backups. btrfs' send/receive implementation requires sending the entire snapshot.
+
 
+
* ZFS supports data deduplication, which is a memory hog and only works well for specialized workloads. btrfs has no equivalent.
+
 
+
* ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
+
 
+
* ZFS has the ability to create virtual block devices called zvols in its namespace. btrfs has no equivalent and must rely on the loop device for this functionality, which is cumbersome.
+
 
+
The only area where btrfs is ahead of ZFS is in the area of small file
+
efficiency. btrfs supports a feature called block suballocation, which
+
enables it to store small files far more efficiently than ZFS. It is
+
possible to use another filesystem (e.g. reiserfs) on top of a ZFS zvol
+
to obtain similar benefits (with arguably better data integrity) when
+
dealing with many small files (e.g. the portage tree).
+
 
+
=== Disclaimers ===
+
 
+
{{fancywarning|This guide is a work in progress. Expect some quirks.}}
+
{{fancyimportant|'''Since ZFS was really designed for 64 bit systems, we are only recommending and supporting 64 bit platforms and installations. We will not be supporting 32 bit platforms'''!}}
+
 
+
== Video Tutorial ==
+
 
+
As a companion to the install instructions below, a YouTube video ZFS install tutorial is now available:
+
 
+
{{#widget:YouTube|id=kxEdSXwU0ZI|width=640|height=360}}
+
 
+
== Downloading the ISO (With ZFS) ==
+
In order for us to install Funtoo on ZFS, you will need an environment that provides the ZFS tools. Therefore we will download a customized version of System Rescue CD with ZFS already included. When booting, use the "alternate"-kernel. The ZFS-module won't work with the default kernel.
+
 
+
<pre>
+
Name: sysresccd-3.8.1_zfs_0.6.2.iso  (510 MB)
+
Release Date: 2013-11-03
+
md5sum aa33ef61c5d85ad564372327940498c3
+
</pre>
+
 
+
 
+
'''[http://ftp.osuosl.org/pub/funtoo/distfiles/sysresccd/ Download System Rescue CD with ZFS]'''<br />
+
 
+
== Creating a bootable USB from ISO ==
+
After you download the iso, you can do the following steps to create a bootable USB:
+
  
 
<console>
 
<console>
Make a temporary directory
+
###i## dd if=/dev/sr0 of=/tftproot/winxp.iso
# ##i##mkdir /tmp/loop
+
 
+
Mount the iso
+
# ##i##mount -o ro,loop /root/sysresccd-3.7.1_zfs_0.6.2.iso /tmp/loop
+
 
+
Run the usb installer
+
# ##i##/tmp/loop/usb_inst.sh
+
 
</console>
 
</console>
 +
If your cdrom device isn't ''<code>/dev/sr0</code>'' please use the appropriate device in this command.
  
That should be all you need to do to get your flash drive working.
+
== Mount the ISO and Prepare Installation Sources ==
 
+
Mount the image to ''<code>/tftproot/cdrom</code>'':
When you are booting into system rescue cd, make sure you select the '''alternative 64 bit kernel'''. ZFS support was specifically added to the alternative 64 bit kernel rather than the standard 64 bit kernel.
+
 
+
== Creating partitions ==
+
There are two ways to partition your disk: You can use your entire drive and let ZFS automatically partition it for you, or you can do it manually.
+
 
+
We will be showing you how to partition it '''manually''' because if you partition it manually you get to create your own layout, you get to have your own separate /boot partition (Which is nice since not every bootloader supports booting from ZFS pools), and you get to boot into RAID10, RAID5 (RAIDZ) pools and any other layouts due to you having a separate /boot partition.
+
 
+
==== gdisk (GPT Style) ====
+
 
+
'''A Fresh Start''':
+
 
+
First lets make sure that the disk is completely wiped from any previous disk labels and partitions.
+
We will also assume that <tt>/dev/sda</tt> is the target drive.<br />
+
 
+
 
<console>
 
<console>
# ##i##gdisk /dev/sda
+
###i## mkdir /tftproot/cdrom; mount -o loop /tftproot/winxp.iso /tftproot/cdrom
 
+
Command: ##i##x ↵
+
Expert command: ##i##z ↵
+
About to wipe out GPT on /dev/sda. Proceed?: ##i##y ↵
+
GPT data structures destroyed! You may now partition the disk using fdisk or other utilities.
+
Blank out MBR?: ##i##y ↵
+
 
</console>
 
</console>
 
+
Create the new directory for the network installation files and copy the needed files to it:
{{fancywarning|This is a destructive operation. Make sure you really don't want anything on this disk.}}
+
 
+
Now that we have a clean drive, we will create the new layout.
+
 
+
'''Create Partition 1''' (boot):
+
 
<console>
 
<console>
Command: ##i##n ↵
+
###i## mkdir /tftproot/winxp; cp -R /tftproot/cdrom/i386 /tftproot/winxp/i386
Partition Number: ##i##↵
+
First sector: ##i##↵
+
Last sector: ##i##+250M ↵
+
Hex Code: ##i##
+
 
</console>
 
</console>
 
+
Depending on your CD/DVD copy of windows the directory name may be I386 as opposed to i386, if that is the case you will just need to change the first part of the command, keeping the new directory name i386 - this is going to be very important later on when creating the remap file!
'''Create Partition 2''' (BIOS Boot Partition):
+
Check the contents of your newly created i386 directory to see if the filenames are in all CAPS or if they are already in lowercase.
<console>Command: ##i##n ↵
+
Partition Number: ##i##↵
+
First sector: ##i##↵
+
Last sector: ##i##+32M ↵
+
Hex Code: ##i##EF02 ↵
+
</console>
+
 
+
'''Create Partition 3''' (ZFS):
+
<console>Command: ##i##n ↵
+
Partition Number: ##i##↵
+
First sector: ##i##↵
+
Last sector: ##i##↵
+
Hex Code: ##i##bf00 ↵
+
 
+
Command: ##i##p ↵
+
 
+
Number  Start (sector)    End (sector)  Size      Code  Name
+
  1            2048          514047  250.0 MiB  8300  Linux filesystem
+
  2          514048          579583  32.0 MiB    EF02  BIOS boot partition
+
  3          579584      1953525134  931.2 GiB  BF00  Solaris root
+
 
+
Command: ##i##w ↵
+
</console>
+
 
+
 
+
=== Format your boot volume ===
+
Format your separate /boot partition:
+
<console># ##i##mkfs.ext2 /dev/sda1</console>
+
 
+
=== Encryption (Optional) ===
+
If you want encryption, then create your encrypted vault(s) now by doing the following:
+
 
+
 
<console>
 
<console>
# ##i##cryptsetup luksFormat /dev/sda3
+
###i## ls /tftproot/winxp/i386
# ##i##cryptsetup luksOpen /dev/sda3 vault_1
+
 
</console>
 
</console>
 
+
If you happen to have all UPPERCASE filenames, lets go ahead and run a script to convert it to all lowercase:
=== Create the zpool ===
+
We will first create the pool. The pool will be named `tank` and the disk will be aligned to 4096 (using ashift=12)
+
<console># ##i##zpool create -f -o ashift=12 -o cachefile= -O compression=on -m none -R /mnt/funtoo tank /dev/sda3</console>
+
 
+
{{fancyimportant|If you are using encrypted root, change '''/dev/sda3 to /dev/mapper/vault_1'''.}}
+
 
+
{{fancynote|'''ashift<nowiki>=</nowiki>12''' should be use if you have a newer, advanced format disk that has a sector size of 4096 bytes. If you have an older disk with 512 byte sectors, you should use '''ashift<nowiki>=</nowiki>9''' or don't add the option for auto detection}}
+
 
+
{{fancynote|If you have a previous pool that you would like to import, you can do a: '''zpool import -f -R /mnt/funtoo <pool_name>'''}}
+
 
+
=== Create the zfs datasets ===
+
We will now create some datasets. For this installation, we will create a small but future proof amount of datasets. We will have a dataset for the OS (/), and your swap. We will also show you how to create some optional datasets: <tt>/home</tt>, <tt>/var</tt>, <tt>/usr/src</tt>, and <tt>/usr/portage</tt>.
+
 
+
 
<console>
 
<console>
Create some empty containers for organization purposes, and make the dataset that will hold /
+
###i## cd /tftproot/winxp/i386;ls | awk '$0!=tolower($0){printf "mv \"%s\" \"%s\"\n",$0,tolower($0)}' | sh
# ##i##zfs create -p tank/os/funtoo
+
# ##i##zfs create -o mountpoint=/ tank/os/funtoo/root
+
 
+
Optional, but recommended datasets: /home
+
# ##i##zfs create -o mountpoint=/home tank/os/funtoo/home
+
 
+
Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
+
# ##i##zfs create -o mountpoint=/usr/src tank/os/funtoo/src
+
# ##i##zfs create -o mountpoint=/usr/portage -o compression=off tank/os/funtoo/portage
+
# ##i##zfs create -o mountpoint=/usr/portage/distfiles tank/os/funtoo/portage/distfiles
+
# ##i##zfs create -o mountpoint=/usr/portage/packages tank/os/funtoo/portage/packages
+
 
</console>
 
</console>
  
=== Create your swap zvol ===
+
==Extracting and Modifying the Required Boot Files ==
'''Make your swap +1G greater than your RAM. An 8G machine would have 9G of SWAP (This is kinda big though). For machines with this much memory, You could just make it 2G if you don't have any problems.'''
+
Install {{Package|app-arch/cabextract}}
 
<console>
 
<console>
# ##i##zfs create -o sync=always -o primarycache=metadata -o secondarycache=none -o volblocksize=4K -V 1G tank/swap
+
###i## emerge -av app-arch/cabextract
 
</console>
 
</console>
 
+
Extract the prepackaged drivers:
=== Format your swap zvol ===
+
 
<console>
 
<console>
# ##i##mkswap -f /dev/zvol/tank/swap
+
###i## cd /tftproot/winxp/i386;cabextract driver.cab
# ##i##swapon /dev/zvol/tank/swap
+
 
</console>
 
</console>
 
+
Install support for a large list of network cards:
Now we will continue to install funtoo.
+
 
+
== Installing Funtoo ==
+
[[Funtoo_Linux_Installation|Download and extract the Funtoo stage3 and continue installation as normal.]]
+
 
+
Then once you've extracted the stage3, chroot into your new funtoo environment:
+
 
<console>
 
<console>
Go into the directory that you will chroot into
+
###i## cd /tftproot/;wget http://downloads.sourceforge.net/project/bootfloppy/pxefiles.tar.gz
# ##i##cd /mnt/funtoo
+
###i## tar zxvf pxefiles.tar.gz; cp pxefiles/drivers/* winxp/i386/
 
+
Mount your boot drive
+
# ##i##mount /dev/sda1 /mnt/funtoo/boot
+
 
+
Bind the kernel related directories
+
# ##i##mount -t proc none /mnt/funtoo/proc
+
# ##i##mount --rbind /dev /mnt/funtoo/dev
+
# ##i##mount --rbind /sys /mnt/funtoo/sys
+
 
+
Copy network settings
+
# ##i##cp /etc/resolv.conf /mnt/funtoo/etc/
+
 
+
chroot into your new funtoo environment
+
# ##i##env -i HOME=/root TERM=$TERM chroot /mnt/funtoo /bin/bash --login
+
 
+
Place your mountpoints into your /etc/mtab file
+
# ##i##cat /proc/mounts > /etc/mtab
+
 
+
Sync your tree
+
# ##i##emerge --sync
+
 
</console>
 
</console>
 
+
Copy the BINLSRV /INFParser tools to /tftproot:
=== Add filesystems to /etc/fstab ===
+
 
+
Before we continue to compile and or install our kernel in the next step, we will edit the <tt>/etc/fstab</tt> file because if we decide to install our kernel through portage, portage will need to know where is your <tt>/boot</tt> so that it can place the files in there. We also need to update <tt>/etc/mtab</tt> so our system knows what is mounted
+
 
+
{{File
+
|/etc/fstab|<pre>
+
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>
+
 
+
/dev/sda1              /boot          ext2            defaults        0 2
+
/dev/zvol/tank/swap    none            swap            sw              0 0
+
</pre>}}
+
 
+
== Kernel Configuration ==
+
To speed up this step, you can install "bliss-kernel" since it's already properly configured for ZFS and a lot of other configurations. The kernel is also compiled and ready to go. To install {{Package|sys-kernel/bliss-kernel}} type the following:
+
 
+
 
<console>
 
<console>
# ##i##emerge -av bliss-kernel
+
###i## cp pxefiles/script/* /tftproot/
 
</console>
 
</console>
 
+
Extract the netboot startrom:
Now make sure that your <tt>/usr/src/linux symlink</tt> is pointing to this kernel by typing the following:
+
 
<console>
 
<console>
# ##i##eselect kernel list
+
###i## cd /tftproot; cabextract winxp/i386/startrom.n1_
Available kernel symlink targets:
+
[1]  linux-3.10.10-FB.01 *
+
 
</console>
 
</console>
You should see a star next to the bliss-kernel version you installed. In this case it was 3.10.10-FB.01. If it's not set, you can type '''eselect kernel set #'''.
+
Fix the startrom for netbooting xp:
 
+
== Installing the ZFS userspace tools and kernel modules ==
+
Emerge {{Package|sys-fs/zfs}}, {{Package|sys-kernel/spl}}, and {{Package|sys-fs/zfs-kmod}}:
+
<console># ##i##emerge -av zfs spl zfs-kmod</console>
+
 
+
{{Note}}(spl = Solaris Porting Layer)
+
 
+
Check to make sure that the zfs tools are working, the <code>zpool.cache</code> file that you copied before should be displayed.
+
 
+
 
<console>
 
<console>
# ##i##zpool status
+
###i## sed -i -e 's/NTLDR/XPLDR/gi' startrom.n12
# ##i##zfs list
+
###i## mv startrom.n12 winxp.0
 
</console>
 
</console>
 
+
Fix XPLDR:
If everything worked, continue.
+
 
+
== Install the bootloader ==
+
=== GRUB 2 ===
+
Before you do this, make sure this checklist is followed:
+
* Installed kernel and kernel modules
+
* Installed zfs package from the tree
+
* <code>/dev</code>, <code>/proc</code>, <code>/sys</code> are mounted in the chroot environment
+
 
+
Once all this is checked, let's install grub2. First we need to enable the "libzfs" use flag so zfs support is compiled for grub2.
+
 
+
<console># ##i##echo "sys-boot/grub libzfs" >> /etc/portage/package.use</console>
+
 
+
Then we will compile grub2:
+
 
+
<console># ##i##emerge -av grub</console>
+
 
+
Once this is done, you can check that grub is version 2.00 by doing the following command:
+
 
<console>
 
<console>
# ##i##grub-install --version
+
###i## cabextract winxp/i386/setupldr.ex_
grub-install (GRUB) 2.00
+
###i## sed -i -e 's/winnt\.sif/winxp\.sif/gi' setupldr.exe
 +
###i## sed -i -e 's/ntdetect\.com/ntdetect\.wxp/gi' setupldr.exe
 +
###i## mv setupldr.exe xpldr
 +
###i## cp winxp/i386/ntdetect.com ntdetect.wxp
 
</console>
 
</console>
  
Now try to install {{Package|sys-boot/grub}}:
+
== Creating a remapping file ==
<console>
+
Create the file <code>/tftproot/tftpd.remap</code> and add the following to it:
# ##i##grub-install --recheck /dev/sda
+
{{File
</console>
+
|/tftproot/tftpd.remap|<pre>
 +
ri ^[az]: # Remove “drive letters”
 +
rg \\ / # Convert backslashes to slashes
 +
rg \# @ # Convert hash marks to @ signs
 +
rg /../ /..no../ # Convert /../ to /..no../
 +
rg A a
 +
rg B b
 +
rg C c
 +
rg D d
 +
rg E e
 +
rg F f
 +
rg G g
 +
rg H h
 +
rg I i
 +
rg J j
 +
rg K k
 +
rg L l
 +
rg M m
 +
rg N n
 +
rg O o
 +
rg P p
 +
rg Q q
 +
rg R r
 +
rg S s
 +
rg T t
 +
rg U u
 +
rg V v
 +
rg W w
 +
rg X x
 +
rg Y y
 +
rg Z z
 +
r ^/(.*) \1
 +
r ^xpldr xpldr
 +
r ^ntdetect.wxp ntdetect.wxp
 +
r ^winxp.sif winxp.sif
 +
</pre>}}
  
You should receive the following message:
+
==Install/Configure Samba ==
 +
If you don't already have {{Package|net-fs/samba}} installed, then:
 
<console>
 
<console>
Installation finished. No error reported.
+
###i## emerge -av net-fs/samba
 
</console>
 
</console>
 +
Create a Samba share for your tftp server in <code>/etc/samba/smb.conf</code>
  
If not, then go back to the above checklist.
+
{{Note}} Be sure you have the other required samba settings configured in the file
 
+
=== LILO ===
+
Before you do this, make sure the following checklist is followed:
+
* <code>/dev</code>, <tt>/proc</tt> and <tt>/sys</tt> are mounted.
+
* Installed the {{Package|sys-fs/zfs}} package from the tree.
+
Once the above requirements are met, LILO can be installed.
+
 
+
Now we will install {{Package|sys-boot/lilo}}.
+
<console># ##i##emerge -av sys-boot/lilo</console>
+
Once the installation of LILO is complete we will need to edit the lilo.conf file.
+
 
{{File
 
{{File
|/etc/lilo.conf|<pre>
+
|/etc/samba/smb.conf|<pre>
boot=/dev/sda
+
[Global]
prompt
+
interfaces = lo eth0 wlan0
timeout=4
+
bind interfaces only = yes
default=Funtoo
+
workgroup = WORKGROUP
 +
security = user
  
image=/boot/bzImage
+
[tftproot]
      label=Funtoo
+
path = /tftproot
      read-only
+
browsable = true
      append="root=tank/os/funtoo/root"
+
read only = yes
      initrd=/boot/initramfs
+
writable = no
 +
guest ok = yes
 
</pre>}}
 
</pre>}}
All that is left now is to install the bootcode to the MBR.
+
Start Samba:
 
+
<console>
This can be accomplished by running:
+
###i## /etc/init.d/samba start
<console># ##i##/sbin/lilo</console>
+
</console>  
If it is successful you should see:
+
or if samba has already been started:
 
<console>
 
<console>
Warning: LBA32 addressing assumed
+
###i## /etc/init.d/samba restart
Added Funtoo + *
+
One warning was issued
+
 
</console>
 
</console>
  
== Create the initramfs ==
+
== Creating a Setup Instruction File ==
There are two ways to do this, you can use genkernel, or you can use my bliss initramfs creator. I will show you both.
+
Create the file <code>/tftproot/winxp.sif</code> and add the following, replacing <tt>SAMBA_SERVER_IP</tt> with the local IP address of your samba server:
 +
{{File
 +
|/tftproot/winxp.sif|<pre>
 +
[data]
 +
floppyless = "1"
 +
msdosinitiated = "1"
 +
; Needed for second stage
 +
OriSrc = "\\SAMBA_SERVER_IP\tftproot\winxp\i386"
 +
OriTyp = "4"
 +
LocalSourceOnCD = 1
 +
DisableAdminAccountOnDomainJoin = 1
  
=== genkernel ===
+
[SetupData]
<console>
+
OsLoadOptions = "/fastdetect"
# ##i##emerge -av sys-kernel/genkernel
+
; Needed for first stage
# You only need to add --luks if you used encryption
+
SetupSourceDevice = "\Device\LanmanRedirector\SAMBA_SERVER_IP\tftproot\winxp"
# ##i##genkernel --zfs --luks initramfs
+
</console>
+
  
=== Bliss Initramfs Creator ===
+
[UserData]
If you are encrypting your drives, then add the "luks" use flag to your package.use before emerging:
+
ComputerName = *
 +
</pre>}}
  
 +
== Editing the pxelinux.cfg/default boot menu ==
 +
Edit your boot menu so that it contains the following entry:
 
<console>
 
<console>
# ##i##echo "sys-kernel/bliss-initramfs luks" >> /etc/portage/package.use
+
LABEL WinXP
 +
MENU LABEL Install MS Windows XP
 +
KERNEL winxp.0
 
</console>
 
</console>
  
Now install the creator:
+
== Re-Start all required daemons ==
 
+
If the daemon isn't already running use start instead or restart in the following commands
 
<console>
 
<console>
# ##i##emerge bliss-initramfs
+
###i## /etc/init.d/dnsmasq restart
</console>
+
###i## /etc/init.d/in.tftpd restart
 
+
 
+
Then go into the install directory, run the script as root, and place it into /boot:
+
<console># ##i##cd /opt/bliss-initramfs
+
# ##i##./createInit
+
# ##i##mv initrd-<kernel_name> /boot
+
 
</console>
 
</console>
'''<kernel_name>''' is the name of what you selected in the initramfs creator, and the name of the outputted file.
 
  
== Using boot-update ==
+
== Modify Binlsrv, update driver cache, and start driver hosting service ==
=== /boot on separate partition ===
+
Change the BASEPATH= variable at or around line #62 of ''<code>binlsrv.py</code>'' so that it is:
If you created a separate non-zfs partition for boot then configuring boot-update is almost exactly the same as a normal install except that auto detection for root does not work. You must tell boot-update what your root is.
+
==== Genkernel ====
+
If your using genkernel you must add 'real_root=ZFS=<root>' and 'dozfs' to your params.
+
Example entry for boot.conf:
+
 
<console>
 
<console>
"Funtoo ZFS" {
+
###i## nano binlsrv.py
        kernel vmlinuz[-v]
+
BASEPATH='/tftproot/winxp/i386/'
        initrd initramfs-genkernel-x86_64[-v]
+
        params real_root=ZFS=tank/os/funtoo/root
+
        params += dozfs=force
+
        # Also add 'params += crypt_root=/dev/sda3' if you used encryption
+
        # Adjust the above setting to your system if needed
+
}
+
 
</console>
 
</console>
 
+
Generate driver cache:
==== Bliss Initramfs Creator ====
+
If you used the Bliss Initramfs Creator then all you need to do is add 'root=<root>' to your params.
+
Example entry for boot.conf:
+
 
<console>
 
<console>
"Funtoo ZFS" {
+
###i## cd /tftproot;./infparser.py winxp/i386/
        kernel vmlinuz[-v]
+
        initrd initrd[-v]
+
        params root=tank/os/funtoo/root quiet
+
        # If you have an encrypted device with a regular passphrase,
+
        # you can add the following line
+
        params += enc_root=/dev/sda3 enc_type=pass
+
}
+
 
</console>
 
</console>
 
+
Start binlservice:
After editing /etc/boot.conf, you just need to run boot-update to update grub.cfg
+
<console># ##i##boot-update</console>
+
 
+
=== /boot on ZFS ===
+
TBC - pending update to boot-update to support this
+
 
+
== Final configuration ==
+
=== Add the zfs tools to openrc ===
+
<console># ##i##rc-update add zfs boot</console>
+
 
+
=== Clean up and reboot ===
+
We are almost done, we are just going to clean up, '''set our root password''', and unmount whatever we mounted and get out.
+
 
+
 
<console>
 
<console>
Delete the stage3 tarball that you downloaded earlier so it doesn't take up space.
+
###i## ./binlsrv.py
# ##i##cd /
+
# ##i##rm stage3-latest.tar.xz
+
 
+
Set your root password
+
# ##i##passwd
+
>> Enter your password, you won't see what you are writing (for security reasons), but it is there!
+
 
+
Get out of the chroot environment
+
# ##i##exit
+
 
+
Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
+
# ##i##umount -l proc dev sys boot
+
 
+
Turn off the swap
+
# ##i##swapoff /dev/zvol/tank/swap
+
 
+
Export the zpool
+
# ##i##cd /
+
# ##i##zpool export tank
+
 
+
Reboot
+
# ##i##reboot
+
 
</console>
 
</console>
  
{{fancyimportant|'''Don't forget to set your root password as stated above before exiting chroot and rebooting. If you don't set the root password, you won't be able to log into your new system.'''}}
+
== Booting the client ==
 
+
If all is well, you should be able to boot the client choosing to ''boot from network'' in the boot options, you should get to your PXELinux bootloader, and see the Install Windows XP option after pressing enter you *should* kick off your XP installation via network!! Congratulations!
and that should be enough to get your system to boot on ZFS.
+
 
+
== After reboot ==
+
=== Create initial ZFS Snapshot ===
+
Continue to set up anything you need in terms of /etc configurations. Once you have everything the way you like it, take a snapshot of your system. You will be using this snapshot to revert back to this state if anything ever happens to your system down the road. The snapshots are cheap, and almost instant.
+
 
+
To take the snapshot of your system, type the following:
+
<console># ##i##zfs snapshot -r tank@install</console>
+
 
+
To see if your snapshot was taken, type:
+
<console># ##i##zfs list -t snapshot</console>
+
 
+
If your machine ever fails and you need to get back to this state, just type (This will only revert your / dataset while keeping the rest of your data intact):
+
<console># ##i##zfs rollback tank/os/funtoo/root@install</console>
+
 
+
{{fancyimportant|'''For a detailed overview, presentation of ZFS' capabilities, as well as usage examples, please refer to the [[ZFS_Fun|ZFS Fun]] page.'''}}
+
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
[[Category:Filesystems]]
 
[[Category:Featured]]
 
 
__NOTITLE__
 

Revision as of 23:52, 14 January 2014

Howto use your Funtoo machine to serve a MS Windows installation over the network In this guide we will assume that you have followed the PXE network boot server Wiki article and have a working network/pxe boot setup. As of now this guide will cover Windows XP. Soon it will be expanded to also cover Windows 7.

Contents

Prerequisites

  1. A working Funtoo installation
  2. A working PXE Setup (DHCP, TFTP, PXELinux)
  3. app-arch/cabextract
  4. A legitimate copy of Microsoft Windows
  5. Driver for your NIC - Suggested to use a complete driver pack with all major supported NIC hardware for the version of Windows to be installed.
  6. RIS Linux toolkit >=0.4
  7. A working Samba server setup

Creating the Windows XP Image

  • In the previous guide, PXE Network Boot Server, we used /tftproot as the working directory so we will also use it in this guide for convenience. If you chose to use a different working directory then please apply it where needed in place of the /tftproot we will be going by here.

First you will need to create an ISO from your Windows XP installation disc. If you already have the ISO image you may skip this step.

# dd if=/dev/sr0 of=/tftproot/winxp.iso

If your cdrom device isn't /dev/sr0 please use the appropriate device in this command.

Mount the ISO and Prepare Installation Sources

Mount the image to /tftproot/cdrom:

# mkdir /tftproot/cdrom; mount -o loop /tftproot/winxp.iso /tftproot/cdrom

Create the new directory for the network installation files and copy the needed files to it:

# mkdir /tftproot/winxp; cp -R /tftproot/cdrom/i386 /tftproot/winxp/i386

Depending on your CD/DVD copy of windows the directory name may be I386 as opposed to i386, if that is the case you will just need to change the first part of the command, keeping the new directory name i386 - this is going to be very important later on when creating the remap file! Check the contents of your newly created i386 directory to see if the filenames are in all CAPS or if they are already in lowercase.

# ls /tftproot/winxp/i386

If you happen to have all UPPERCASE filenames, lets go ahead and run a script to convert it to all lowercase:

# cd /tftproot/winxp/i386;ls | awk '$0!=tolower($0){printf "mv \"%s\" \"%s\"\n",$0,tolower($0)}' | sh

Extracting and Modifying the Required Boot Files

Install app-arch/cabextract

# emerge -av app-arch/cabextract

Extract the prepackaged drivers:

# cd /tftproot/winxp/i386;cabextract driver.cab

Install support for a large list of network cards:

# cd /tftproot/;wget http://downloads.sourceforge.net/project/bootfloppy/pxefiles.tar.gz
# tar zxvf pxefiles.tar.gz; cp pxefiles/drivers/* winxp/i386/

Copy the BINLSRV /INFParser tools to /tftproot:

# cp pxefiles/script/* /tftproot/

Extract the netboot startrom:

# cd /tftproot; cabextract winxp/i386/startrom.n1_

Fix the startrom for netbooting xp:

# sed -i -e 's/NTLDR/XPLDR/gi' startrom.n12
# mv startrom.n12 winxp.0

Fix XPLDR:

# cabextract winxp/i386/setupldr.ex_
# sed -i -e 's/winnt\.sif/winxp\.sif/gi' setupldr.exe
# sed -i -e 's/ntdetect\.com/ntdetect\.wxp/gi' setupldr.exe
# mv setupldr.exe xpldr
# cp winxp/i386/ntdetect.com ntdetect.wxp

Creating a remapping file

Create the file /tftproot/tftpd.remap and add the following to it:

ri ^[az]: # Remove “drive letters”
rg \\ / # Convert backslashes to slashes
rg \# @ # Convert hash marks to @ signs
rg /../ /..no../ # Convert /../ to /..no../
rg A a
rg B b
rg C c
rg D d
rg E e
rg F f
rg G g
rg H h
rg I i
rg J j
rg K k
rg L l
rg M m
rg N n
rg O o
rg P p
rg Q q
rg R r
rg S s
rg T t
rg U u
rg V v
rg W w
rg X x
rg Y y
rg Z z
r ^/(.*) \1
r ^xpldr xpldr
r ^ntdetect.wxp ntdetect.wxp
r ^winxp.sif winxp.sif

Install/Configure Samba

If you don't already have net-fs/samba installed, then:

# emerge -av net-fs/samba

Create a Samba share for your tftp server in /etc/samba/smb.conf

Note Note: Be sure you have the other required samba settings configured in the file

[Global]
interfaces = lo eth0 wlan0
bind interfaces only = yes
workgroup = WORKGROUP
security = user

[tftproot]
path = /tftproot
browsable = true
read only = yes
writable = no
guest ok = yes

Start Samba:

# /etc/init.d/samba start

or if samba has already been started:

# /etc/init.d/samba restart

Creating a Setup Instruction File

Create the file /tftproot/winxp.sif and add the following, replacing SAMBA_SERVER_IP with the local IP address of your samba server:

[data]
floppyless = "1"
msdosinitiated = "1"
; Needed for second stage
OriSrc = "\\SAMBA_SERVER_IP\tftproot\winxp\i386"
OriTyp = "4"
LocalSourceOnCD = 1
DisableAdminAccountOnDomainJoin = 1

[SetupData]
OsLoadOptions = "/fastdetect"
; Needed for first stage
SetupSourceDevice = "\Device\LanmanRedirector\SAMBA_SERVER_IP\tftproot\winxp"

[UserData]
ComputerName = *

Editing the pxelinux.cfg/default boot menu

Edit your boot menu so that it contains the following entry:

LABEL WinXP
	MENU LABEL Install MS Windows XP
	KERNEL winxp.0

Re-Start all required daemons

If the daemon isn't already running use start instead or restart in the following commands

# /etc/init.d/dnsmasq restart
# /etc/init.d/in.tftpd restart

Modify Binlsrv, update driver cache, and start driver hosting service

Change the BASEPATH= variable at or around line #62 of binlsrv.py so that it is:

# nano binlsrv.py
BASEPATH='/tftproot/winxp/i386/'

Generate driver cache:

# cd /tftproot;./infparser.py winxp/i386/

Start binlservice:

# ./binlsrv.py

Booting the client

If all is well, you should be able to boot the client choosing to boot from network in the boot options, you should get to your PXELinux bootloader, and see the Install Windows XP option after pressing enter you *should* kick off your XP installation via network!! Congratulations!