Skip to content
Snippets Groups Projects
arch-installation.md 5.22 KiB
Newer Older
Your Name's avatar
Your Name committed
---  
title: Arch Linux Installtion 
subtitle: My way to install Arch Linux  
date: 2021-12-04  
menu: "publications"
tags: ["linux", "arch"]
---
Your Name's avatar
Your Name committed

# Arch Installation

## Installation

### 1. Partion a disk
```
fdisk /dev/sda
d # Delete Partitions
p # List Partitions
n # Create Partitions
w # Execute changes
```
### 2. Make filesystems
```
mkfs.ext4 /dev/sda2
mkfs.fat -F32 /dev/sda1
```

### 3. Mount Partitions

```
mount /mnt /dev/sda2
mkdir /mnt/boot
mount /mnt/boot /dev/sda1
```

### 4. Connect a WiFi

- First, if you do not know your wireless device name, list all Wi-Fi devices:

```
[iwd]# device list
```

- Then, to scan for networks:

```
[iwd]# station device scan
```

- You can then list all available networks:

```
[iwd]# station device get-networks
```

- Finally, to connect to a network:

```
[iwd]# station device connect SSID
```

### 5. Install base 

```
pacstrape base base-devel linux linux-firmware vi networkmanager grub efibootmgr
```
### 6. Generate /etc/fstab file
```
genfstab -U /mnt >> /mnt/etc/fstab
```
### Chroot into new install

- Set timezone 
```
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
```
- Enable  synchronizing
```
timedatectl set-ntp true
```
- Autostart `NewworkManager`
``` 
systemctl enable NetworkManager
```

- Install GRUB to target partition
```
grub-install --target=x86_64-efi --efi-directory=/boot
```
- Generation GRUB configuration file
```
grub-mkconfig -o /boot/grub/grub.cfg
```
- Set the root password
```
passwd
```
- Add a new user
```
useradd -m username
```
- Set new user password
```
passwd username
```
- Add user to groups
```
usermod -aG wheel,audio,video,optical,storage username
```
- Add locale information
```
vim /etc/local.gen uncomment en_US
```
- Run locale generation
```
local-gen
```
- Add locale information
```
vim /etc/locale.conf add LANG=en-US.UTF
```

```
vim /etc/hostname
```

## First boot
- run `visudo`, uncomment `wheel` group to allow new user sudo permission

- enable ZRAM. 
  
    - Install `zram-generator` using one of the methods listed above.
    - Create a `zram-generator.conf` config file.
        ```
        # /etc/systemd/zram-generator.conf
        [zram0]
        zram-size = ram / 2

        A zram device will be created for each section. No actual configuration is necessary (the default of zram-size = min(ram / 2, 4096) will be used unless overriden), but the configuration file with at least one section must exist.
        Mount points

        # /etc/systemd/zram-generator.conf
        [zram1]
        mount-point = /var/tmp
        This will set up a /dev/zram1 with ext2 and generate a mount unit for /var/tmp.
        ```
    - Run `systemctl daemon-reload` to create new device units.
    - Run `systemctl start /dev/zram0` (adjust the name as appropriate to match the config).
    - Call `zramctl` or `swapon` to confirm that the device has been created and is in use.


- enable eriodic TRIM, The `util-linux` package provides `fstrim.service` and `fstrim.timer` systemd unit files. Enabling the timer will activate the service weekly

### 1. `NetworkManager` add new WiFi
- Adding a Wi-Fi Connection
  To view the available Wi-Fi access points, issue a command as follows:
```
  ~]$ nmcli dev wifi list
    SSID            MODE  CHAN  RATE     SIGNAL  BARS  SECURITY
    FedoraTest     Infra  11    54 MB/s  98      ▂▄▆█  WPA1
    Red Hat Guest  Infra  6     54 MB/s  97      ▂▄▆█  WPA2
    Red Hat        Infra  6     54 MB/s  77      ▂▄▆_  WPA2 802.1X
  * Red Hat        Infra  40    54 MB/s  66      ▂▄▆_  WPA2 802.1X
    VoIP           Infra  1     54 MB/s  32      ▂▄__  WEP
    MyCafe         Infra  11    54 MB/s  39      ▂▄__  WPA2
```
  - To create a Wi-Fi connection profile with static IP configuration, but allowing automatic DNS address assignment, issue a command as follows:
```
  ~]$ nmcli con add con-name MyCafe ifname wlan0 type wifi ssid MyCafe \
  ip4 192.168.100.101/24 gw4 192.168.100.1
```
  - To set a WPA2 password, for example “caffeine”, issue commands as follows:
```
  ~]$ nmcli con modify MyCafe wifi-sec.key-mgmt wpa-psk
  ~]$ nmcli con modify MyCafe wifi-sec.psk caffeine
```
  - To change Wi-Fi state, issue a command in the following format:
```
  ~]$ nmcli radio wifi [on | off ]
```
  #### Changing a Specific Property
  - To check a specific property, for example mtu, issue a command as follows:
```
  ~]$ nmcli connection show id 'MyCafe' | grep mtu
  802-11-wireless.mtu:                     auto
```
  - To change the property of a setting, issue a command as follows:
```
  ~]$ nmcli connection modify id 'MyCafe' 802-11-wireless.mtu 1350
```
  - To verify the change, issue a command as follows:
```
  ~]$ nmcli connection show id 'MyCafe' | grep mtu
  802-11-wireless.mtu:                     1350
```
  Note that NetworkManager refers to parameters such as 802-3-ethernet and 802-11-wireless as the setting, and mtu as a property of the setting. See the nm-settings(5) man page for more information on properties and their settings. 

Network: https://docs.fedoraproject.org/en-US/Fedora/25/html/Networking_Guide/sec-Connecting_to_a_Network_Using_nmcli.html
ZRAM: https://github.com/systemd/zram-generator
Periodic TRIM: https://wiki.archlinux.org/title/Solid_state_drive#Periodic_TRIM