Last active
June 22, 2017 10:47
-
-
Save Namibnat/0e604cd2ff406329a7f02d9c65b40a53 to your computer and use it in GitHub Desktop.
A Rough Guide To Arch Linux Setup [for mostly Django with Apache and Postgresql]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First - a warning - If you follow step by step what I describe below, you'll kill whatever was on your machine. | |
I don't write 'this will wipe your disk' in the details below - I'll assume you're using a machine you can | |
mess around with and wipe out the disk without pain and anguish. It might blow up your box - if it does, be sure to | |
post to youtube...but don't blame me. I also don't describe anything like duel-boot...this is assuming you want | |
your whole machine to be linux to the bone. | |
There's something really appealing about building and Arch Linux box. Though I've build up an arch system many | |
times over the last few year, I still follow the 'beginner's guide', and probably will for some time to come. | |
https://wiki.archlinux.org/index.php/Beginners'_guide | |
I think that Arch Linux is really the crux of what Linux should be - you build your box, just the way you want it. | |
You can have a full-on desktop environment if you want, or you can leave out the x11 desktop kind of stuff and just have | |
the raw commandline. | |
I'm not really a hard-core hacker or commandline purist, but I work all day long on a Window 10 machine at work - I don't | |
even know anything about the machine specks, I just...work. On that machine I bang out emails and, I hope, I create awesome | |
Namibian holidays for many people. My job is challenging, but awesome. The machines we work on, well, they suck! | |
At home I have a Macbook Pro, which is a wonderful machine - It's what I use to browse the web, type stuff like this, | |
edit images and to look at my websites. So, since I have these two machines that I spend a lot of time on, | |
I want my Linux box to represent a different side of me. | |
So, instead of having a desktop environment which I really don't need since I've got that in my other machines, | |
I use Tmux & Vim largely as my desktop environment. Otherwise, it's all commandline, hacker style. And it | |
brings me much joy. I really love Arch Linux, since, despite the fact that my 'command-line, hackerish' machine | |
looks like a throw-back to 1970's Unix, it really is at the very cutting edge of modern computing - linux | |
can move faster than commercial organizations, and Arch is the distro that sits right at the dangerous | |
sharp edge! | |
I spend around 2-3 hours every week day, and as much of the weekend as I can get away with learning hacking skills on | |
my linux box. | |
Every once in a while I think the machine is just getting to full of crap, and then I wipe the disk and re-install | |
Arch and some basics..and feel really good. The wonderful advantage of git is that you can just push your changes | |
to a repo off the machine, and know that when you come back to the new install you just need to run a few git commands | |
to get everything back to what you need. | |
The below is simply my own notes for setting up a new box - I don't | |
think it will be that helpful for anyone but me - I see it as notes to myself - but perhaps you may just see | |
some little thing that helps you with a setup you were trying to get right. | |
Since this follows the "Beginners' guide" of Arch setup, I'm not going to spell out everything, but rather encourage anyone | |
who finds this of interest to follow that wiki page together with my actual set-up. | |
This is how I set up a Linovo super cheap laptop with Arch. It has a modern UEFI motherboard, which I still find somewhat | |
confusing, but setting it up is easy. | |
The whole machine is somewhat "hacker'ish" as, when I first set it up it was so slow | |
I though I'd add some RAM, and ended up cracking the keyboard opening it up - so the keyboard doens't work. So I | |
work with a towel over the machine, with a plugged in keyboard sitting on top of the laptop... | |
Okay, roughly step-by-step here is how I set up my box: | |
Interwebs | |
I just use wifi, and wifi-menu is so easy to follow, no need for much explanation. I see my wifi driver is wlp4s0, | |
rather than wlp2s0 as the wiki describes. | |
# wifi-menu -o wlp4s0 | |
Then just follow the ncurses stuff to get wifi set up. | |
System clock | |
# timedatectl set-ntp true | |
Partition (chop up your disk into the bits you need): | |
parted /dev/sda | |
(of course, your disk might not be sda...) | |
(parted) mktabel gpt | |
(parted) mklabel gpt | |
(I really don't know if I need to do both mktabel and mklabel...?) | |
(parted) mkpart ESP fat32 1MiB 513MiB | |
(parted) set 1 boot on | |
(parted) mkpart primary ext4 513MiB 98% | |
(parted) mkpart primary linux-swap 98% 100% | |
** I don't really give to much thought to the whole 'swap' portion, but since I end up using so little | |
of the hard drive anyway, I just give a nice chunck to swap anyway. | |
(parted) quit | |
lsblk | |
(lsblk just shows you how your disks look) | |
Now the disk is divided into the bits we need, they need need to be told what they are: | |
mkfs.ext4 /dev/sda2 | |
(so, /dev/sda2 is our main chunk) | |
mkswap /dev/sda3 | |
swakon /dev/sda3 | |
mkfs.fat -F32 /dev/sda1 | |
(/dev/sda1 is the efi boot bit) | |
# In order to chroot into our new machine, we need to mount the bits we've setup above: | |
mount /dev/sda2 /mnt | |
mkdir /mnt/boot | |
mount /dev/sda1 /mnt/boot | |
Select mirrors by editing: | |
/etc/pacman.d/mirrorlist | |
Of course, you need to edit with nano - which is painful if you usually work with vim, | |
but even without knowing anyting about Nano, you'll get the job done. | |
# pacstrap -i /mnt base base-devel | |
(I also do vim, but it isn't perfect, complains about LANG and stuff. But I just hate doing config with nano...so I force it) | |
# genftstab -U /mnt >> /mnt/etc/fstab | |
(check /mnt/etc/fstab afterwards to make sure it did the right thing. It's fairly obvious when things look wrong.) | |
Chroot (where the fun starts - work in your new machine): | |
arch-chroot /mnt /bin/bash | |
Uncomment en_US.UTF-8 UTF-8 in /etc/locale.gen | |
(I go for US settings because I grew up with expats in east Africa, and still spell American...it might be bad for my brain..) | |
then: | |
# locale-gen | |
# echo "LANG=en_US.UTF-8" > /etc/locale.conf | |
(I feel like I get nerd extra credit when I write files with echo...) | |
Select timezone | |
# tzselect | |
# ln -s /usr/share/zoneinfo/Africa/Windhoek /etc/localtime | |
I'm in Windhoek...I would guess that I'm the only arch hacker in town???? | |
# hwclock --systohc --utc | |
# bootctl path=/boot/ESP install | |
I've only recently started to give up on grub for a bootloader. I don't know anything | |
about bootctl, but I don't want to know about my bootloader - I want it to do it's thing and | |
get me into my log-in prompt as quickly as possible. | |
vim esp/loader/loader.conf | |
default arch | |
timeout 4 | |
(I change timeout to 0 after the first couple boots, when I know it does the right thing) | |
editor 0 | |
# pacman -S intel-ucode | |
# blkid -s PARTUUID -o value /dev/sda2 >> /boot/entries/arch.conf | |
# vim /boot/loader/entries/arch.conf | |
(I had some trouble here, and I think that the idea is that the conf file must be called the same | |
as the "default" in the loader.conf above?) | |
title Arch Linux | |
linux /vmlinuz-linux | |
initrd /intel-ucode.img ## don't know if we need this | |
initrd /initrfamfs-linux.img | |
options root=partuuid=.....all the nums from blkid command... rw | |
(most of this is just black magic to me...I just bang the stuff until I get the box to boot) | |
# echo "espresso" > /etc/hostname | |
(you can't set up your machine with some lame hostname...I often go with 'ice' or 'Spheniscidae', or | |
something that has to do with penguins. Last year I read 'south' and so I think going forward I might | |
look into antartic exploration for more machine names...I like the tux theme of Linux - my | |
interestes since childhood included a fairly deep interest in ornithology and exploration...Shackleton, | |
Endurance, stuff like that. But, alas, I also like coffee, and it also has some connection to hacking, | |
so espresso is the name of my newest machine. Maybe 'how to name your linux machine' should be a blog | |
topic soon?) | |
Then append your hostname to the items in /etc/hosts | |
# pacman -S iw wpa_supplicant dialog | |
(this is all stuff to get wifi-menu working, if you want to keep using it) | |
# passwd | |
(obvious) | |
# exit | |
(go out of your chroot, and hope that all went well!!! I often end up back here a couple times before | |
my machine is working right). | |
# umount -R /mnt | |
(do things the right way...) | |
Now, boot into your machine and let the game begin: | |
# pacman -Syu | |
(if you're new to arch, this gets your system up to date. do a man pacman if you're new to arch) | |
# pacman -S vim tmux | |
# pacman -S python | |
(Arch has been setting you up with python3.x for some time...Did I say that I love Arch!!!) | |
# pacman -S git | |
# pacman -S python-pip | |
# pacman -S openssh | |
# pacman -S apache | |
(For someone who uses the bleeding edge distro you might be amazed that I still use apache, but I | |
think Apache has done a lot to stay relevant, and it's stood the test of time in the changing | |
environment of the world wide web - and learned a lot from it's very hard battles.) | |
# pacman -S postgresql | |
(database - a really good one at that) | |
# pacman -S mod_wsgi | |
(server python stuff with apache) | |
# useradd -m -s /bin/bash vernon | |
(set up a user with a /home/username) | |
# visudo (add vernon ALL=...) | |
(you probably know visudo...add the user created above to the sudoers file) | |
# passwd vernon | |
# su vernon | |
$ mkdir conf | |
(all my dot-files are in conf, then I just create symlinks from the various | |
dot files. I don't know if this is the normal way of doing it, but it works | |
and it means that I can keep a basic set of dotfile settings under conf that | |
I can use accross various machines. Even on my Macbook I use very similar | |
dotfiles to what I do in Linux.) | |
$ mkdir docs | |
(this is mainly notes and some personal stuff) | |
$ mkdir code | |
(Mostly this is either django projects, with individual apps, or separate git repos. | |
I use git even for stuff I don't share at all.) | |
$ git config --global user.email "vernon@..." | |
$ git config --global user.name "Vernon..." | |
$ git config --global core.editor "vim" | |
(we don't feel okay without Vim) | |
Now I get my regular stuff from a usb flash driver: | |
Mount usb, copy dotfiles: | |
$ cp dotfiles to conf, and make simlinks | |
$ cp -r /mnt/instructions docs | |
$ sudo umount /mnt | |
$ mkdir .backups | |
(now, as we start to mess around with basic config, I start | |
to save some back-ups of files that I'm messing with that | |
I frequently get messed up...like httpd conf.) | |
$ cp /etc/httpd/conf/httpd.conf .backups/ | |
Now I'm ready to set up apache and postgresql for a new Django project, virtualenv, and so on.... | |
basically this is my set-up complete. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment