On installing Linux (almost) from scratch

The following notes document my attempt to build my own custom Linux system. I won't be starting from scratch since compiling the kernel myself would be overkill. The backbone consist of a (very) raw Debian Wheezy and Awesome WM. The system will be simultaneously installed in a Virtual Machine (VMFusion, host OS X) and a desktop machine (i4770kOC + GTX780 + ZX87-OC). Log and notes are valid for both system unless explicitly noted.

Naked Linux. Minimalistic Debian net install

Linux distribution: Debian Wheezy netinstall iso (~270mb)
Get it from here: https://www.debian.org/CD/netinst/

For VMWare installation the ISO can be used directly, for the desktop system a bootable USB needs to be created. Under OS X, this can be achieved by:

$ hdiutil convert -format UDRW -o ~/debian-*-netinst.img ~/debian-*-netinst.iso
$ diskutil list # check which device is the USB, my case disk2
$ sudo dd if=~/debian-*-netinst.img.dmg of=/dev/disk2 bs=1m
$ diskutil eject /dev/disk2


Some notes about the installation process:

Single partition encrypted Logical Volume Manager (LVM) was selected as the partition scheme. LVM will not be used right now but might be handy to have, specially if I want to switch to a more traditional partition scheme later (i.e. separate partitions for /home, /var, etc)

During the installation process, when presented with the option of "software selection" nothing was installed (unchecked everything). This means that everything will need to be installed later. Giving total control and assuring that only what will be used is installed on the system.

Gimme internet! Waking up the wireless card

To get the wireless card up and running we need to install wpa_supplicant. Usually this is installed by default on most distributions, however since the bare minimum was chosen during the installation, it won't be available. The usual apt-get will not work of course. The package can be downloaded from the Debian repositories:

https://packages.debian.org/wheezy/amd64/wpasupplicant/download

Note that "amd64" is valid for 64bit AMD and Intel systems as well. The package won't work on other architectures.

I copied the package to a USB stick and deploy it on the system like this:

$ ls /dev/sd* # find out the id for the USB device
$ mount -t vfat /dev/sdd1/ /mnt # use vfat if the USB has a FAT partition
$ dpkg -i wpasupplicant*.deb # install the package



Once wpa_supplicant is installed we can generate the configuration file. The SSID and WPA passphrase of the wireless network is needed, just run:

$ wpa_passphrase myrouter mypassphrase > /etc/wpa.conf
$ su - # switch to root account
$ wpa_supplicant -B -D[driver] -i[device] -c/etc/wpa.conf
$ dhclient -r # release DHCP leases (if any)
$ dhclient [device] # get a DHCP lease
$ exit # switch back to user account

To connect at boot, add these lines to /etc/network/interfaces

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant.conf


Some notes about the wpa_supplicant command:

[driver]: Check which are the available drivers by executing wpa_supplicant --help; "wext" driver is the most common one and should work on most cases.
[device]: The network device of your card is usually eth1 or wlan0, run iwconfig if unsure.
The -B parameter runs the command in the background giving back the console to the user.

Make me a SU please

Now that we can get packages from the online repositories, let's start by installing sudo:

$ su -
$ apt-get update # update list of available packages
$ apt-get install sudo # yes, not even sudo is installed!


I want to add my username to the sudo user group, so the file /etc/sudoers needs to be edited. The proper way to do that is to execute visudo instead of editing the file directly. Visudo checks for syntax errors before saving the file, so the scenario of being unable to gain super user privileges is avoided.

$ visudo
and add the line: username ALL(ALL:ALL) ALL


Now that my regular user account has SU privileges, I can switch back to my regular user account and add the non-free software and backports repositories. Debian is known for its very conservative approach to updating packages. Its release cycle is longer than most of the distros out there, many of the stable packages in Debian can be considered as old in other distributions. The advantage of this approach is stability. The backports repository provides a way to install more up to date (and less stable) packages:

$ exit -
$ sudo vi /etc/apt/sources.list
and add the lines:
deb http://http.debian.net/debian/ wheezy main non-free contrib
deb-src http://http.debian.net/debian/ wheezy main non-free contrib
deb http://http.debian.net/debian/ wheezy-backports main contrib non-free



Let's get a GUI: X-server and Awesome

To install X-server and Awesome window manager:

$ sudo apt-get install xorg awesome



I don't know much about Awesome window manager, so I will start by copyng an example awesome wm config file to my home directory:

$ mkdir -p ~/.config/awesome/
$ sudo cp /etc/xdg/awesome/rc.lua ~/.config/awesome/
$ sudo chown username ~/.config/awesome/rc.lua



I want X-server to start automatically on console login

$ vi ~/.bash_profile
and add the lines:
# startx automatically
if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty1 ]; then
startx
fi



I also want Awesome to start automatically:

$ vi ~/.xinitrc and add the lines:
# ~/.xinitrc
# This file is sourced when running startx and other programs which call xinit
# Start the window manager
exec awesome



At this point I can reboot and the X-server + Awesome should start automatically:

$ sudo shutdown -r now


The next step is very dependent on the video card. My desktop system has a GeForce GTX780. The following procedure will work for any NVIDIA card. To take full advantage of the video card, It's best to replace the noveau driver with the specific drivers for your video card. NVIDIA provides official drivers for Linux. If you wish to have the latest drivers then that would be the best choice. However a more conservative approach is to install the NVIDIA drivers provided by Debian (drivers are several release cycles behind though).

This information was copied directly from the Debian wiki site might be a good idea to check there for updated information before following these steps:

https://wiki.debian.org/NvidiaGraphicsDrivers#wheezy-backports

$ aptitude update
$ aptitude install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,')
$ aptitude -t wheezy-backports -r install nvidia-kernel-dkms


Since the NVIDIA driver is not autodetected by Xorg, a configuration file is required:

$ mkdir /etc/X11/xorg.conf.d
$ echo -e 'Section "Device"\n\tIdentifier "My GPU"\n\tDriver "nvidia"\nEndSection' > /etc/X11/xorg.conf.d/20-nvidia.conf




Comments

If you find these notes useful and/or run into trouble please leave a comment, your feedback might help others.

comments powered by Disqus