Installing Slackware 14.1

From BitFolk
Jump to navigation Jump to search

Installing Slackware 14.1 (32bit) on a bitfolk vps

Before you start

The default recommended install for slackware is everything except for kdei, ref for which you usually just install your locale. The space used can obviously be reduced by not installing things like X, or servers that are not going to be used, but this how-to doesn't assume what you will or won't use. That is left to you in the usual slackware way.

If you have less than 15gb or more of storage you will not be able to retain the installation packages on your virtual drive, there simply isn't enough space.

Part 1. preparing the virtual drives

log in to xen shell (using putty from windows, or ssh from linux or mac)

ssh yourserver.console.bitfolk.com
yourserver
yourpassword

By default bitfolk allocate two virtual disks for your virtual machine. xvda (the main amount) and xvdb (an amount equal to the ram you have allocated) presumably for swap. If you want to specify your own swap size, you could remove the two virtual drives and create a single virtual drive instead. This installation guide assumes that you have done this. (or at least it ignores /dev/xdb entirely).

I noticed that a bit late, and don't want to start all over, but you will want to sort that out before going further. if you don't sort this now, you'll have to start all over if you want to change it.

type disks

to view and change the arrangement of virtual drives made up out of your purchased disk space.

When you are happy with the virtual disk allocation, you can get back to the xen-shell prompt and continue....

For this install we are assuming at least 10GB of space allocated to the first virtual disk /dev/xvda

Part 2. partitioning drives and obtaining the install files

Partitioning the drive

  • type rescue
  • log on as user with password given
  • To avoid having to sudo everything type sudo su
    (now we can do everything as root)
  • type fdisk -l to check the drive of the virtual machine.
    On mine it is /dev/xvda
  • type fdisk /dev/xvda
  • then n for a new partition
  • then p for a primary partition
  • then 1 for the partition number
  • accept the default start position, and for the size +XGB where X is (storage purchased) - (2 x system RAM) in GB
  • then n for a new partition
  • then p for a primary partition
  • then 2 for the partition number
  • Accept the default start position and end position, then press t and then 2 and then 82 to set the second partition as a swap file
  • Finally press w to write the changes and quit fdisk.

Now to format the new partition ext3 (for ext2 , just miss out the -j )

mke2fs -j /dev/xvda1

Now to create a mount point

mkdir -p /mnt/slackware

and to mount

mount /dev/xvda1 /mnt/slackware

Lets also format and activate the swap partition we just created

mkswap -L SWAP /dev/xvda2

Setting up the file structure and getting the install files

Now to create a boot point and a location for the install files

mkdir -p /mnt/slackware/boot/grub
mkdir -p /mnt/slackware/slackdisk

Now to download the slack files

rsync -azP --delete --exclude 'source/' rsync.mirrorservice.org::ftp.slackware.com/pub/slackware/slackware-14.1/ /mnt/slackware/slackdisk

(If you have 20GB of storeage then you can omit the --exclude 'source/' to include the source code as well. This will increase the space used from 2.5G to 6.1G at this point of the installation.

When that is done we can do some more prep, and then install.

ln -s /usr/bin/du /bin/du
mkdir /usr/local/sbin

If you did download the source, use

cp /mnt/slackware/slackdisk/source/a/pkgtools/scripts/installpkg /usr/local/sbin/

Otherwise the following two lines..

cd /usr/local/sbin
wget ftp://ftp.slackware.org.uk/slackware/slackware-14.1/source/a/pkgtools/scripts/installpkg

then

chmod +x /usr/local/sbin/installpkg

Note: If you have less than 20GB and did download the source files you will have to do rm -r /mnt/slackware/slackdisk/source to delete the source files, otherwise you'll run out of space in the install.

We should also remove all unwanted kdei packages at this point for the same reason.

cd /mnt/slackware/slackdisk/slackware/kdei
rm `ls|grep -v en_GB`

(change the en_GB to your locale)

If your virtual storage is only 10GB then we will need to delete the install packages when they have been installed to free space

  • Option 1. limited storage space (<15G)
    • This installs all the packages to the mount point, deleting the install packages as we go to free up space.
    • cd /mnt/slackware/slackdisk/slackware
      
      for i in `ls|grep "/"`; do
      installpkg --root /mnt/slackware/ /mnt/slackware/slackdisk/slackware/${i}*.t?z
      rm -r /mnt/slackware/slackdisk/slackware/$i
      done
    • (this will take some while. ignore the warning about tar >1.13 )
  • Option 2. (15G or more storage)
    • This just installs everything.
    • ./installpkg --root /mnt/slackware/ /mnt/slackware/slackdisk/slackware/*/*.t?z
    • (this will take some while. Ignore the warning about tar >1.13 )

The install uses about 8.5GB (assuming you choose option 1. )

Because we are not using the slackware main setup installer, we will have to manually do a little bit of extra configuration.

  • first to set up an appropriate keymap. All the keymappings can be found in /mnt/slackware/usr/share/kbd/keymaps and their subdirectories. For example, the uk one is found at /mnt/slackware/usr/share/kbd/keymaps/i386/qwerty/uk.map.gz For this example I'll use uk.map.
  • We need to create a rc.keymap file and put it in /etc/rc.d on the destination partition
    echo -e "\043\041/bin/sh\n\043 Load the keyboard map.  More maps are in /usr/share/kbd/keymaps.\nif [ -x /usr/bin/loadkeys ]; then\n /usr/bin/loadkeys uk.map\nfi\n" >/mnt/slackware/etc/rc.d/rc.keymap
    chmod 755 /mnt/slackware/etc/rc.d/rc.keymap
  • Now we need to set the timezone
  • Find the name and location of your timezone. Look in /mnt/slackware/usr/share/zoneinfo/xxx/yyy where xxx is the region and yyy is the city. For the uk the location is /mnt/slackware/usr/share/zoneinfo/Europe/London
  • To apply it we type ln -sf /mnt/slackware/usr/share/zoneinfo/Europe/London /mnt/slackware/etc/localtime-copied-from
    then cp -f /mnt/slackware/etc/localtime-copied-from /mnt/slackware/etc/localtime

Part 3. Recording network settings and changing init to handle the xen console

Now we can use the rescue images' dns values

cp /etc/resolv.conf /mnt/slackware/etc/

Lets check the network settings for later.

  • ifconfig|grep "inet addr"|grep -v "127.0.0.1"|awk -F":" '{print $2}'|awk '{print $1}'
    This will tell you your assigned ip4 public address (just in case you forgot it)
  • ifconfig|grep Mask|grep -v "127.0.0.1"|awk -F":" '{print $NF}'
    This will tell you your ip4 netmask
  • route -n|grep UG|awk '{print $2}'
    This will tell you your default gateway
  • cat /etc/resolv.conf |awk '{print $2}'
    This will tell you the default bitfolk dns values

Make a note of these values for later

Now to enter the new system for final admin work

chroot /mnt/slackware

Here we comment out the tty entries and add the xen hvc entry so we can see what happens from the virtual machine login.

sed "s/^c[1-6]/#&/g" -i /etc/inittab
sed "/#c6/a \
co:12345:respawn:\/sbin\/agetty 38400 hvc0 linux" -i /etc/inittab

We also need to allow root to log in on that hcv0 xen terminal

cat "hvc0" >> /etc/securetty

We can set up some kernel vm type magic by creating sysctl.conf. Don't ask me what it does.!

 
echo -e "vm.swappiness = 60\nvm.lower_zone_protection = 100\nvm.vfs_cache_pressure = 200\nvm.min_free_kbytes = 65536\nvm.zone_reclaim_mode =0">/etc/sysctl.conf

Part 4. building a kernel so xen can boot

Now to build a kernel to support xen and to include ext2/3/4 support built in (so we don't need to bother with an initrd)

cd /usr/src/linux
make menuconfig

There are five entries to be changed:

  • General setup → Kernel compression mode (Gzip) Xen can only boot gzipped kernels, not LZMA.
  • Processor type and features → Linux guest support → Enable paravirtualization code → Xen guest support
  • File systems → Second extended fs support (make sure this is a <*> not <M> )
  • File systems → Ext3 journalling file system support (make sure this is a <*> not <M> )
  • File systems → The Extended 4 (ext4) filesystem (make sure this is a <*> not <M> )
make all -j2

(this will take ages - think hours)

make modules_install -j2

(this is a bit quicker)

cp -a arch/x86/boot/bzImage /boot/
cp -a .config /boot/config
cp -af System.map /boot/

Part 5. Configuring grub and network so pygrub can boot your os

Now set up the grub file read by bitfolk to boot the os

echo -e "default  0\ntimeout  2\ntitle  Slackware 14.1\nroot  (hd0,0)\nkernel  /boot/bzImage root=/dev/xvda1 ro" >/boot/grub/menu.lst

(note that is MENU.LST in lower case)

Now setup fstab (This is all on one line. If you chose to format using ext2 instead of ext3, amend the next line accordingly)

echo -e "/dev/xvda2\tswap\t\tswap\tdefaults\t\t0\t0\n/dev/xvda1\t/\t\text3\tdefaults\t\t1\t1\ndevpts\t\t/dev/pts\tdevpts\tgid=5,mode=620\t\t0\t0\nproc\t\t/proc\t\tproc\tdefaults\t\t0\t0" >/etc/fstab

Now to configure network

netconfig

fill out the details you obtained earlier. You can add the second dns to /etc/resolv.conf

echo "nameserver 85.119.80.233" >>/etc/resolv.conf

(use the ip value obtained earlier)

The root password for the new virtual machine needs to be set.

passwd root

Put in the password you want to use

We are almost done. Now exit the chroot by typing exit and stop the virtual machine rescue mode by typing halt

Part 6. Running your new installation

You can now run boot at the xen console prompt to start your new installation.

Once you have logged in as root, and before you configure anything else, you can update packages that have been updated to fix security bugs etc.

cd /slackdisk/patches/packages
upgradepkg *.txz

you can also run

rsync -azP --delete rsync.mirrorservice.org::ftp.slackware.com/pub/slackware/slackware-14.1/patches/packages/ /slackdisk/patches/packages

at any later time which will fetch all the security updated packages to your local drive, where you can then review (and install) them.

If you did this before 8th April 2014, make sure you download and install the latest openssl-1.0.1g-i486-1_slack14.1.txz and openssl-solibs-1.0.1g-i486-1_slack14.1.txz so that you are protected from the openssl bleeding heart vulnerability.

January 2016 ssh update

This update changes the default settings for ssh root login. If you want to be able to continue logging in directly as root (with password) you will need to update /etc/ssh/sshd_config by uncommenting the PermitRootLogin yes as the default compiled in option for sshd root login has changed to prohibit-password

More stuff to do

You can also cd to /etc/rc.d/ and make executable the rc. scripts that you want to run on startup. eg. httpd (apache), sendmail, mysql (mariadb), saslauthd once you have configured the various server software config files.

See the slackware documentation project for info about setting up and running slackware.

To create and install packages not included with slackware, you may find sbopkg useful.

cd /tmp
wget http://sbopkg.googlecode.com/files/sbopkg-0.37.0-noarch-1_cng.tgz
installpkg sbopkg*

sbopkg will allow you to sync with the slackbuilds.org repository, and allow you to search slackbuilds, and build them, downloading the source as required, and then install them. Make sure to read the readme's and info files for any dependancies you need to install first.

Protecting your ssh login from hackers

A strongly recommended package is DenyHosts. This allows you to block brute force password attacks on ssh. You can get a good how-to on configuring it here. You can install DenyHosts using sbopkg, but you will still have to follow the instructions to configure it for slackware.

You just have to cat /var/log/messages to see all those nasty hackers trying to ssh into your system within minutes of your system being installed. Deny hosts can help keep them at bay.
See also the comment a few paragraphs earlier about openssl which affects ssh as well.

Comments:

  1. You will notice I haven't used pico or nano to edit any files during setup. This is because Ctrl-O (used to save changes in nano or pico) is interpreted by the xen console instead. Once your system is up and running, you can log in to your VM via ssh, and use pico/nano as much as you like. It is only when logging in to the xen console that there is the limitation.
  2. If you mess up in the xen console and want to get back to the xen console prompt, type ctrl-] and press enter
    You can then halt or boot or enter rescue mode as needed.
  3. You can run most of the official installer actions once you have booted into your new slackware system. As root, type pkgtool and select setup. You can pick the setup scripts you want to run. Just make sure you don't reinstall the kernel, or you'll have to copy your new one over it again.