= Slackware = The original Linux distribution, geared towards power and stability. http://www.slackware.com == Vagrant on Slackware 14 32 bit == Ruby version: ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux] VirtualBox version, Oracle VM VirtualBox Manager 4.2.8 === Install Vagrant from source === Based on [[https://github.com/mitchellh/vagrant/wiki/Installing-Vagrant-from-source]] As root run the following: * cd /tmp * mkdir gitVagrant * cd gitVagrant * git clone https://github.com/mitchellh/vagrant.git * cd vagrant * git pull origin master #get latest version * #git reset a40522f5fabccb9ddabad03d836e120ff5d14093 --hard # reset to v1.3.5 * git reset 7ec0ee1d00a916f80b109a298bab08e391945243 --hard #reset to v1.2.7 * gem install bundle #it may not be installed * bundle install * rake install * gem list * gem uninstall vagrant #uninstall other old gems * vagrant -v #check vagrant version === Install VirtualBox on Slackware 14 32 bit === Get VirtualBox 4.2.8 for Linux, i386, all distributions [[http://download.virtualbox.org/virtualbox/4.2.8/VirtualBox-4.2.8-83876-Linux_x86.run]]. For 4.2.18 [[http://download.virtualbox.org/virtualbox/4.2.18/VirtualBox-4.2.18-88781-Linux_x86.run]] As root run the following commands: * cd * chmod 755 VirtualBox-4.2.8-83876-Linux_x86.run * ./VirtualBox-4.2.8-83876-Linux_x86.run * usermod -a -G vboxusers * id #check user groups As a normal user run the following: * virtualbox --help # check the version and parameters * virtualbox #start virtualbox === Get and run a base box - Ubuntu Lucid32 === In [[http://www.vagrantbox.es/]] there is a list of available vagrant boxes. As normal user run the following * mkdir -p /tmp/vgbox * cd /tmp/vgbox * wget http://files.vagrantup.com/lucid32.box #Ubuntu 10.04 LTS * vagrant box add UbuntuLucid32 lucid32.box * vagrant init UbuntuLucid32 * vagrant up * vagrant ssh #access the VM through SSH * ping www.sapo.pt #inside VM ... does not reply * exit * vagrant suspend Run the following as stated in [[http://serverfault.com/questions/453185/vagrant-virtualbox-dns-10-0-2-3-not-working]]: * VBoxManage list vms * VBoxManage modifyvm "vgbox_1372194938" --natdnsproxy1 on * VBoxManage modifyvm "vgbox_1372194938" --natdnshostresolver1 on * vagrant resume * vagrant ssh * ping www.sapo.pt # OK ! it gets ping replies * dpkg -l | more # show all installed packages Running '''cat /etc/debian_version''' show its based on '''squeeze/sid'''. Running '''cat /etc/issue.net''' show it's '''Ubuntu 10.04.4 LTS''' [[http://releases.ubuntu.com/lucid/]]. Current user and pass for the lucid32 box is '''vagrant''' '''vagrant'''. To get superuser access run '''sudo bash'''. Inspecting the file '''/etc/shadow''' we can see that only the user vagrant has a password defined. In '''/etc/sudoers''' it is said that all users belonging to group can gain root privileges with supplying a password. In '''/etc/group''' it is stated that vagrant belongs to the admin group. === Ubuntu Precise32 === In [[http://www.vagrantbox.es/]] there is a list of available vagrant boxes. As normal user run the following * mkdir -p ~/Downloads/vagrantBoxes/ * cd ~/Downloads/vagrantBoxes/ * wget http://files.vagrantup.com/precise32.box #Ubuntu 12.04 LTS * mkdir -p /tmp/precise32 * cd /tmp/precise32 * vagrant box add UbuntuPrecise32 ~/Downloads/vagrantBoxes/precise32.box * vagrant init UbuntuPrecise32 * vagrant up * vagrant ssh #access the VM through SSH * ping www.sapo.pt * exit * vagrant suspend == Slackware NAT router with Pen 3G == Configure Slackware PC to share a 3G internet connection (TMN portuguese ISP). === Internet connection === The used '''APN''' is '''internet'''. There is no PIN defined in the used SIM card. Edit '''/etc/ppp/peers/tmnpub''' * /dev/ttyUSB0 * 460800 * connect 'chat -v -f /etc/ppp/chat/tmnpub' * defaultroute * usepeerdns Edit '''/etc/ppp/chat/tmnpub''' * ABORT 'BUSY' * ABORT 'NO CARRIER' * ABORT 'ERROR' * ABORT 'SIM PIN' * ABORT 'SIM PUK' * '' AT * OK AT+CGDCONT=1,"IP","internet" * OK AT+CPIN? * READY ATDT*99# * CONNECT To connect to the internet we must use the command: * pppd call tmnpub Using the command '''ifconfig''' we should see the device '''ppp0''' in the output. Issuing a command '''ping www.google.com''' we should get a reply with the IP address from Google. === Configure NAT (Network Address Translation) router === Translate internal network addresses (source address) to a public/usable IP address given to the 3G modem. View the routing table: * route -n It should appear the devices ppp0 and eth0, and based on the Destination and Netmask the destination interface. Enable IP forwarding: * echo 1 > /proc/sys/net/ipv4/ip_forward Configure iptables to translate the address after they are forwarded to the correct interface, from '''eth0''' to '''ppp0''': * iptables -F * iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE To view the iptables configuration run the commands: * iptables -L -t nat -v * iptables -L -t filter -v {{{#!highligth bash #script #Enable IP forwarding: echo 1 > /proc/sys/net/ipv4/ip_forward #Configure iptables to translate the address after they are forwarded to the correct interface, from eth0 to ppp0: iptables -F iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE }}} === Configure client computer === The routing table must be configure to use the NAT on Slackware, that will act as a router. Check the current default gateway: * route -n The line with destination equal to 0.0.0.0 and gateway 0.0.0.0, is the default router/gateway and must be deleted. We must run a command to do that, adapted to the current situation: * route del -net 0.0.0.0 gw 192.168.1.1 The previous command is to delete a route with destination 0.0.0.0 and gateway 192.168.1.1. If the NAT router have the IP 192.168.1.123 then the following command must be sent: * route add default gw 192.168.1.123 * route -n After that running '''route -n''' should return a line with: * Gateway: 192.168.1.123 * Netmask: 0.0.0.0 * Destination: 0.0.0.0 * Iface: eth0 Running a '''ping www.google.com''' from the client computer should return the IP address from Google. Running a '''traceroute www.google.com''' should show the IP address from the NAT router. === Windows === * route print * route delete 0.0.0.0 * route add 0.0.0.0 192.168.1.123 == Generic kernel == The “generic” kernel on the other hand, is a kernel which has virtually no drivers built in. All drivers will be loaded into RAM on demand. {{{ #/usr/share/mkinitrd/mkinitrd_command_generator.sh # # mkinitrd_command_generator.sh revision 1.45 # # This script will now make a recommendation about the command to use # in case you require an initrd image to boot a kernel that does not # have support for your storage or root filesystem built in # (such as the Slackware 'generic' kernels'). # A suitable 'mkinitrd' command will be: mkinitrd -c -k 3.2.45-smp -f ext4 -r /dev/sda1 -m usb-storage:ehci-hcd:usbhid:uhci-hcd:mbcache:jbd2:ext4 -u -o /boot/initrd.gz # Add to /etc/lilo.conf image = /boot/vmlinuz-generic-smp-3.2.45-smp initrd = /boot/initrd.gz # add this line so that lilo sees initrd.gz root = /dev/sda1 label = SlackwareGeneric read-only # run lilo -v }}} == USB boot in VirtualBox == $VBoxManage convertfromraw -format VDI usbboot.img usbboot.vdi == Generic on Slackware64 14.0 == * /usr/share/mkinitrd/mkinitrd_command_generator.sh * mkinitrd -c -k 3.2.29 -f ext4 -r /dev/sda5 -m usbhid:ehci-hcd:mbcache:jbd2:ext4 -u -o /boot/initrd.gz Add to /etc/lilo.conf {{{ image = /boot/vmlinuz-generic-3.2.29 initrd = /boot/initrd.gz # add this line so that lilo sees initrd.gz root = /dev/sda5 label = SlackGen read-only }}} * lilo -v == System V (Sys V) init == Slackware since 7.0 also allows Sys V inits. Sample service /etc/init.d/blah: {{{#!highlight bash #! /bin/sh # /etc/init.d/blah # # Some things that run always touch /var/lock/blah # Carry out specific functions when asked to by the system case "$1" in start) echo "Starting script blah " echo "Could do more here" ;; stop) echo "Stopping script blah" echo "Could do more here" ;; *) echo "Usage: /etc/init.d/blah {start|stop}" exit 1 ;; esac exit 0 }}} Mark script as executable: * chmod 755 /etc/init.d/blah Default runlevels (2 3 4 5): * ln -s /etc/init.d/blah /etc/rc2.d/S99blah * ln -s /etc/init.d/blah /etc/rc2.d/K10blah * ln -s /etc/init.d/blah /etc/rc3.d/S99blah * ln -s /etc/init.d/blah /etc/rc3.d/K10blah * ln -s /etc/init.d/blah /etc/rc4.d/S99blah * ln -s /etc/init.d/blah /etc/rc4.d/K10blah * ln -s /etc/init.d/blah /etc/rc5.d/S99blah * ln -s /etc/init.d/blah /etc/rc5.d/K10blah Check symbolic links: * ls /etc/rc*.d == Sys V init for Python script == Sample service /etc/init.d/blah: {{{#!highlight bash #! /bin/sh # /etc/init.d/blah # # Some things that run always touch /var/lock/blah # Carry out specific functions when asked to by the system case "$1" in start) logger "Starting beat.py" echo "Starting beat.py" /usr/bin/python /tmp/beat.py & ;; status) PID=`cat /var/run/beat.pid` logger "Process running with PID $PID" echo "Process running with PID $PID" ;; stop) PID=`cat /var/run/beat.pid` logger "Killing process with PID $PID" echo "Killing process with PID $PID" kill -9 $PID rm /var/run/beat.pid ;; *) echo "Usage: /etc/init.d/blah {start|status|stop}" exit 1 ;; esac exit 0 }}} Mark script as executable: * chmod 755 /etc/init.d/blah Default runlevels (2 3 4 5): * ln -s /etc/init.d/blah /etc/rc2.d/S99blah * ln -s /etc/init.d/blah /etc/rc2.d/K10blah * ln -s /etc/init.d/blah /etc/rc3.d/S99blah * ln -s /etc/init.d/blah /etc/rc3.d/K10blah * ln -s /etc/init.d/blah /etc/rc4.d/S99blah * ln -s /etc/init.d/blah /etc/rc4.d/K10blah * ln -s /etc/init.d/blah /etc/rc5.d/S99blah * ln -s /etc/init.d/blah /etc/rc5.d/K10blah Check symbolic links: * ls /etc/rc*.d Python /tmp/beat.py code: {{{#!highlight python #!/usr/bin/python import threading import time import os import syslog import datetime class Beat(threading.Thread): def __init__(self): threading.Thread.__init__(self) #required def run(self): loop=True while loop: syslog.syslog(syslog.LOG_INFO, "Beat %s"%(datetime.datetime.now()) ) time.sleep(5) if __name__=="__main__": f=open('/var/run/beat.pid','wa') f.write('%d'%(os.getpid())) f.close() os.getpid() b = Beat() b.start() }}} == Packages updates == Check patches/packages and patches/PACKAGES.TXT for the desired Slackware version. URL for Slackware 14.0 ftp://ftp.slackware.com/pub/slackware/slackware-14.0/patches/ === Get packages to be updated === * cd ~/Downloads/slack14i386patches * wget ftp://ftp.slackware.com/pub/slackware/slackware-14.0/patches/PACKAGES.TXT * cat PACKAGES.TXT | grep "PACKAGE NAME" | awk '//{print $3}'| sed 's/.txz//g' | xargs -i ls /var/log/packages/{} &> /tmp/out.txt ;mkdir -p /tmp/packages;cd /tmp/packages; cat /tmp/out.txt | grep cannot | awk '//{print $4}' | sed 's/\/var\/log\/packages\///g' | sed 's/://g' | xargs -i wget ftp://ftp.slackware.com/pub/slackware/slackware-14.0/patches/packages/{}.txz === Caching only nameserver/DNS server === * chmod 755 /etc/rc.d/rc.bind * Check the configuration with '''named-checkconf'''. * Start the service with /etc/rc.d/rc.bind start Edit '''/etc/resolv.conf''' {{{ nameserver 127.0.0.1 }}} Edit '''/etc/named.conf''' {{{ options { directory "/var/named"; forwarders { 8.8.8.8; 8.8.4.4; }; }; // a caching only nameserver config zone "." IN { type hint; file "caching-example/named.root"; }; zone "localhost" IN { type master; file "caching-example/localhost.zone"; allow-update { none; }; }; zone "0.0.127.in-addr.arpa" IN { type master; file "caching-example/named.local"; allow-update { none; }; }; logging { channel my_named_channel { file "/tmp/named.log"; // syslog info; // Set the severity to dynamic to see all the debug messages. severity dynamic; print-time yes; print-severity yes; print-category yes; }; category queries { my_named_channel; }; category client { my_named_channel; }; category default { default_syslog; }; }; }}} == Update bash on Slackware64 14 == * wget ftp://ftp.slackware.com/pub/slackware/slackware64-14.0/patches/packages/bash-4.2.048-x86_64-2_slack14.0.txz * upgradepkg bash-4.2.048-x86_64-2_slack14.0.txz == Upgrade from Slackware 14.0 to 14.1 == * ctrl+alt+f1 * mount /dev/cdrom /mnt/cdrom * cd /mnt/cdrom * cp slackware /root/ -r * cd /root * telninit 1 * login as root * cd /root/slackware * upgradepkg a/glibc-solibs-*.t?z * upgradepkg a/pkgtools-*.tgz * upgradepkg a/tar-*.tgz * upgradepkg a/xz-*.tgz * upgradepkg a/findutils-*.txz * upgradepkg --install-new /root/slackware/*/*.t?z * removepkg Terminal aumix kdegames kdemultimedia ksecrets mysql printer-applet quanta rexima scim-bridge xxgdb * Check file /etc/lilo.conf to see which old kernel is used #/boot/vmlinuz-generic-smp-3.2.45-smp * /usr/share/mkinitrd/mkinitrd_command_generator.sh -k 3.10.17-smp | bash * In /etc/lilo.conf use image=/boot/vmlinuz-generic-smp-3.10.17-smp * lilo -v * telinit 3 * reboot * After the reboot shows the kernel version 3.10.17 * In /etc/rc.d/rc.local add modprobe snd_mixer_oss