homehowtokbslinksaboutcontactprojectsmusic

Index > Help Tutorials > Create Ubuntu for Ram
Note: I did the whole (server & client) setup on my laptop running Ubuntu Desktop 12.04 LTS

Server Setup

Install the required packages, please exclude isc-dhcp-server from the list you are going to use exisitng dhcp.
sudo apt-get install isc-dhcp-server tftpd-hpa syslinux nfs-kernel-server initramfs-tools -y
Set DHCP
nano /etc/dhcp/dhcpd.conf
Paste the following and save the file
allow booting;
allow bootp;

subnet 192.168.2.0 netmask 255.255.255.0 {
  range 192.168.2.xxx 192.168.2.xxx;
  option broadcast-address 192.168.2.255;
  option routers 192.168.2.xxx;
  option domain-name-servers 192.168.2.xxx;

  filename "/pxelinux.0";
}

# force the client to this ip for pxe.
# This is only necessary assuming you want to send different images to different computers.
host pxe_client {
  hardware ethernet xx:xx:xx:xx:xx:xx;
  fixed-address 192.168.2.xxx;
}
Restart DHCP server
sudo service isc-dhcp-server restart
Set up TFTP server
nano /etc/default/tftpd-hpa
Make changes like following
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"        
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
Configure TFTP root directory
sudo mkdir -p /tftpboot/pxelinux.cfg
sudo cp /usr/lib/syslinux/pxelinux.0 /tftpboot
Create configuration file
nano /tftpboot/pxelinux.cfg/default
Copy the boot image to home directory
sudo cp /boot/vmlinuz-$(uname -r) ~
Copy the /etc/initramfs-tools to /etc/initramfs-pxe and change the boot flag using initrramfs.conf in /etc/initramfs-pxe folder rather than modifying the original
cp -r /etc/initramfs-tools /etc/initramfs-pxe
Now edit the file
nano /etc/initramfs-pxe/initramfs.conf
Find MODULES=most and replace it with MODULES=netboot, BOOT=local with BOOT=nfs, and DEVICE= DEVICE=eth0
Now run mkinitramfs
mkinitramfs -d /etc/initramfs-pxe -o ~/initrd.img-$(uname -r)
Now copy boot image and kernel to tftp
sudo cp ~/{vmlinuz-$(uname -r),initrd.img-$(uname -r)} /tftpboot/ 
Now setup the pxe option for new boot system
echo "default linux" >> /tftpboot/pxelinux.cfg/default
echo "label linux" >> /tftpboot/pxelinux.cfg/default
echo "kernel vmlinuz-$(uname -r)" >> /tftpboot/pxelinux.cfg/default
echo "append root=/dev/nfs initrd=initrd.img-$(uname -r) nfsroot=xxx.xxx.xxx.xxx:/nfs ip=dhcp rw" >> /tftpboot/pxelinux.cfg/default
Change the permission
chmod 755 /tftpboot -R
finally restart the tftp service
service tftpd-hpa restart
Now you are almost done with server setting, lets move to next part

Client Setup

This setup can be done on server or desktop, I used desktop. Install the tools we needed to create base image
apt-get -y install debootstrap
Install the base system (Ubuntu 12.04 LTS 32)
debootstrap --arch i386 precise /nfs
Set /nfs as NFS share
nano /etc/exports
Paste the following and save the file
/nfs             *(rw,no_root_squash,async,insecure)
Sync you exports
sudo exportfs -rv
Set the mount option
nano /nfs/etc/fstab
Paste the following and save the file
proc            /proc         proc    defaults 0 0
/dev/nfs        /             nfs     defaults 0 0
none            /tmp          tmpfs   defaults 0 0
none            /var/tmp      tmpfs   defaults 0 0
none            /media        tmpfs   defaults 0 0
none            /var/log      tmpfs   defaults 0 0
Change /nfs/etc/resolvconf/resolv.conf.d/original file and update dns according to your enviornment.
nano /nfs/etc/resolvconf/resolv.conf.d/original
Now copy the timezone, localtime, sources.list and modules over to the new base system.
cp /etc/{timezone,localtime} /nfs/etc/
cp /etc/apt/sources.list /nfs/etc/apt/
If you are going to use lxde then you dont need to do this
cp -r /lib/modules/$(uname -r) /nfs/lib/modules/
Now chroot the base system, all following need to be done in chroot enviornment
chroot /nfs
Set the locales
locale-gen en_US.UTF-8
update-locale LANG=en_US.UTF-8
dpkg-reconfigure -u tzdata
Set the host name, I am leaving it empty
echo "local" > etc/hostname
Add user account
adduser view
Exit out of chroot
exit
Now boot the client to PXE and make sure you can login with view user. If everything looks good then install desktop if needed, there are two ways to install it.
1) Install it in chroot enviornment, (you might ran into some issues)
2) Add view to sudo group chroot /nfs and add view to sudo group usermod -a -G sudo view && exit. Boot the client to PXE. Login as view user and make him root sudo bash and install packages you like. I used the second method and recommend using it.
sudo apt-get install ubuntu-desktop
Or without add ons
sudo aptitude install --no-install-recommends ubuntu-desktop ssh
Or lighter GUI
apt-get install lxde lxdm nano ssh -y
Or even lighter GUI
sudo apt-get install xfce4
Run cleanup
apt-get autoremove && apt-get autoclean

Install the acpid, it allow you to control the power button behavior
apt-get install acpid
Reference