EvilZone

Hacking and Security => Tutorials => : Rytiou December 12, 2013, 02:35:18 AM

: Arch Linux Install Guide (Aug. 2014)
: Rytiou December 12, 2013, 02:35:18 AM
Alright so it's been nearly a whole year since I've created this thread I decided to give it some justice and revamp it to the best of my abilities while taking in to consideration everyone's replies they've made. Here's how how I'm going to lay out this thread:
Base Install
Upgrade System | Configure keymap | Configure mirrorlist | Create partitions | Format device | Install system base | Configure fstab | Configure Mkinitcpio | Configure hostname | Configure timezone | Configure hardware clock | Configure locale | Install/Configure bootloader | Make a user account | Final Stuff
Post Install
Basic Setup | Desktop Environment / Window Manager | Closing Thoughts

Hopefully this is layed out well enough for anyone to follow. Some of you who have done this before may or may not think this a weird layout for an Arch Linux install but this has worked out for me without any difficulty so far. I hope this well help anyone out who's interested in  Arch but can't seem to get it up and running. If anything in here doesn't work out for you please let me know and I will try to assist you to the best of my abilities. Also, if you're not up to installing this on actual hardware, which is understandable, I would download and put this on Virtualbox as it's a great free VM software. Now, without further ado, let's get this tutorial going.

Upgrade System
Before you actually get started with anything I'd recommend you upgrading your system so that you can get all the necessary things and not run into problems down the line. If this isn't working because you're on wireless here (https://wiki.archlinux.org/index.php/beginners%27_guide#Wireless) is the Arch Wiki post about setting up your wireless. I would tell you how to do it here but I have no experience in doing so.
After you're sure your internet is working you can finally run the command below
:
pacman -Syu
Configure Keymap
Now we are going to setup our keymap so that we'll be able to use our appropriate layout. A list of the layouts you can use are usually stored in /usr/share/kbd/keymaps/ Replace us with whatever layout you decide to use.
:
loadkeys us
Configure Mirrorlist
Now we are going to configure our mirrors. This is so that you can pick mirrors that are in your country or close to it so you can download packages a bit faster. If you're having trouble with your mirrors later down the road you may need to generate a new one. Click here (https://www.youtube.com/watch?v=jbCi9plLczY) to find out how to do that.
:
nano /etc/pacman.d/mirrorlist
uncomment a few that are in or near your country by remove the #'s in front of whatever mirror you choose to use

Create Partitions
Next we are going to make our partitions. You can make this as simple or complex as you want it to be. I'll show you both a scheme with just a home and swap partition and a scheme with a root, usr, home, boot, var, and swap partitions. Choose whichever you prefer. Also, wherever you see a +G put the amount in Gigabytes you would like to use right between the + and G.
:
fdisk

2 partitions
---------------
/home - Press n, then n, then p, 1, 2048, +G, then press a
/swap Press n, then p, 2, ENTER, ENTER, t, 2, type 82

5 partitions
---------------
/boot - Press n, then p, 1 2048, +200M, then press a
/ - Press n, then p, 2, ENTER, +G (Usually want this to be around 15 GB - 20 GB),
/var - Press n, then p, 3, ENTER, +G (Usually want this to be around (8 GB - 12 GB)
/home - Press n, then p, 4, ENTER, +G (Varies. This is where most of your HDD space is. IMO I would leave enough space that's about twice the amount of ram you have if you can spare it)
/swap - Press n, then p, 5, ENTER, ENTER, t, 5, type 82
Verify your partition scheme is right by hitting p. If everything is good then hit w to write and exit.
Format Device
Once the above is done you are going to want to format the partitions Arch Linux is going to be install too and set the filesystem it's going to use. In this tutorial we are going to use ext4 as it's one of the most common filesystems used in linux. Replace partition with the order your partition scheme is. If it's your main hard drive it'll be /dev/sda1 /dev/sda2 etc
:
mkfs.ext4 /dev/partition
mkswap /dev/partiton (this is wherever your swap partition is)
swapon /dev/partition (same as above)

Install System Base
Now that we got that all out of the way we can finally proceed to installing to base system. But before we do we must mount the necessary partitions.
:
First, mount the root partition on /mnt Mine happens to be /dev/sda1 but yours maybe different so replace it to whatever it is.
mount /dev/sda1 /mnt

Next mount the home partition and any other separate partition (/boot, /var, etc), if you have any
mkdir /mnt/home
Finally, enter the following command
:
pacstrap -i /mnt base base-devel
Configure fstab
Next we are going to generate an fstab which is a file that typically lists all available disks and disk partitions. Just run the following command and you should be good to go.
:
genfstab -U -p /mnt >> /mnt/etc/fstab
Configure Mkinitcpio
Now we have to configure Mkinitcpio so our kernel can load.
:
mount /dev/sda1 /mnt
arch-chroot /mnt /bin/bash
mkinitcpio -p linux
Configure Hostname
This part is completely optional except for the first command. This is the name that follows the @ in your terminal to help distinguish your machines. If you would like to change your host name type in this command
:
hostnamectl set-hostname myhostname
Configure Timezone
Now we are going to set our timezone. Please note that your location may not be on the list. If that is the case just pick the location closest to you.
:
ls /usr/share/zoneinfo/
ls /usr/share/zoneinfo/countryhere
ln -s /usr/share/zoneinfo/Country/ClosestPlace /etc/localtime

Incase you get a symbolic link error from the last command
ln -sf /usr/share/zoneinfo/Country/ClosestPlace /etc/localtime
Configure Hardware Clock
Next you're going to want to configure your hardware clock. This is so that if you ever dual boot and what not all your clocks will stay the same and not cause your time to shift.
:
hwclock --systohc --utc
Configure Locale
This next part is so that you can set what language locale your system is. You're going to want to uncomment whatever locale you are. For me, it's en_US
:
nano /etc/locale.gen
Uncomment the two things that have your locale listed.
local-gen
Next thing to do is to create your locale.conf file. Just substitute the locale listed below for whatever locale you chose.
:
echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8
Install / Configure Bootloader
We're almost done. Now we have to install a bootloader so that our system that our system can actually boot up. I'm going to use grub as it's one of the most popular and well supported bootloaders.
:
pacman -S grub
grub-install --target=i386-pc --recheck /dev/sda
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo (Replace en for whatever language you chose)
grub-mkconfig -o /boot/grub/grub.cfg
Make a User Account
Finally, we are going to create a user account since you don't want to run your system as root all the time. Just enter the following commands and you should be set.
:
pacman-S sudo
useradd -m -g users -G wheel,storage,power -s /bin/bash USERNAMEHERE
passwd USERNAMEHERE

Now set a password for the root user
passwd
Now in order to run root commands as a user you are going to have to do a few things.
:
EDITOR=nano visudo
Scroll down and uncomment "%wheel all=all"
Final Stuff
Before we reboot into our new system I thought I'd show you a few useful things. First off if you want your internet to automatically run type in the following commands.
:
systemctl enable dhcpcd@eth0.service
pacman -S wireless_tools wpa_supplicant wpa_actiond dialog
Also, I forgot to tell you to do this if you're on a 64 bit installation
:
nano /etc/pacman.conf
Scroll down until you multilib. Underneath it should be line starting with the word "including". Remove the # that's in front of it.
That's about it now. Just type in the next few commands and reboot your pc without the installation media inserted.
:
exit
umount /mnt
reboot
Basic Setup
Congratulations! You successfully installed Arch Linux. Now all you have to do is setup sound, install a Desktop / Window Environment, install video drivers, and enable network manager

Sound setup
:
pacman -S alsa-utils
enter the command - alsamixer
crank each volume bar until you see a gain of 0
Video Drivers
:
Check which video card you have - lspci -k | grep -A 2 -i "VGA"
(People who have Intel) sudo pacman -S xf86-video-intel
(People who have AMD) sudo pacman -S xf86-video-ati
(People who have NVIDIA) sudo pacman -S nvidia
(People who are in a VM) sudo pacman -S virtualbox-guest-utils
Dekstop Environment / Windows manager
Now all we have to do really is install a DE / WM + enable network manager and you should be all done and good to go.
I'm going to be installing XFCE4 but you can install anything you like. Just look at the respective Arch Wiki page. First off for any DE you are going to want to enter this command.
:
sudo pacman -S xorg-server xorg-xinit xorg-server-utils mesa ttf-dejavu samba smbclient networkmanager networkmanager-vpnc networkmanager-pptp networkmanager-openconnect gvfs-smb sshfs
Now you are going to want to enable Network Manager and reboot.
:
sudo systemctl enable NetworkManager Once you boot back up and login you are finally going to install your DE / WM of choice. This is the command to install XFCE
:
sudo pacman -S xfce4 xfce4-goodiesNow you are going to want to enable your DE / WM so you can use the startx command to start it.
:
cp /etc/skel/.xinitrc ~
nano .xinitrc
Uncomment / Instert whatever DE / WM you've installed. Usually the command to start it will be on the respective page on the Arch wiki.
startx
Closing Thoughts
Now you're officially done with Installing Arch Linux. Congratulations if you made it all the way to the end. If you were new to this I hope you learnt a lot along the way. Now you don't have much installed really but you'll get past that soon. If you want a list of some applications then look here (https://wiki.archlinux.org/index.php/List_of_applications) for a good list of some. Now all that's left for you to do is to use your system and break stuff / fix it / repeat. Thanks for reading my tutorial and I hope I helped anyone who reads this out in one way or another :).
: Re: Arch Linux Install Guide (Dec. 2013)
: proxx December 12, 2013, 07:58:54 AM
Thanks for sharing :)

Uhm but one partition ?
I would highly recommend splitting  /usr /home /boot  and /
1 Gb of swap is not really enough for suspend to RAM and similar.
Im not using any swap at all but be careful it is easy to corrupt databases when you have too little swap space, or in other words , I wouldnt recoomend it for productions systems.
: Re: Arch Linux Install Guide (Dec. 2013)
: lucid December 12, 2013, 08:50:50 AM
Yeah technically it's recommended to use at least twice as much swap space as RAM. I'm like proxx and use no swap however. Also, I thank you for contributing but this guide is a little lacking in detail and any complete noob to installing Arch would probably have difficulty following this. I mean, there's probably no other documentation that one needs when one has the ever comprehensive Arch wiki.

Still, at least you are making an effort to contribute.
: Re: Arch Linux Install Guide (Dec. 2013)
: techb December 12, 2013, 09:11:50 AM
I also agree with the above.

I would also add, this in an ethernet only install. I had to do it several times with wireless. And a desktop is optional, you could use just a window manager which is what I recommend. I don't use a swap either.
: Re: Arch Linux Install Guide (Dec. 2013)
: Snayler December 12, 2013, 02:25:43 PM
You forgot to insert a link in the "Introduction" chapter.

If you need to download VM software look here.
Anyway, good contribution.
: Re: Arch Linux Install Guide (Dec. 2013)
: Heisenburg December 24, 2013, 01:11:37 PM
 :o  erm, that codes.
I think Archlinux's wiki and community already have a good environment for beginner to deal with it.

Anyway, good try :)
: Re: Arch Linux Install Guide (Dec. 2013)
: Kulverstukas December 24, 2013, 01:56:43 PM
Nice effort! :) nice looking and straight guide. But you should really surround the commands with code tags.
: Re: Arch Linux Install Guide (Dec. 2013)
: jacobopus August 21, 2014, 07:55:36 PM
Thanks for the tutorial.
 
I'm trying to follow it and I found this:

:
genfstab -U -p >> /mnt/etc
ERROR : no root directory specified.

After a little research i could do it:

:
genfstab -U -p /mnt/home >> /mnt/home/etc/fstab

This because /mnt/home was the mount point specified in the first step of the guide and genfstab need to know where /root/ is.

I know this post is old, and you guys do not need it, but maybe this clarification will help other noobs.
: Re: Arch Linux Install Guide (Dec. 2013)
: Kulverstukas August 21, 2014, 08:19:48 PM
It's OK to necro a thread if you have something valuable to add :)
: Re: Arch Linux Install Guide (Dec. 2013)
: voodoo August 26, 2014, 07:21:21 AM
:
https://wiki.archlinux.org/index.php/beginners'_guide
: Re: Arch Linux Install Guide (Dec. 2013)
: Rytiou August 26, 2014, 12:19:34 PM
Thanks for the tutorial.
 
I'm trying to follow it and I found this:

:
genfstab -U -p >> /mnt/etc
ERROR : no root directory specified.

After a little research i could do it:

:
genfstab -U -p /mnt/home >> /mnt/home/etc/fstab

This because /mnt/home was the mount point specified in the first step of the guide and genfstab need to know where /root/ is.

I know this post is old, and you guys do not need it, but maybe this clarification will help other noobs.
Interesting, thanks for letting me know. The command most likely have changed since I made this thread. I might get around to updating this thread since I haven't really done anything with it in the past year. Also, +1 for the info and letting me know people are still interested in this thread.
: Re: Arch Linux Install Guide (Dec. 2013)
: voodoo August 26, 2014, 04:22:21 PM
the correct way to initially generate the fstab file is.
:
genfstab -U -p /mnt >> /mnt/etc/fstab
the following
:
genfstab -U -p >> /mnt/etc/fstabshouldn't do anything as you are not giving it the path to the mounted partitions.
However, if genfstab defaults a path to /mnt I could be wrong.
: Re: Arch Linux Install Guide (Dec. 2013)
: proxx August 26, 2014, 05:48:25 PM
Genfstab source.
:
#!/bin/bash

shopt -s extglob

m4_include(common)

write_source() {
  local src=$1 spec= label= uuid= comment=()

  label=$(lsblk -rno LABEL "$1" 2>/dev/null)
  uuid=$(lsblk -rno UUID "$1" 2>/dev/null)

  # bind mounts do not have a UUID!

  case $bytag in
    '')
      [[ $uuid ]] && comment=("UUID=$uuid")
      [[ $label ]] && comment+=("LABEL=$(mangle "$label")")
      ;;
    LABEL)
      spec=$label
      [[ $uuid ]] && comment=("$src" "UUID=$uuid")
      ;;
    UUID)
      spec=$uuid
      comment=("$src")
      [[ $label ]] && comment+=("LABEL=$(mangle "$label")")
      ;;
    *)
      [[ $uuid ]] && comment=("$1" "UUID=$uuid")
      [[ $label ]] && comment+=("LABEL=$(mangle "$label")")
      [[ $bytag ]] && spec=$(lsblk -rno "$bytag" "$1" 2>/dev/null)
      ;;
  esac

  [[ $comment ]] && printf '# %s\n' "${comment[*]}"

  if [[ $spec ]]; then
    printf '%-20s' "$bytag=$(mangle "$spec")"
  else
    printf '%-20s' "$(mangle "$src")"
  fi
}

optstring_apply_quirks() {
  local varname=$1 fstype=$2

  case $fstype in
    f2fs)
      # These are Kconfig options for f2fs. Kernels supporting the options will
      # only provide the negative versions of these (e.g. noacl), and vice versa
      # for kernels without support.
      optstring_remove_option "$varname" noacl,acl,nouser_xattr,user_xattr
      ;;
    vfat)
      # Before Linux v3.8, "cp" is prepended to the value of the codepage.
      if optstring_get_option "$varname" codepage && [[ $codepage = cp* ]]; then
        optstring_remove_option "$varname" codepage
        optstring_append_option "$varname" "codepage=${codepage#cp}"
      fi
      ;;
  esac
}

usage() {
  cat <<EOF
usage: ${0##*/} [options] root

  Options:
    -L             Use labels for source identifiers (shortcut for -t LABEL)
    -p             Avoid printing pseudofs mounts
    -t TAG         Use TAG for source identifiers
    -U             Use UUIDs for source identifiers (shortcut for -t UUID)

    -h             Print this help message

genfstab generates output suitable for addition to an fstab file based on the
devices mounted under the mountpoint specified by the given root.

EOF
}

if [[ -z $1 || $1 = @(-h|--help) ]]; then
  usage
  exit $(( $# ? 0 : 1 ))
fi

while getopts ':Lpt:U' flag; do
  case $flag in
    L)
      bytag=LABEL
      ;;
    U)
      bytag=UUID
      ;;
    p)
      nopseudofs=1
      ;;
    t)
      bytag=${OPTARG^^}
      ;;
    :)
      die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG"
      ;;
    ?)
      die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG"
      ;;
  esac
done
shift $(( OPTIND - 1 ))

(( $# )) || die "No root directory specified"
root=$1; shift

if ! mountpoint -q "$root"; then
  die "$root is not a mountpoint"
fi

# handle block devices
findmnt -Recvruno SOURCE,TARGET,FSTYPE,OPTIONS,FSROOT "$root" |
    while read -r src target fstype opts fsroot; do
  if (( nopseudofs )) && fstype_is_pseudofs "$fstype"; then
    continue
  fi

  # default 5th and 6th columns
  dump=0 pass=2

  src=$(unmangle "$src")
  target=$(unmangle "$target")
  target=${target#$root}

  if (( !foundroot )) && findmnt "$src" "$root" >/dev/null; then
    # this is root. we can't possibly have more than one...
    pass=1 foundroot=1
  fi

  # if there's no fsck tool available, then only pass=0 makes sense.
  if ! fstype_has_fsck "$fstype"; then
    pass=0
  fi

  if [[ $fsroot != / ]]; then
    if [[ $fstype = btrfs ]]; then
      opts+=,subvol=${fsroot#/}
    else
      # it's a bind mount
      src=$(findmnt -funcevo TARGET "$src")$fsroot
      if [[ $src -ef $target ]]; then
        # hrmm, this is weird. we're probably looking at a file or directory
        # that was bound into a chroot from the host machine. Ignore it,
        # because this won't actually be a valid mount. Worst case, the user
        # just re-adds it.
        continue
      fi
      fstype=none
      opts+=,bind
      pass=0
    fi
  fi

  # filesystem quirks
  case $fstype in
    fuseblk)
      # well-behaved FUSE filesystems will report themselves as fuse.$fstype.
      # this is probably NTFS-3g, but let's just make sure.
      if ! newtype=$(lsblk -no FSTYPE "$src") || [[ -z $newtype ]]; then
        # avoid blanking out fstype, leading to an invalid fstab
        error 'Failed to derive real filesystem type for FUSE device on %s' "$target"
      else
        fstype=$newtype
      fi
      ;;
  esac

  optstring_apply_quirks "opts" "$fstype"

  # write one line
  write_source "$src"
  printf '\t%-10s' "/$(mangle "${target#/}")" "$fstype" "$opts"
  printf '\t%s %s' "$dump" "$pass"
  printf '\n\n'
done

# handle swaps devices
{
  # ignore header
  read

  while read -r device type _ _ prio; do
    options=defaults
    if [[ $prio != -1 ]]; then
      options+=,pri=$prio
    fi

    # skip files marked deleted by the kernel
    [[ $device = *'\040(deleted)' ]] && continue

    if [[ $type = file ]]; then
      printf '%-20s' "$device"
    elif [[ $device = /dev/dm-+([0-9]) ]]; then
      # device mapper doesn't allow characters we need to worry
      # about being mangled, and it does the escaping of dashes
      # for us in sysfs.
      write_source "$(dm_name_for_devnode "$device")"
    else
      write_source "$(unmangle "$device")"
    fi

    printf '\t%-10s\t%-10s\t%-10s\t0 0\n\n' 'none' 'swap' "$options"
  done
} </proc/swaps

# vim: et ts=2 sw=2 ft=sh:

: Re: Arch Linux Install Guide (Aug. 2014)
: Rytiou August 27, 2014, 04:30:14 AM
Alright so I actually went back and spent a few hours revamping this entire thread. Hopefully this is better than last time and if I missed anything or if I didn't do something right please let me know since I'm always open to feedback. Hope this contribution helps a few people out who want to become fellow Archers.
: Re: Arch Linux Install Guide (Aug. 2014)
: proxx August 27, 2014, 08:17:33 AM
Real man write their own fstab files :P
Thanks for the effort dude fellow archer.
: Re: Arch Linux Install Guide (Aug. 2014)
: Rytiou August 27, 2014, 12:06:18 PM
Real man write their own fstab files :P
Thanks for the effort dude fellow archer.
I've never really understood how you would right your own fstab file as it was always beyond me.
: Re: Arch Linux Install Guide (Aug. 2014)
: shad0wingfir3 September 07, 2014, 06:03:47 PM
Thanks for the nice looking tutorial, it helped me flesh out a few ideas for my post install! I always have trouble customizing Arch whenever I install it. Guess I am just jealous of other people's pretty desktops.
: Re: Arch Linux Install Guide (Aug. 2014)
: apexcr3d September 17, 2014, 06:34:31 AM
Thanks for this guide as wll... I started to do an "archAssault" install on vbox... and it didn't work out.  I am going to do vanilla Arch then add blackarch as a repo maybe.


But one question... nearly 50GB for this install??? 50GB isn't really that high if you have gnome 3 fully customized with 15 shell extensions.... or some other huge DE, but I hope I can get away with installing this in vbox for about 20GB as a trial...


But thanks for your step-by-step!!
: Re: Arch Linux Install Guide (Aug. 2014)
: proxx September 17, 2014, 08:51:17 AM
Thanks for this guide as wll... I started to do an "archAssault" install on vbox... and it didn't work out.  I am going to do vanilla Arch then add blackarch as a repo maybe.


But one question... nearly 50GB for this install??? 50GB isn't really that high if you have gnome 3 fully customized with 15 shell extensions.... or some other huge DE, but I hope I can get away with installing this in vbox for about 20GB as a trial...


But thanks for your step-by-step!!

You can install arch on a 4gig partition if you want , just dont drag in too many packages.
: Re: Arch Linux Install Guide (Aug. 2014)
: Zobrist January 12, 2015, 05:45:07 PM
Thanks for the tutorial. The information that you have provided us is highly valuable to every newbie who wants to install Arch Linux.
: Re: Arch Linux Install Guide (Aug. 2014)
: Syntax990 January 12, 2015, 05:48:28 PM
Would have been nice if I saw this a while ago, since I was looking for a good guide. Anyway, well done man! It's clearly laid out and describes everything you need to get it up and running!

+2 Cookies!
: Re: Arch Linux Install Guide (Aug. 2014)
: Intel January 15, 2015, 08:03:12 PM
You missed the "pacman -S os-prober" command if people want to install Arch with Windows Dual-booted.


However, not sure if os-prober is fully functional with Windows 8 and above.. It's been a while since I used Arch so if someone could post an update on that, it might help more users.