Wednesday, November 23, 2011

Another Take On Distribution Plurality

We all know these arguments. An outsider comments on Linux distribution plurality and says that the lack of a unified platform is what hurts Linux adoption. This argument is not without its merits, but it isn't exactly a valid argument anyway. The first main issue with it is an obvious one. If no one singularly owns and controls Linux, no one would be able to pull all variants off of the virtual shelves and standardize the community on a singular distribution. Beyond this, there exists an entirely practical reason for distribution plurality that people tend to overlook.

One of the biggest causes of distribution variation is actually just package selection. This wouldn't be the case if applications were easy to install 100% of the time, but they aren't. Most people are not going to be willing to rebuild their compilers, install fifty other packages, change/create 10 environment variables, symlink 20 libraries, and add 3 groups to their machines just to install a single package... and nor should they be. People who are not willing to do these things are not stupid. They are not lazy. They are simply unwilling to do something that ought to have been made simpler by the programmer(s) who created the package. This is a cost/reward scenario that they perhaps rightly feel is heavy on cost and not so much on reward. The thought by the developer(s) is something like "we coded this for Linux, which is a fractured platform, but we made no effort to accommodate any differences that may arise from release to release of even a single distribution, library, or even our own application. Figure it out yourself, because we are too busy, too arrogant, and don't care." In response to this issue, members of the community began making distributions that include everything a day to day user would ever need. All of the annoyances of getting software to work are taken care of by the distribution creator(s), and the rest of the community is free to simply use their computers.

The problems that exist with software installation wouldn't be so terrible if everyone actually documented the software that they create. Quite often, you will find that certain packages are available only for a specific distribution. No other binaries are available. No dependency listings are available. Nothing. You install Ubuntu in a virtual machine. You save a list of every package listed in the default install. You then install the package you originally wanted. You list every file in every package that the targeted package requires. You then scour the internet looking for the project from which each individual file originates. Nothing. Google reveals nothing about your plight at all. No one has ever apparently wanted to run program X on distribution Y. You post your inquiry on a message board (possibly the message board for the targeted package). Nothing. In the history of computing, this is must be a first. No. Thousands of people have had this very problem. Thousands of people get so frustrated by this type of bull shit that they actually go back to using Winders or OSX.

Why does this all happen? (1) Many programmers go fully native for every application that they write without worry of portability. This makes the applications highly non-portable from distribution to distribution, library version to library version, architecture to architecture, and OS to OS. (2) Many programmers mistakenly assume that Ubuntu is the only Linux distribution that matters. (3) The IT field is snobbish, and the technorati look down upon the poor plebian masses despite the fact that it is those plebian masses for whom everyone in IT really works.

So, seeing as most of the software developers out there are never going to change their opinions about any of this, distribution developers/packagers/whateveryoucallthem took on the task. You can use Pinguy and have everything plus the kitchen sink thrown onto a DVD. You can use Slackware and have a ton of different libraries available. For anything not on the install disc you have your repositories, and if that's your cup of tea Debian has the largest repositories of all. It's funny that when the closed-source world decided to create software repositories they called them "app stores" and the idea was "revolutionary."

There were a few issues with these solutions of course. First, no one can ever agree on a package format or build system so we have tons of them. Second, no one can ever agree upon which applications are best to include. This leads to many holy wars (Vi/Emacs, GNOME/KDE, MPlayer/VLC, etc...). Third, everyone wants to be chief. These three reasons cause endless forking and an infinite number of respins. Shortly after Ubuntu was first released there were six versions: Ubuntu, Ubuntu AMD64, Kubuntu, Kubuntu AMD64, Xubuntu, Xubuntu AMD64. A seventh was created not long after, and that was the server version. Within a few releases, Ubuntu had a graphical installer that required a bit of computing power. For lesser machines, we now had a low memory "alternate" version of all of these that excluded that graphical installer and live environment. That makes 14 total versions within the official Ubuntu camp. That's 6 main versions, add in alternates, add in 32bit and 64bit server... 14 total versions. Some people weren't satisfied with any of those 14 and unofficial respins started popping up faster pricks in a brothel.

The nice thing about standards is that there many from which to choose!

Thursday, October 20, 2011

A Slackware Primer

People often look at Slackware with a certain amount of trepidation. It appears complicated, difficult, or tedious. If you ever felt like trying Slackware but didn't because of those fears, this is an article for you. I am going to cover installation step by step, and then proceed to common post install configuration tasks, and a few system management tasks. Before beginning, you need either to have backed up your data, or to have prepared a virtual machine.

Getting Slackware
Slackware has been around for quite some time. It's the oldest actively maintained distribution, and as such has many mirrors in many nations. If you are downloading from HTTP or FTP you will want to pick a mirror in your country or a country close by. If you are going to download Slackware via torrent, you need look no further than the Slackware torrents page. For 32 bit systems, you can choose either 6 CDs or 1 DVD. For 64 bit systems, your choice is only the DVD. Slackware does have an online store through which you can purchase discs, and Microcenter usually carries Slackware CDs and DVDs. If you are downloading Slackware (and I am guessing most people will be), you will need to burn the iso file to disc. This isn't too tough. On a Linux system or Macintosh, you can use dd for this:
dd if=slackware64-dvd.iso of=/dev/sr0
Of course, the iso file name will likely be different from what I have posted, and the device could be /dev/sdxN (on OSX it will be something like /dev/disk1s1). You will need to make adjustments. Many other tools exist for this purpose. In OSX, you can use disktutil. In Windows, you can use ImgBurn, GizmoDrive, Nero, or the Windows 7 ISO tool. In Linux, K3B, Brasero, cdrecord/wodim, and other tools are available.

Installation
Naturally, you will need to put the Slackware disc into your optical drive, and boot from it. To boot from a disc, restart the computer with the disc in the drive. When the manufacturer of your machine's logo is displayed you will need to press ESC, F12, or F8. The specific key varies from manufacturer to manufacturer (HP is usually ESC, Dell is usually F12, Asus amd Toshiba are usually F8), but this should bring up a prompt asking you from which device you would like to boot. Use the arrow keys on your keyboard to navigate to the CD/DVD drive, and then press enter. Your next screen should be:

And at that screen you can just hit enter to proceed.


At this one, if you are using a US English keyboard just hit enter. Otherwise, you are going to want to press "1" and select the keymapping that matches your keyboard. The next image shows us actually getting to a point that becomes useful.


Here we type "root" and then press enter.


Here you need to type "cfdisk". If you have multiple hard disk drives, you may need to specify the drive designation (cfdisk /dev/xxxN). If you have an IDE HD, you can try /dev/hda for your first disk, /dev/hdb for the second, and so on. If you have an SATA HD, you can try /dev/sda for the first one, and /dev/sdb for the second, and so on. In any case, cfdisk can only handle one drive at a time and the syntax must be
cfdisk /dev/sda
Of course you can substitute the sda for whatever you need. I am only going to cover a basic setup, using a single 20GB HD with two partitions. In general, you will likely have a larger HD. Simply subtract 4000 from your disc size (specified in megabytes in cfdisk), and that should make your main partition. The remaining 4GB should be reserved for swap space (a popular setup is 600MB ext3 /boot, 15GB ext4 or jfs /, 4GB swap, * ext4 or jfs /home). If you want to dual boot and you use a PC, go check out partedmagic. It's a liveCD intended for partitioning. You will need to resize your current partitions and make room for Slackware (20GB is the minimum I would recommend). If you are using a Mac, you can use the boot camp tool. On Macs, you will need to use the gdisk tool instead of cfdisk.


So, assuming you have no currently defined partitions the above should be in front of you. If you do have partitions, go ahead and use up and down arrows to select them, and then use the right and left arrows to select the delete button. If you are dual booting, you should have either made some space available already or have a partition in mind that should get deleted. Whatever your choice, select the new button. Press enter.


I prefer to use primary partitions exclusively, just for speed and simplicity.


Again, the size is issued in megabytes. Press enter to have it accept the value.


You will almost certainly want this partition at the beginning of the drive's free space.


While most computers these days don't really require you to flag a partition as bootable, it is usually a good idea to do so.


By pressing the down key, and using the arrow keys to get to the button that says "new", we can add another partition. This is the swap partition. I generally like to have a swap partition that is about 4GB in size. Should the computer run out of memory resource it will use the swap partition free up more memory resource. I like to err on the side of caution.


Seem familiar?


Unlike the previous partition, this one needs to have it's type changed.


Cfdisk is going to assume that you wanted to change the type to swap, and it is correct in this case, as long as it says 82 is the type.


Now comes the dangerous part. We are going to write these modifications to disc. You did backup your data, right?


It is going to ask you to type "yes" to verify that you are indeed sure you wish to do this. Even though you cannot see the "s" of the yes, I assure you that it is there. Press enter.


Hooray! We are done with partitioning. Time to leave cfdisk behind.


Once you exit, you should be put back at a prompt. Type "setup", press enter, and you'll get the installer that hasn't changed because there has never been a reason to change it.


Use the arrow keys to navigate to add swap, or just press 'a'.


The installer should automatically find any discs/partitions that are potentially swap. Press enter so long as this is correct.


The installer is now going to format the swap space, turn it on, and during the process it's going to check for bad blocks (unless of course you tell it not to).


If everything goes according to plan, we can continue.


You should automatically be moved forward to a menu that allows you to select the partition that you would like to use for /, and should you have more than one partition use the arrow keys to select the appropriate parition and then press enter.


You will need to select a filesystem to use. Ext4 is the most common, and it is suitable for most situations. JFS is the one I prefer. ReiserFS is a killer filesystem. XFS and BTRFS are high performance. Ext2 is very fast, but it isn't journaled (an unexpected shutdown could result in massive amounts of data loss, and the filesystem is more easily corrupted).


Horray. If you see a screen similar to this one, you have some partitions. Press enter for 19 millionth time.


Yup, there are several ways to install Slackware. I didn't talk about them. DVDs/CDs and USB sticks are the easiest methods available. For this reason, they are also the most common. Some quick trivia: which key should you press?


99 times out 100, Slackware can automatically find the install media. Occasionally, it cannot. This is usually due to an ATA controller that the kernel version cannot support. Other times, people have failing optical drives.


At this point, you get to make some choices. Slackware divides packages into sets. A is absolutely essential. You will want N, and L as well. If you want a GUI, make sure that X and XAP are installed. GNOME is not available, but XFCE is. If you don't like KDE you have an alternative option. However, the KDE experience on Slackware is second to none (all packages are vanilla). KDE also includes KOffice, and Slackware does not ship with OOo or LibreOffice. Even if you do not intend upon doing development, you will still want the dev packages for SlackBuilds (more on this later). If in doubt just select everything. I dislike Emacs. I am multilingual and like international support. Other than that, I install everything. As usual, you can use the up and down arrow keys to navigate. Space bar selects and deselects package sets. Press enter when done.


Right now, don't worry about the majority of these options. Unless you know exactly what you are doing, go ahead and choose full. Slackware does not check dependencies automatically so if you choose to select packages individually you have to know the dependencies for every package.


This could take a while. Is that cold coffee that you're drinking? Go get a fresh cup.


Some time ago, this used to be a floppy instead of USB stick. While it can be useful, I prefer to use the install disc as my rescue disc.


Unless you have an extremely odd setup, you should be able to use the automatic option here. If you are dual booting a mac, you can still select automatic. This is also true if you plan on using a boot loader that is already installed.


This option does not matter as much as it once did. If you are using NVIDIA, ATI/AMD, or Intel graphics just use standard as the framebuffer drivers are going to give you a good resolution in console anyway. If you are using VIA graphics, you can safely choose any of the 256 color options. For other graphics chipsets, you may want to stay in the realm of 800x600 to be safe. Standard always works though.


Most folks can safely skip this. If you cannot boot, you can always ask for help here or elsewhere.


I would highly recommend not to try this. While it often does work, you may experience difficulties with some of your favorite applications.


If you are dual booting and want to use the boot loader you have already installed, go ahead and choose root (especially if you are dual booting with OSX). If you are dual booting with Winders, lilo should automatically find the Winders partition and add it so you can safely choose MBR. If you are not dual booting, choose MBR.


This really only matter for console mouse support, and doesn't much affect anything else. PS2 mice have a circular connector. USB are thin rectangular connectors. PS2 should work for many laptop trackpads. Dell and HP desktops from '04 and earlier should also choose PS2. Almost all eMachine and Gateway desktops use PS2 as well. The overwhelming majority of people can choose USB at this point.


If you want to use your mouse in console, this is the program that enables it.


Unless you're some kind of luddite, you do want networking. Choose yes.


The hostname is the name of your computer. If you are mixing this machine in with a largely Winders based network, try to make sure that you choose a name that no other computer on the network has. If you do not care about networking capabilities other than internet access then it really doesn't matter.


Most people will not care much either way here. This does not affect your ability to access Winders networks, and doesn't make much difference on UNIX networks either.


If you do not have to manually set your IP address, gateway, and DNS then you should choose DHCP. If you do have to set those then you should choose Static IP. You will have no problem setting those if you've done it on another system.


If you have one, you know about it. If you don't know about it, leave this blank.


Isn't Slackware nice? It's giving you the chance to change your mind.


If you do not know what some of these are, do not touch them. Otherwise, SSH is a secure remote connection service. If you do not care to use it, go ahead and deselect it. Mysqld is a database server. Httpd is web server. Samba is the service that will allow you to connect to Winders networks, share files and printers with Winders machines and the like. If you have a slightly more mature laptop and it uses an external network card (not USB), go ahead and select PCMCIA.


If you are really into this sort of thing, go for it. I prefer to use the regular, old school, terminal font. Although, I also really want a DeLorean... to each his own.


I prefer to keep my machine set to local time, some people prefer to use Universal Coordinated Time. Make your choice. If you choose incorrectly, you can set the clock properly later.


Just choosin' my timezone. Don't mind me.


This will set the default graphic environment for all users. Each user can later change this, but it will be his/her initial default. You are probably already familiar with KDE, but it is a very complete and mature environment. XFCE is fairly complete, decently mature, but it isn't quite as shiny as KDE. Fluxbox and Blackbox have long been staples of the Linux/UNIX desktop, but they are spartan in comparison to KDE. WindowMaker is a clone of the NeXT style desktop. Jobsianites may want to check it out. FVWM2 is highly customizable and has a good following. TWM is a classic, but it is very minimalistic.


You best want to set a root password.


You'll be typing blind. Don't fret. It is accepting the input you give it.


If you choose a bad/short/guessable password, it alerts you. If you are stubborn, it will let you use it anyway. My suggestion is to choose a password that isn't bad/short/guessable.


You did it. You installed Slackware. It really wasn't all that tough was it?


Just choose exit unless you want to redo some part of the installation procedure.


Ctl + alt + del, or reboot, or shutdown -r now, or whatever. It is probably going to try and eject the optical medium as well.

Security Updates
After installing any operating system, you will want to get any updates that are available for security reasons. Slackware has the ability to semi-automatically do this. First, we will want to enable a mirror from /etc/slackpkg/mirrors
vim /etc/slackpkg/mirrors
I live in Georgia, so I chose to use the Georgia Tech mirror. So for me, this
# ftp://ftp-linux.cc.gatech.edu/pub/slackware/slackware64-13.37/
became this
ftp://ftp-linux.cc.gatech.edu/pub/slackware/slackware64-13.37/
The next step is to issue two commands
slackpkg update
and then
slackpkg upgrade-all
Then go ahead and reboot.

X11 and Startup
If you are lucky (and I am sure that many of you will be), you ought not have any issues with X11 at all. To figure out whether or not you are lucky simply type
startx
and see what happens. If you get a nice KDE desktop in the proper resolution, and without anything clearly wrong. You are in luck. If you do not, you have a few options. If you are using an NVIDIA or AMD/ATI graphics card you can get proprietary drivers. AMD's driver should work with Slackware64 or with Slackware. NVIDIA has two separate drivers, one is for x86 and the other is for AMD64. In both cases, you will want to make certain that X11 is not running. A fresh boot, without modification, ought to ensure this. If you are using NVIDIA, you also need to disable the Nouveau driver. To do this, put the Slackware DVD in your optical drive. Then, as root, execute
mount /dev/sr0 /mnt/cdrom
installpkg /mnt/cdrom/extra/xf86-video-nouveau-blacklist/xf86-video-nouveau-blacklist-noarch-1.txz
When you restart the machine, the console will not look as pretty as it did when nouveau was running (assuming that nouveau worked for you at all, with certain nvidia cards it has issues). After this, the installation procedures are not that exciting. Type
ls -l ~
to see the files in your home directory, and what their permissions are. If the listing doesn't show any "x"s to the left of the file name for the driver, then you need to issue
chmod +x *.run
before you can issue
./N*.run
or
./a*.run
Follow the instructions for either driver, and upon another reboot you ought to be in business. If you are using an Intel video chipset and do not get video, you may want to try the latest Intel graphics drivers, for which this installation guide is available. If all goes well and you can get the drivers installed without error, try starting X11 again. If you get what you expected, your next step (should you want to do it) is to tell Slackware to boot into X11 by default.
vim /etc/inittab
You can use the arrow keys to navigate lines. You are looking for a line that looks like this
id:3:initdefault:
Get the cursor to the immediate right of the 3. Press "i" and then hit backspace. Type the number 4, then hit ESC. Next, press ":" and type "wq". Then, press enter. When you restart, you ought to be presented with KDM. Login as root (never do this after the next step).

Users and Groups
At this point, we only ought to have a root user. For most people, the easiest way to add a user is using Kuser. This is the KDE user and group management tool. You can get to this tool through the KMenu: System -> KUser.

To add a user, just click the add button in the top left.


Make sure you set a login shell. Bash and Zsh are the most common. Also, make sure you deselect the disable checkbox, which is automatically checked.


Switch over to the groups tab along the top. You have to add the user to a few groups in order to make this user useful. Typical groups are audio, disk, floppy, video, plugdev, cdrom, netdev, wheel, and scanner. Before you logout and log back in as this new user, you should make your life a little easier and an give yourself some sudo power. At a terminal window:
visudo
look for a line like
#%wheel ALL=(ALL) ALL
and remove the hash so that it becomes
%wheel ALL=(ALL) ALL
this will allow all members of the group wheel to use sudo.

Wireless Networking
If you use or want to use wireless networking. You will probably want to have a decent wireless network management tool. The answer is wicd. The package for wicd is conveniently located on the Slackware DVD. Pop in the disc, open dolphin, select the DVD on the left hand side. Go to the extra folder, then the wicd folder, and press shift and F4. At the terminal prompt, type
sudo installpkg wicd*.txz
It would now be a good idea to check what network hardware you are trying to use. You can try the command "ifconfig -a" to see if the hardware is automatically detected. If it isn't you can use "lspci". The most common problem is firmware related. If you are using a Broadcom 43xx chipset try Slackbuilds. If you are using a newer Macintosh, you will most likely need the Broadcom STA driver and you are going to need to edit src/wl/sys/wl_linux.c at line 485 from init_MUTEX(&wl-;>sem); to sema_init(&wl-;>sem,1); and then issue
make && sudo make install && sudo modprobe wl
LAMP Setup
If you didn't enable httpd and mysqld during setup, that's ok. Go ahead and issue
sudo pkgtool

Here you need to select setup.


Then you need to select services.


Then you need to make sure that you select httpd and mysqld.


After that is done, we can naturally exit.

Your next steps are going to be dealt with by editing some configuration files. With the editor of your choosing (I prefer VIM), open
sudo vim /etc/httpd/httpd.conf
and find the line
# Include /etc/httpd/mod_php.conf
and then remove the # in front of it. Then find the line
DirectoryIndex index.html
and change it to
DirectoryIndex index.html index.php
task accomplished? Good. Now, we need to ensure that we have a MySQL config, which is /etc/my.cnf, and the easiest way to do this is this
sudo cp /etc/my-small.cnf /etc/my.cnf
Create the initial MySQL database
mysql_install_db –user=mysql
Make that database writable by the mysql user
chown -R mysql.mysql /var/lib/mysql
Once this is done, we can start the servers
sudo /etc/rc.d/rc.httpd start
sudo /etc/rc.d/rc.mysqld start
Now we just run the MySQL setup, and we will be finished
mysql_secure_installation
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
At this point, it's useful to know that the default location for your web files will be /var/www/htdocs/ and if you create a folder within that path, you will be able to access these files through your web browser with http://127.0.0.1/foobar/

Multilib 64 Bit
To get a multilib Slackware64 system (one that is capable of running 32 bit applications), we need first to get the 32 bit compatibility packages.
lftp -c 'open http://slackware.com/~alien/multilib/ ; mirror 13.37'
Now, move to that directory
cd 13.37/
And install the first set of packages.
sudo upgradepkg --reinstall --install-new *.t?z
Those were the prerequisits for the following
sudo upgradepkg --install-new slackware64-compat32/*/*.t?z
That should do it.

WINE
WINE is Windows API compatibility layer for Linux that will allow you to run many Windows programs on Linux. This is technically only supported on 32 bit systems, but it can work on Slackware64 Multilib systems. You first need to grab the sources and SlackBuild.
wget http://www.unrealize.co.uk/source/dibeng-max-2010-11-12.zip
wget http://ibiblio.org/pub/linux/system/emulators/wine/wine-1.2.3.tar.bz2
wget http://slackbuilds.org/slackbuilds/13.37/system/wine.tar.gz
You will then need to unpack the SlackBuild archive
tar -xzf wine.tar.gz
Move the source archives into the new folder
mv dibeng-max-2010-11-12.zip wine/
mv wine-1.2.3.tar.bz2 wine/
Now you need to run the SlackBuild script, then install the package.
sudo ./wine.SlackBuild
sudo installpkg /tmp/wine*.tgz
Backup
So, you've gotten everything up and running and you now want to back up your system. No problem. Let's go ahead and get things moving. I am going to assume that you want to backup to an external hard disc drive. The next thing that I am going to assume is that this drive is formatted as NTFS. At this point, let's create a plain old text file that will contain a list of things to exclude from the up.
sudo cat > /etc/systembackup.excludes << "EOF"
+ /dev/console
+ /dev/initctl
+ /dev/null
+ /dev/zero

- /dev/*
- /proc/*
- /sys/*
- /tmp/*
- lost+found/
- /media/*
- /mnt/*
EOF
Now, let's create the backup script.
sudo cat > /usr/bin/systembackup << "EOF"
#!/bin/sh
sudo rsync -av --delete-excluded --exclude-from=/etc/systembackup.excludes / $1;
EOF
Make it executable.
sudo chmod +x /usr/bin/systembackup
So, now all you need to do is issue a single command, and the entire system will be backed up. If you have no other removable external device attached to your computer this command should work just fine
systembackup /media/disk
A Bit About SlackBuilds
In the section about WINE, I used a SlackBuild. SlackBuilds.org is pretty much the Slackware software repository for packages not included in the distribution release. Slackware doesn't use automatic dependency resolution, nor does it use automatic package fetching. Slackpkg is used only for the automatic installation of packages that have been updated for security reasons. Every SlackBuild works like the one shown, and if the SlackBuild has dependencies they are listed on the SlackBuild page.