User:Tachy

From ArchWiki
Jump to navigation Jump to search

Bio

Name
Helge Willum Larsen
Location
Aalborg, Denmark
Gender
♂ Male
Age
expr \( `date +%s` - 539132400 \) / 31536952


Copy-Pasta

Here's some "inspiration"

Dual-boot Windows 7 and Arch Linux (x64 UEFI) on my Dell E7440

Storage setup

  • Disk partitions (GPT disk label; print using sgdisk -p /dev/sda):
    1. 100.0 MiB EF00 EFI System
    2. 128.0 MiB 0C01 Microsoft reserved partition
    3. 97.4 GiB 0700 Basic data partition
    4. 20.0 GiB 8E00 Linux LVM
    5. 20.0 GiB 8E00 Linux LVM
    6. 20.0 GiB 8E00 Linux LVM
    7. 20.0 GiB 8E00 Linux LVM
    8. 20.0 GiB 8E00 Linux LVM
    9. 20.0 GiB 8E00 Linux LVM
    10. 20.0 GiB 8E00 Linux LVM
    11. 837.3 MiB 8300 Linux filesystem
  • Filesystems, LVM etc.
    • /dev/sda1
      • FAT32
      • /boot/efi
    • /dev/sda3
      • NTFS
      • Windows 7 (C:)
    • /dev/sda4-10
      • LVM VG raw
      • /dev/mapper/raw-luks
        • LUKS volume (dm-crypt)
        • /dev/mapper/raw-luks_crypt
          • LVM VG luks
          • /dev/mapper/luks-btrfs
            • Btrfs
            • /
    • /dev/sda11
      • EXT4
      • /boot


# vim: set ft=sh:
echo "YOU SHOULD NOT RUN THIS FILE!!!"
exit 1

################################################################################
# HARDWARE
################################################################################
fold -s <<-_EOF_
	Dell Latitude E7440
	BIOS: A11
	Service Tag: GYDGN12
	
	Bluetooth: Intel Wireless Bluetooth 4.0
	Storage: SAMSUNG SSD PM851 mSATA (firmware: EXT4AD0Q)
	Audio: Realtek ALC3226
	Card reader: BayHubTech/O2Micro Integrated MMC/SD controller
	Touchpad: Dell Touchpad [ACPI/DLL05CB]
	Network (LAN): Intel Ethernet Connection I218-LM
	Network (WLAN): Intel Dual Band Wireless-AC 7260
	Network (3G/Modem): Dell Wireless 5570 HSPA+ (42Mbps)
	VGA: Intel HD Graphics
	USB: Intel 8 Series USB Enhanced Host Controller
	USB (wireless): Sierra Wireless USB
	Misc: Integrated webcam, Intel WiUSB
	
	Boot-up shortcut keys:
	BIOS: F2
	Boot Menu: F12
	
	BIOS SETTINGS:
	* General
	** Boot Sequence
	*** Disable "Diskette Drive" and "Onboard NIC"
	*** Change "Boot List Option" to UEFI
	* System Configuration
	** Integrated NIC
	*** Enabled w/PXE -> Enabled
	
	Windows drivers (download from Linux):
	http://en.community.dell.com/techcenter/enterprise-client/w/wiki/4952.latitude-e7440-windows-7-driver-cab

	Intel 7260 WiFi Driver (2014-08-18):
	http://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverId=W975H
	
	Windows drivers (download from Windows):
	http://www.dell.com/support/home/us/en/04/product-support/servicetag/GYDN12/drivers
	
	Realtek combined High-Definition Audio Driver (2014-11-19):
	http://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverid=Y8V8V
_EOF_


################################################################################
# INSTALLATION (dual-boot Windows 7 and Arch Linux in UEFI mode)
################################################################################
# Ensure BIOS boots in UEFI mode
# Boot archiso and
loadkeys dk
# Backup /dev/sda MBR, /dev/sda1 (Dell) and /dev/sda2 (boot/recovery)
# Create GPT disk label
parted /dev/sda mklabel gpt
# Reboot to Windows 7 UEFI installation

##### Windows installation (UEFI mode)
# Create partition (this creates two other partitions)
# Install Windows on Partition 3
# Don't install Windows updates just yet
# Install WindSLIC UEFI SLIC injector
# * Run Installer_EFI_gui.exe and install Acer (no confirmation shown)
# * Extract key_cert_installers.zip and run acer.exe
# Reboot
# In BIOS -> Boot Sequence there should now be a WindSLIC boot entry
#   Boot Option Name: WindSLIC
#   File System List: HD(1,GPT,5D2FA970-D7F9-4B9B-A9E3-4ECF4535B145)
#   File Name: \EFI\58da059ce62f495a13a84e6f8c0b787e\BOOTX64.EFI 
# Check if Windows is indeed activated
# My Windows was not activated, so proceed to install modified BOOTX64.EFI
# In an elevated command prompt:
#   mountvol V: /S
#   V:
#   cd EFI\58da059ce62f495a13a84e6f8c0b787e
#   move BOOTX64.EFI BOOTX64.EFI.bak
#   copy C:\path\to\modified\BOOTX64.EFI BOOTX64.EFI
# Reboot and re-check that Windows is activated
# Proceed to enable Windows Update etc.
# Install Intel 7260 WiFi Driver (A08) - only Link Driver, deselect bloat
# Install updates and software
# Go to support.dell.com, download and install
#  * Chipset: Intel 8 Series Chipset
#  * Chipset: Intel USB3.0 xHCI
#  * Chipset: O2 Micro OZ777xxx/OZ921XX Memory Card Reader
#  * Chipset: ST Microelectronics Free Fall Data Protection (ACPI\SMO8810)
#  * Modem/Communications: Dell Wireless 5808e LTE
#  * Mouse, Keyboard & Input Devices: Dell Multi-Touch Touchpad
#  * Mouse, Keyboard & Input Devices: Dell Unifying Application
# Audio driver: Search "Realtek combined High-Definition" on support.dell.com
#
# Disable hibernation in an elevated command prompt:
#   powercfg -h off
# Go to advanced power settings and make sure the following is disabled/gone:
#   Allow hybrid sleep
#   Hibernate after
# Also, check these settings:
#   Critical battery action
#   Low battery action
#
# Go to System Properties -> Advanced -> Performance: Settings... -> Advanced
# Change virtual memory settings:
#   Initial size (MB): 1024
#   Maximum size (MB): 17000

##### Arch Linux installation (UEFI mode)
# Boot archiso in UEFI mode and
loadkeys dk
wifi-menu
# Connect to the internet
# Windows 7 installer already created a 100MB EFI system partitioni (ESP)
# In this case, SSD appears as /dev/sda with 140.8GB of free space
gdisk /dev/sda
# Create 7x 20GB partitions of type 8e00 (Linux LVM)
#   /dev/sda(4-10)
# Create the last partition (ca. 837MB) as Linux filesystem
#   /dev/sda11
#
### Format partitions
for i in `seq 4 10`; do pvcreate /dev/sda$i; done
mkfs.ext4 -L boot /dev/sda11
#
### Setup first layer of LVM and dm-crypt (LUKS)
vgcreate raw /dev/sda`seq -s " /dev/sdb" 4 10`
lvcreate -L 80G -n luks raw
# Determine fastest cipher (turned out to be aes-xts)
cryptsetup benchmark
# Encrypt the device using an XTS cipher and plain64 IV generator
# (in XTS mode, only half of the key is cipher, so 256 bits equalents AES-128)
# https://code.google.com/p/cryptsetup/wiki/FrequentlyAskedQuestions
cryptsetup -c aes-xts-plain64 -y -s 256 luksFormat /dev/mapper/raw-luks
# type YES and enter a passphrase
cryptsetup --allow-discards open /dev/mapper/raw-luks raw-luks_crypt
# enter passphrase to unlock
cryptsetup status raw-luks_crypt
#
### Setup second layer of LVM and filesystems:
pvcreate /dev/mapper/raw-luks_crypt
vgcreate luks /dev/mapper/raw-luks_crypt
lvcreate -l 100%VG -n btrfs luks
# https://wiki.archlinux.org/index.php/Btrfs
mkfs.btrfs -L btrfs /dev/mapper/luks-btrfs
mount -o discard,autodefrag,compress=lzo,space_cache /dev/mapper/luks-btrfs /mnt
btrfs subvolume create /mnt/arch
umount /mnt
mount -o subvol=arch,discard,autodefrag,compress=lzo /dev/mapper/luks-btrfs /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
mkdir -p /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
#
### Setup btrfs subvolumes and enable quota (WARNING: quotas are yet unstable)
# https://btrfs.wiki.kernel.org/index.php/Quota_support
btrfs quota enable /mnt
btrfs sub create /mnt/home
btrfs sub create /mnt/var
btrfs qgroup limit 5G /mnt/var
# Check quotas
btrfs sub list /mnt
btrfs qg show -re /mnt
btrfs qg show -Fre /mnt/var
#
### Install base system + basic shell utilities
pacstrap /mnt base bash-completion screen vim
# Generate /etc/fstab using UUID as identifiers
genfstab -U -p /mnt >> /mnt/etc/fstab
# Chroot into the new environment
arch-chroot /mnt
SHELL=/bin/bash screen
#
# Using screen's copy-paste feature:
#   1) Go to copy/scrollback mode (CTRL+A, ESC)
#   2) Select start/end with SPACE
#   3) Exit copy mode with ESC
#   4) To paste, press CTRL+A, ]


##### Enable multilib repository in /etc/pacman.conf (32-bit support)
sed -i '
  /^#\[multilib\]/ ! b
  s/^#//; n; s/^#//
' /etc/pacman.conf


##### Pacman: Use fastest mirrors first
pacman -Sy reflector
reflector -c DK -c NO -c SE --sort rate -p http --save /etc/pacman.d/mirrorlist


##### Install basic packages
pacman -Sy --noconfirm `sed 's/#.*//' <<_EOF_
## Development
	multilib-devel base-devel
## LVM and dm-crypt
	cryptsetup lvm2
## Network tools, wifi-menu dependencies
	dialog dhclient openssh wget wpa_supplicant
## Shell utilities
	bash-completion screen vim vim-systemd
_EOF_`


##### Set hostname and timezone manually
echo tachydell > /etc/hostname
ln -sf /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime


#### Locale enable, generate and initial configuration
sed -i '
  /^#en_DK.UTF-8/ s/^#//
  /^#en_GB.UTF-8/ s/^#//
  /^#en_US.UTF-8/ s/^#//
' /etc/locale.gen
locale-gen
echo LANG=en_GB.UTF-8 > /etc/locale.conf


##### Console configuration (keymap)
echo 'KEYMAP="dk"' >> /etc/vconsole.conf


##### Fix usbhid ELAN multitouch panel disconnects
cat > /etc/elan_multitouch_quirks.conf <<_EOF_
# lsusb | grep Elan
# grep HID_QUIRK_ALWAYS_POLL /usr/lib/modules/3.17.3-1-ARCH/build/include/linux/hid.h
options usbhid quirks=0x04f3:0x0111:0x00000400
_EOF_
mkinitcpio -p linux
# Reboot to apply changes


##### Configure /etc/mkinitcpio.conf and generate new RAM disk
# Configuration in /etc/mkinitcpio.conf
#MODULES="crc32c-intel i915 usb_storage"
#HOOKS="base udev autodetect modconf block lvm2 keyboard encrypt filesystems fsck"
#FILES="/etc/udev/hwdb.bin"
# Generate new RAM disk
mkinitcpio -p linux


##### Set root password
passwd


##### Backup LUKS header (e.g. to USB pendrive)
cryptsetup --header-backup-file=/path/to/tachydell_luks_header.dump luksHeaderBackup /dev/mapper/raw-luks


##### GRUB setup (UEFI)
pacman -S grub dosfstools efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug
#
### Configure timeout and LUKS encryption device
sed -i '
/^GRUB_TIMEOUT=/ s/=.*/=15/
/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/=.*/="cryptdevice=/dev/mapper/raw-luks:raw-luks_crypt:allow-discards cryptkey=/dev/sdb:512:11913 quiet"/
' /etc/default/grub
#
# Configure Windows booting in /etc/grub.d/40_custom
# See https://wiki.archlinux.org/index.php/GRUB#Windows_Installed_in_UEFI-GPT_Mode_menu_entry
# Change chainloader to WindSLIC:
#chainloader /EFI/58da059ce62f495a13a84e6f8c0b787e/BOOTX64.EFI
#
### Generate grub.cfg after configuration changes
# Still inside chroot? Ignore warnings about "Failed to connect to lvmetad"
grub-mkconfig -o /boot/grub/grub.cfg


################################################################################
# PACKAGES: CLI
################################################################################

pacman -Sy --needed `sed 's/#.*//' <<_EOF_
## Basic shell tools
	at bash-completion dialog openssh screen vim vim-systemd wget
## Arch Linux tools
	namcap
## Development
	gdb strace
## Audio
	alsa-utils pulseaudio pulseaudio-alsa
## Bluetooth
	bluez bluez-utils
## Booting
	efibootmgr syslinux
## Data recovery
	ddrescue testdisk
## File archiving, compression
	arj cabextract cpio lzop p7zip unzip unrar zip
## File management
	convmv mc mlocate
## File sharing, synchronization, transfer
	libmtp rsync samba sshfs
## Filesystems, encryption
	btrfs-progs exfat-utils f2fs-tools jfsutils nilfs-utils ntfs-3g reiserfsprogs xfsprogs
	gptfdisk parted
	ecryptfs-utils encfs
	cdrkit dosfstools mtools
	fuse ifuse
## Games
	bsd-games fortune-mod
## Hardware
	intel-ucode
## Kernel
	dkms linux-headers
## Multimedia
	imagemagick
## Network connectivity
	avahi dhclient iw
## Network tools
	dnsmasq dnsutils ethtool gnu-netcat links net-snmp net-tools nmap ntp rfkill
## Version control
	bzr git mercurial subversion python2-paramiko
_EOF_`
#Removed again: os-prober

cat <<_EOF_
## Network connectivity
	networkmanager-openconnect openconnect
## Printing, document rendering
	cups foomatic-db foomatic-db-nonfree ghostscript gutenprint hplip
## Text/image processing
	enscript imagemagick poppler
## Hardware
	acpid cpupower dmidecode hdparm i7z iotop smartmontools usb_modeswitch
## Security
	aircrack-ng john
	haveged
## Programming
	php pkgbuild-introspection python2-xlib
## 32-bit support
	multilib-devel gcc-multilib libtool-multilib
_EOF_


################################################################################
# PACKAGES: GUI/mixed
################################################################################
# Install all Xorg drivers
pacman -Sy --noconfirm --needed xorg-drivers xf86-input-elographics
# Install additional graphics driver dependencies (including 32-bit libraries)
pacman -Sy --needed mesa-dri lib32-mesa-dri mesa-libgl lib32-mesa-libgl mesa-vdpau lib32-mesa-vdpau

pacman -Sy --needed `sed 's/#.*//' <<_EOF_
## X server and utilities
	xorg-server xorg-server-utils xorg-apps
## Display manager
	# (SDDM run on both Wayland and Xorg, uses systemd-logind)
	# REMOVED AGAIN: sddm
	lightdm lightdm-gtk2-greeter accountsservice
## Fonts
	ttf-bitstream-vera ttf-dejavu ttf-freefont ttf-linux-libertine ttf-oxygen
	ttf-droid ttf-liberation ttf-ubuntu-font-family
	# xorg-fonts-75dpi xorg-fonts-100dpi xorg-fonts-type1
## Desktop environment
	enlightenment epplet-base terminology  # consider: emotion_generic_players
	xfce4 xfce4-goodies xfce4-whiskermenu-plugin librsvg tumbler
	libcanberra lib32-libcanberra lib32-libcanberra-pulse
	dconf gconf-editor
	gnome-keyring xdg-utils  # consider: notification-daemon
	xdg-user-dirs-gtk
	xscreensaver  # gnome-screensaver xlockmore
## Desktop theming
	adwaita-icon-theme	elementary-icon-theme gnome-icon-theme gnome-icon-theme-symbolic
## Audio
	alsa-plugins pulseaudio pulseaudio-alsa
## File management
	thunar thunar-archive-plugin thunar-media-tags-plugin tumbler
	xarchiver
## Input
	evtest gpointing-device-settings
## Internet
	firefox
	evolution evolution-ews highlight
	pidgin pidgin-sipe pidgin-libnotify purple-plugin-pack skype
## Media codecs, plugins, conversion
	gst-plugins-good gst-libav libdvdcss
	ffmpeg speex x264 x265 xvidcore
## Misc
	perl-file-mimeinfo  # optional dep for: dropbox xdg-utils
	guake
## Multimedia
	gimp xsane-gimp
	musescore  # consider musescore-docs
	vlc
## Networking
	networkmanager networkmanager-openconnect
	modemmanager openconnect pptpclient usb_modeswitch
	network-manager-applet
	gvfs gvfs-afc gvfs-afp gvfs-gphoto2 gvfs-mtp gvfs-smb
	bluez bluez-utils obexfs obexftp obextool
	remmina freerdp libvncserver xorg-server-xephyr
## Office, text
	geany geany-plugins vte
	evince
## Printing, scanning
	cups hplip
	sane xsane
## Runtime
	jre8-openjdk
_EOF_`

### Removed again:
# connman


################################################################################
# PACKAGES: AUR and third-party
################################################################################

##### Install yuourt and dependencies (package-query)
pacman -Sy yajl
mkdir -p /data/abs
chmod 777 /data/abs
pushd /data/aur
wget -O - https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz | sudo -u nobody tar -xz --overwrite
wget -O - https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz | sudo -u nobody tar -xz --overwrite
for pkg in package-query yaourt; do
	pushd $pkg
	sudo -u nobody makepkg -f
	pacman -U $pkg*.pkg.tar.xz
	popd
done
popd
#Optional dependencies for yaourt
#    aurvote: vote for favorite packages from AUR
#    customizepkg: automatically modify PKGBUILD during install/upgrade
#    rsync: retrieve PKGBUILD from official repositories [installed]


##### Pipelight, wine-silverlight
# IMPORTANT: Close Firefox before installing pipelight
# Add to /etc/pacman.conf
cat >>/etc/pacman.conf <<"_EOF_"
[pipelight]
Server = http://repos.fds-team.de/stable/arch/$arch
_EOF_
# Import keys
pacman-key -r E49CC0415DC2D5CA
pacman-key --lsign-key E49CC0415DC2D5CA
# Install pipelight, which pulls in wine-compholio (a.k.a. wine-silverlight)
pacman -Sy pipelight zenity
# Dependencies installed: ca. 355 MB (mostly for wine-compholio)
# zenity is needed for file dialogs
pipelight-plugin --update
# As the regular user, run:
#pipelight-plugin --enable flash
#pipelight-plugin --enable silverlight5.1
#pipelight-plugin --enable unity3d


##### Dependencies for AUR packages:
#blueman-git: aur/obex-data-server cython2 python2-gobject python2-pybluez
#delorean-dark: gtk-engines gnome-themes-standard gtk-engine-murrine
#eweather-git: aur/libeweather-git
#frame: asciidoc
#geis: aur/grail python-gobject xorg-server-devel
#grail: aur/frame
#obex-data-server (blueman-git): openobex imagemagick libusb-compat
#pipelight: aur/wine-silverlight aur/ttf-ms-fonts lib32-libsm
#python-efl: python-dbus
#touchegg: aur/geis
#volumeicon-pulsefix: intltool
#
### No longer required:
#blueman-git: cython2
#frame: asciidoc
#geis: xorg-server-devel
#
### Removed again:
#blueman: obex file transfer not working/starting
#connman-ui-git: Only very basic features - econnman is better
#econnman: aur/python-efl
#wine-silverlight: fontforge lib32-alsa-lib lib32-attr lib32-fontconfig \
#	lib32-gettext lib32-giflib lib32-glu lib32-gnutls lib32-lcms lib32-libcl \
#	lib32-libpng lib32-libxcomposite lib32-libxcursor lib32-libxi \
#	lib32-libxinerama lib32-libxml2 lib32-libxmu lib32-libxrandr lib32-mpg123 \
#	lib32-openal lib32-v4l-utils opencl-headers prelink

yaourt -Sy --needed `sed 's/#.*//' <<_EOF
## Desktop environment
	volumeicon-pulsefix
## Enlightenment
	eweather-git
	delorean-dark gtk-theme-e17gtk
## Fonts
	ttf-ms-fonts
## Hardware
	iucode-tool
## Internet
	dropbox
## Networking
	blueman
## Security
	upm
## Touchscreen
	touchegg touchegg-gce-git
_EOF_`


################################################################################
# CONFIGURATION
################################################################################

##### Create local user "helge"
id helge || useradd -m helge
passwd helge
usermod -a -G audio,games,locate,lp,network,storage,users,wheel helge
# later groups: plugdev,wireshark
# not adding: sys
### Enable sudo for group wheel
visudo # uncomment: %wheel ALL=(ALL) ALL
### Disable XFCE sessions
# https://wiki.archlinux.org/index.php/xfce#Disable_sessions
sudo -u helge bash -c <<_EOF_
mkdir -p ~/.cache/sessions
rm -rf ~/.cache/sessions/*
chmod 500 ~/.cache/sessions
_EOF_
### Update xdg-user-dirs (also fixes permission problems with bluetooth)
sudo -u helge xdg-user-dirs-update


##### Set hostname, keymap (including X11/xcb) and timezone
hostnamectl set-hostname tachydell
localectl set-keymap dk
localectl set-x11-keymap dk
timedatectl set-timezone Europe/Copenhagen


##### Enable services
systemctl enable lightdm.service
set -- bluetooth.service haveged.service NetworkManager.service sshd.service \
	upower.service
systemctl enable "$@"
systemctl start "$@"


##### Enlightenment
# Settings -> Composite -> General
#   Check: Don't fade backlight
# Settings -> Modules -> Utilities
#   Load: Systray
# Settings -> Modules -> System
#   Load: Connection Manager


########## DEPRECATED
##### Connman network manager
# Avoid changing system hostname from DHCP
# Prefer ethernet over wifi
mkdir -p /etc/connman
cat >/etc/connman/main.conf <<_EOF_
[General]
AllowHostnameUpdates=false
PreferredTechnologies=ethernet,wifi
_EOF_
systemctl restart connman.service


###### Fix xfce4-power-manager unable to start without upower
# See "Enable services" further up in this document
#systemctl enable upower.service
#systemctl start upower.service


##### Intel processor microcode
### https://wiki.archlinux.org/index.php/microcode
# Install packages
pacman -S intel-ucode
yaourt -S iucode-tool
# Check if microcode image is available (listed below "selected microcode")
modprobe cpuid
bsdtar -Oxf /boot/intel-ucode.img | iucode_tool -tb -lS -
# Generate new GRUB config, automatically detects and adds microcode initrd
grub-mkconfig -o /boot/grub/grub.cfg


##### Disable "--" in Evolution mail signature
# Open dconf-editor
# Navigate to: org/gnome/evolution/mail
# Enable: composer-no-signature-delim


##### Skype
#Important update note: Since Skype 4.3, only PulseAudio is supported.
#That means you NEED a working PulseAudio setup to use Skype for voice chatting.
#If you get distorted sound in skype, try adding PULSE_LATENCY_MSEC=60 to your
#env before starting skype. Something like 'export PULSE_LATENCY_MSEC=60' in .bashrc, for example.