homehowtokbslinksaboutcontactprojectsmusic

Index > My Projects > osis on Linux
I am using Ubuntu Server 14.04 LTS (kernel ) for this development
Optionally you can delete all kernel which are not in use
sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
Install the tools needed for this development
apt-get install nfs-kernel-server debootstrap -y
Install the base system (Ubuntu 12.04 LTS 32) to /nfs folder on local system
debootstrap --arch i386 trusty /osis
Set /osis as NFS share
echo "" >> /etc/exports
echo "# Development" >> /etc/exports
echo "/osis             *(rw,no_root_squash,async,insecure)" >> /etc/exports
Sync you exports
sudo exportfs -rv
Set the mount option
nano /osis/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 /osis/etc/resolvconf/resolv.conf.d/original file and update dns according to your enviornment if needed.
nano /osis/etc/resolvconf/resolv.conf.d/original
Now copy the timezone, localtime, sources.list over to the new base system and set the computer name for the base system
cp /etc/{timezone,localtime} /osis/etc/
cp /etc/apt/sources.list /osis/etc/apt/
echo "localhost" > /osis/etc/hostname
Now chroot to /osis
chroot /osis
Set the locales and hostname
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
dpkg-reconfigure -u tzdata
Setup password for root
passwd
Setup root for autologin and exit out of chroot
echo "" >> etc/init/tty1.conf
echo "# Autologin account" >> etc/init/tty1.conf
echo "exec /bin/login -f root < /dev/tty1 > /dev/tty1 2>&1" >> etc/init/tty1.conf && exit
Now boot your new system in pxe and do the rest from there, it is musch safe and error free doing from within the live system rather than chrooting to it Install some usefull packages
apt-get update && apt-get dist-upgrade
apt-get install nano ssh wget partimage partclone udpcast ntfs-3g nfs-common smartmontools dnsutils
Considering that you arleady have windows (7 in this example) system ready so lets start the process of capturing windows image using partclone.
mkdir /ntfs
ntfs-3g -o force,rw /dev/sda1 /ntfs
rm -fr /ntfs/{pagefile.sys,hiberfil.sys}
umount /ntfs
Mount the nfs share
mount -o nolock,proto=tcp 192.168.1.2:/images /ntfs
Backup MBRs
dd if=/dev/sda of=/ntfs/sda.mbr bs=512 count=1
dd if=/dev/sda of=/ntfs/sda.vbr bs=512 count=63
Capture image you can also use dd method but I am using partclone.ntfs so partclone.dd -N -c -d -s /dev/hda1 -o hda1.dd.img
partclone.ntfs -N -c -d -s /dev/sda1 -o ntfs/sda1.img
After you are done delete the ntfs folder and reboot the system
umount /ntfs && rm -r /ntfs && reboot
Now test this image by restoring it to different machine, make sure you are using hard drive bigger or equal to the size we used to capture image from. Boot the machine to pxe
partclone.restore -N -d -s /ntfs/sda1.img -o /dev/sda1
Restore MBRs
dd if=/ntfs/sda.mbr of=/dev/sda bs=512 count=1
Delete the temporary folder (ntfs) and reboot the system
umount /ntfs && rm -r /ntfs && reboot


Partclone utils
wget http://www.idealworldinc.com/partclone-utils/partclone-utils.tar.gz
Read the argument passed by pxe config file
$(for var in $(cat /proc/cmdline); do echo export $var | grep =; done)
echo ${dns}
Restrict ssh access to oscis