Difference between revisions of "User:Djgera"

From ArchWiki
Jump to: navigation, search
(pacman)
(syslinux)
Line 97: Line 97:
 
{{bc|<nowiki>
 
{{bc|<nowiki>
 
extlinux -i /boot/syslinux
 
extlinux -i /boot/syslinux
cp /usr/lib/syslinux/menu.c32 /boot/syslinux/
+
cp /usr/lib/syslinux/bios/menu.c32 /boot/syslinux/
 +
cp /usr/lib/syslinux/bios/libutil.c32 /boot/syslinux/
 
</nowiki>}}
 
</nowiki>}}
  

Revision as of 05:25, 4 November 2013

Presentation

My name is Gerardo Exequiel Pozzi (djgera). I am from Buenos Aires (Argentina), my year of birth is 1982. My areas of interest are: low-level programming, theory of languages and mathematics in general.

I am using Arch Linux since December of 2008, my original distro was Slackware Linux since October of 2001. I like helping the community in what it can within my reach, for example reporting bugs and feature request, new ideas, packaging, etc.

Reported bugs and feature requests

Git repo

My machine

  • Motherboard: Asus M2N32-SLI Deluxe (Firmware: 1603)
  • CPU: AMD Athlon 64 X2 5200+ [ADA5200IAA6CS]
  • RAM: 4 x 1GB OCZ DDR2 800MHz Platinum Rev 2 (4-4-4-15) [OCZ2P800R21G]
  • GPU: EVGA GeForce GT 520 1GB RAM DDR3 | VBIOS: 75.19.1b.00.20 | PN: 01G-P3-1523-KR
  • Audio: Sound Blaster Live! MP3
  • Storage (sda): Western Digital Caviar Black 2TB - 64MB Cache (Firmware: 05.01D05) [WD2001FASS-00W2B0]
  • Storage (sdb): Western Digital Caviar Black 2TB - 64MB Cache (Firmware: 01.00101) [WD2001FASS-00W2B0]
  • Storage (sdc): Western Digital Caviar Black 2TB - 64MB Cache (Firmware: 01.00101) [WD2001FASS-00W2B0]
  • Storage (sdd): Western Digital Caviar Black 2TB - 64MB Cache (Firmware: 05.01D05) [WD2001FASS-00W2B0]
  • Optical Drive: LG DVD-RW SATA Dual Layer (Fimware IL00) [GH20NS15]
  • Power Supply: PowerCooler ATX12V 2.0 PS-500SS 500W
  • Monitor: Dell UltraSharp 24" - (H-IPS panel [LM240WU4-SLB1]) - 1920x1200 - [U2410 / Rev A05]
  • Keyboard/Mouse: Logitech Cordless Desktop EX 100
  • Webcam: Logitech HD Webcam C510
  • Printer: HP Laserjet P1006
  • UPS: APC Back-UPS RS800VA, 230V [BR800i] (Firmware: 9.o5 .I USB FW:o5)

System configuration

HDD partition scheme

Disk /dev/sda: 3907029168 sectors, 1.8 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 014F724D-394E-4571-9DDA-9A3943BA7F1E
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3907029134
Partitions will be aligned on 2048-sector boundaries
Total free space is 34925 sectors (17.1 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2099199   1024.0 MiB  8300  Linux filesystem
   2         2101248        69210111   32.0 GiB    8300  Linux filesystem
   3        69212160       136321023   32.0 GiB    8300  Linux filesystem
   4       136323072       169877503   16.0 GiB    8200  Linux swap
   5       169879552       236988415   32.0 GiB    8300  Linux filesystem
   6       236990464      3907006463   1.7 TiB     8300  Linux filesystem
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xba469f54

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  3907029167  1953513560   83  Linux
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x15138733

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048  3907029167  1953513560   83  Linux
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbb1fe300

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048  3907029167  1953513560   83  Linux

syslinux

syslinux (mbr.bin) installed on MBR (sda)

dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/gptmbr.bin of=/dev/sda
extlinux -i /boot/syslinux
cp /usr/lib/syslinux/bios/menu.c32 /boot/syslinux/
cp /usr/lib/syslinux/bios/libutil.c32 /boot/syslinux/
/boot/syslinux/syslinux.cfg
timeout 10

ui menu.c32


label 3.8.13
    linux ../vmlinuz-3.8.13
    initrd ../initramfs-3.8.13.img
    append root=/dev/sda2 rw


label memtest86+
    linux ../memtest86+-4.20.bin

mkinitcpio

/etc/mkinitcpio-djgera.conf
HOOKS="base udev autodetect save_hdd_live keymap fsck shutdown"


/usr/lib/initcpio/install/save_hdd_live 
#!/bin/bash
build()
{
    add_file /etc/udev/rules.d/69-save-hdd-live.rules
    add_binary hdparm
}

help ()
{
cat <<HELPEOF
  This hook will save your HDD live!
HELPEOF
}


/usr/lib/initcpio/install/rescue
#!/bin/bash
build()
{
    # syslinux
    add_binary extlinux
    add_file /usr/lib/syslinux/mbr.bin
    add_file /usr/lib/syslinux/gptmbr.bin


    # util-linux
    add_binary blockdev
    add_binary fdisk
    add_binary hexdump
    add_binary losetup
    add_binary mkswap
    add_binary umount
    add_binary wipefs

    # e2fsprogs
    add_binary badblocks
    add_binary chattr
    add_binary fsck.ext4
    add_binary lsattr
    add_binary mkfs.ext4
    add_binary tune2fs

    # xfsprogs
    add_binary mkfs.xfs
    add_binary xfs_repair

    # gptfdisk
    add_binary gdisk

    # rsync
    add_binary rsync

    # coreutils
    add_binary cat
    add_binary cp
    add_binary dd
    add_binary mv
    add_binary rm
    add_binary sync

    # bash
    add_binary bash

    # findutils
    add_binary find
    add_binary xargs

    # procps-ng
    add_binary free
    add_binary ps
    add_binary slabtop
    add_binary top
    add_binary vmstat

    # smartmontools
    add_binary smartctl
    add_file /usr/share/smartmontools/drivedb.h

    # hdparm
    add_binary hdparm

    # ncurses
    add_file /usr/share/terminfo/l/linux

    # nano
    add_binary nano
}

help ()
{
cat <<HELPEOF
  Rescue hook!
HELPEOF
}

systemd

localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: es
      X11 Layout: es
hostnamectl
   Static hostname: exequiel
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: cd9e9d24fe37411c3b2d22c14951b1a1
           Boot ID: e4f43e59f71748388c7a747e5dbbbfdb
  Operating System: Arch Linux
            Kernel: Linux 3.8.13-64
      Architecture: x86_64
timedatectl
      Local time: Sun 2013-06-09 17:28:36 ART
  Universal time: Sun 2013-06-09 20:28:36 UTC
        RTC time: Sun 2013-06-09 20:28:33
        Timezone: America/Buenos_Aires (ART, -0300)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
/etc/udev/rules.d/69-usbasp.rules
ACTION=="remove", GOTO="usbasp_end"

SUBSYSTEM=="usb", ATTR{product}=="USBasp", TAG+="uaccess"

LABEL="usbasp_end"
/etc/udev/rules.d/69-usbserial.rules
ACTION=="remove", GOTO="usbserial_end"

SUBSYSTEM=="tty", KERNEL=="ttyUSB0", TAG+="uaccess"

LABEL="usbserial_end"
/etc/udev/rules.d/69-android.rules
ACTION=="remove", GOTO="android_end"

SUBSYSTEM=="usb", ATTR{product}=="MT65xx Android Phone", TAG+="uaccess"

LABEL="android_end"
/etc/systemd/system
├── dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service
├── default.target -> /usr/lib/systemd/system/multi-user.target
├── getty.target.wants
│   └── getty@tty1.service -> /usr/lib/systemd/system/getty@.service
├── hddtemp.service.d
│   └── es.conf
├── multi-user.target.wants
│   ├── apcupsd.service -> /usr/lib/systemd/system/apcupsd.service
│   ├── avahi-daemon.service -> /usr/lib/systemd/system/avahi-daemon.service
│   ├── cronie.service -> /usr/lib/systemd/system/cronie.service
│   ├── cups.path -> /usr/lib/systemd/system/cups.path
│   ├── hddtemp.service -> /usr/lib/systemd/system/hddtemp.service
│   ├── mpd.service -> /usr/lib/systemd/system/mpd.service
│   ├── network@enp0s16.service -> /etc/systemd/system/network@.service
│   ├── ntpd.service -> /usr/lib/systemd/system/ntpd.service
│   ├── remote-fs.target -> /usr/lib/systemd/system/remote-fs.target
│   ├── smartd.service -> /usr/lib/systemd/system/smartd.service
│   └── vnstat.service -> /usr/lib/systemd/system/vnstat.service
├── network@.service
├── printer.target.wants
│   └── cups.service -> /usr/lib/systemd/system/cups.service
├── smartlog@.service
└── sockets.target.wants
    ├── avahi-daemon.socket -> /usr/lib/systemd/system/avahi-daemon.socket
    ├── cups.socket -> /usr/lib/systemd/system/cups.socket
    └── sshd.socket -> /usr/lib/systemd/system/sshd.socket

glibc

/etc/locale.gen
en_US.UTF-8 UTF-8  
en_US ISO-8859-1  
es_AR.UTF-8 UTF-8  
es_AR ISO-8859-1 

iproute2

/etc/systemd/system/network@.service
[Unit]
Description=Network Connectivity On %i
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device


[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network/%i
ExecStart=/sbin/ip link set dev %i up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev %i
ExecStop=/sbin/ip link set dev %i down
/etc/conf.d/network/enp0s16
address=192.168.0.77
netmask=24
broadcast=192.168.0.255
gateway=192.168.0.1


hdparm

/etc/udev/rules.d/69-save-hdd-live.rules
ACTION=="remove", GOTO="save_hdd_live_end"
SUBSYSTEM!="block", GOTO="save_hdd_live_end"
ENV{DEVTYPE}!="disk", GOTO="save_hdd_live_end"

ENV{ID_ATA_FEATURE_SET_APM}=="1", RUN+="/usr/bin/hdparm -B 255 $devnode"
ENV{ID_ATA_FEATURE_SET_AAM}=="1", RUN+="/usr/bin/hdparm -M 128 $devnode"
ENV{ID_ATA_FEATURE_SET_PM}=="1", RUN+="/usr/bin/hdparm -S 0 $devnode"

LABEL="save_hdd_live_end"


smartmontools

/etc/systemd/system/smartlog@.service 
[Unit]
Description=SMART on disk %i

[Service]
ExecStart=/usr/bin/smartctl -a /dev/%i
SyslogIdentifier=smart-%i
/etc/udev/rules.d/70-smartlog.rules
ACTION=="remove", GOTO="smartlog_end"
SUBSYSTEM!="block", GOTO="smartlog_end"
ENV{DEVTYPE}!="disk", GOTO="smartlog_end"

ENV{ID_ATA_FEATURE_SET_SMART_ENABLED}=="1", ENV{SYSTEMD_WANTS}="smartlog@$name.service"

LABEL="smartlog_end"

hddtemp

/etc/systemd/system/hddtemp.service.d/es.conf 
[Service]
ExecStart=
ExecStart=/usr/bin/hddtemp -dF /dev/sda /dev/sdb /dev/sdc /dev/sdd

apcupsd

/usr/lib/systemd/system-shutdown/apc_killpower
#!/bin/sh

if [ -f /etc/apcupsd/powerfail -a "$1" = "poweroff" ]; then
    /etc/apcupsd/apccontrol killpower
fi
/root/bin/ups-mailer
#!/bin/sh

TO="<USER>@<DOMAIN>"
MAIL="/usr/bin/mail"
export MAILRC="/root/.mailrc"

/usr/bin/apcaccess status | $MAIL -s "${0##*/} | $(hostname)" "$TO"

exit 0

/etc/apcupsd/
├── changeme -> /root/bin/ups-mailer
├── commfailure -> /root/bin/ups-mailer
├── commok -> /root/bin/ups-mailer
├── offbattery -> /root/bin/ups-mailer
└── onbattery -> /root/bin/ups-mailer

s-nail

/root/.mailrc
set sendmail="/usr/bin/msmtp"
set from="Gerardo Exequiel Pozzi <USER@DOMAIN>"

msmtp

/root/.msmtprc
account <USER>
host <DOMAIN>
from <USER@DOMAIN>
auth on
tls on
tls_starttls off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
port 465
user <USER>
password <PASSWORD>

mc

/etc/profile.d/mc.sh
alias mc='. /usr/lib/mc/mc-wrapper.sh'

polkit

/etc/polkit-1/rules.d/69-djgera.rules
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.login1.power-off" ||
        action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
        action.id == "org.freedesktop.login1.reboot" ||
        action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
        action.id == "org.freedesktop.login1.hibernate" ||
        action.id == "org.freedesktop.login1.hibernate-multiple-sessions" ||
        action.id == "org.freedesktop.login1.suspend" ||
        action.id == "org.freedesktop.login1.suspend-multiple-sessions") {
        return polkit.Result.NO;
    }
});

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.upower.hibernate" ||
        action.id == "org.freedesktop.upower.suspend") {
        return polkit.Result.NO;
    }
});

filesystem

/etc/fstab
tmp                    /tmp          tmpfs     nodev,nosuid,size=100% 0 0

/dev/sda4              none          swap      defaults 0 0

/dev/sda1              /boot         ext4      noatime,nosuid,nodev,noexec 0 2
/dev/sda2              /             ext4      noatime,nodev 0 0
/dev/sda3              /var          ext4      noatime,nosuid,nodev 0 2
/dev/sda5              /home         ext4      noatime,nosuid,nodev 0 2
/dev/sda6              /data/data    xfs       ro,noatime,nosuid,nodev,noexec 0 2

/dev/sdb1              /neta/neta0   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2
/dev/sdc1              /neta/neta1   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2
/dev/sdd1              /neta/neta2   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2
/etc/nsswitch.conf
passwd: files
group: files
shadow: files

publickey: files

hosts: files dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

netgroup: files
/etc/hosts

127.0.0.1       localhost.localdomain   localhost
::1             localhost.localdomain   localhost

192.168.0.77 exequiel
/etc/profile.d/editor.sh
export VISUAL=mcedit
export EDITOR=mcedit
/etc/profile.d/kwin_triple_buffer.sh
export KWIN_TRIPLE_BUFFER=1

kmod

/etc/modules-load.d/djgera.conf
#fbcon
/etc/modprobe.d/djgera.conf
#blacklist nvidia
blacklist fbcon
blacklist nouveau
blacklist rtl8187
blacklist pata_amd
blacklist snd_hda_intel
/etc/modprobe.d/nvidia.conf
options nvidia NVreg_EnableMSI=1

xorg-server

/etc/X11/xorg.conf
Section "Device"
    Identifier     "nvidia0"
    Driver         "nvidia"
    Option         "TripleBuffer" "on"
#    Driver         "nouveau"
#    Option         "GLXVBlank" "on"
EndSection

fontconfig

/etc/fonts/local.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <match target="font">
  <edit mode="assign" name="autohint">
   <bool>true</bool>
  </edit>
 </match>
</fontconfig>

pacman

/etc/pacman.conf
[options]
HoldPkg     = pacman glibc
Architecture = auto

IgnorePkg    = pm-utils pm-quirks
IgnorePkg    = linux-headers
IgnorePkg    = hplip

IgnorePkg    = flashplugin
IgnorePkg    = lib32-flashplugin

IgnorePkg    = freetype2 fontconfig
IgnorePkg    = lib32-freetype2 lib32-fontconfig

IgnorePkg    = nvidia-utils nvidia-libgl opencl-nvidia
IgnorePkg    = lib32-nvidia-utils lib32-nvidia-libgl lib32-opencl-nvidia

IgnorePkg    = systemd systemd-sysvcompat
IgnorePkg    = lib32-systemd

NoUpgrade   = etc/apcupsd/onbattery etc/apcupsd/offbattery etc/apcupsd/changeme etc/apcupsd/commok etc/apcupsd/commfailure

Color
VerbosePkgLists

SigLevel    = Required DatabaseOptional
LocalFileSigLevel = Optional

[core]
Include = /etc/pacman.d/mirrorlist

[extra]
Include = /etc/pacman.d/mirrorlist

[community]
Include = /etc/pacman.d/mirrorlist

[multilib]
Include = /etc/pacman.d/mirrorlist

mpd

/etc/mpd.conf
music_directory		"/data/musica"
playlist_directory	"/var/lib/mpd/playlists"
db_file			"/var/lib/mpd/mpd.db"
log_file		"syslog"
pid_file		"/var/run/mpd/mpd.pid"
state_file		"/var/lib/mpd/mpdstate"
user			"mpd"
metadata_to_use		"none"
max_playlist_length	"65536"
audio_output {
    type		"alsa"
    name		"default"
}

¡Machetes!

qemu-kvm

Quick image with base setup

A quick way to make an image with a base installation without installer.

  • Packages needed: syslinux arch-install-scripts
  • First time boot with fallback initramfs, then run mkinitcpio -p linux.
  • Adjust /etc/locale.gen, run locale-gen.
modprobe nbd max_part=8
qemu-img create -f qcow2 archbase.qcow2 1G
qemu-nbd -c /dev/nbd0 archbase.qcow2
sleep 2
echo -e "p\nn\np\n1\n\n\na\n1\np\nw\nq\n" | fdisk /dev/nbd0
mkfs.ext4 -m0 -L AB_RAIZ /dev/nbd0p1
mkdir /tmp/archbase
mount /dev/nbd0p1 /tmp/archbase
pacstrap /tmp/archbase
echo 'LABEL=AB_RAIZ / ext4 defaults 0 1' >> /tmp/archbase/etc/fstab
echo 'archbase' > /tmp/archbase/etc/hostname
ln -s /usr/share/zoneinfo/America/Buenos_Aires /tmp/archbase/etc/localtime
echo 'KEYMAP=es' > /tmp/archbase/etc/vconsole.conf
echo 'LANG=en_US.UTF-8' > /tmp/archbase/etc/locale.conf
mkdir /tmp/archbase/boot/syslinux
cat << FIN > /tmp/archbase/boot/syslinux/syslinux.cfg
# DEFAULT arch

LABEL arch
  LINUX ../vmlinuz-linux
  APPEND root=LABEL=AB_RAIZ rw
  INITRD ../initramfs-linux.img

LABEL arch-fallback
  LINUX ../vmlinuz-linux
  APPEND root=LABEL=AB_RAIZ rw
  INITRD ../initramfs-linux-fallback.img
FIN
extlinux -i /tmp/archbase/boot/syslinux
umount /tmp/archbase
rmdir /tmp/archbase
cat /usr/lib/syslinux/mbr.bin > /dev/nbd0
blockdev --flushbufs /dev/nbd0
qemu-nbd -d /dev/nbd0
Increment size of the image
  • Assume partition of 1G created in previous step. Resize to 2G.
modprobe nbd max_part=8
qemu-img convert archbase.qcow2 -O raw archbase.raw
dd of=archbase.raw bs=1G count=0 seek=2
qemu-img convert archbase.raw -O qcow2 archbase.qcow2
qemu-nbd -c /dev/nbd0 archbase.qcow2
sleep 2
echo -e "p\nd\nn\np\n1\n\n\na\n1\np\nw\nq\n" | fdisk /dev/nbd0
e2fsck -f /dev/nbd0p1
resize2fs /dev/nbd0p1 
blockdev --flushbufs /dev/nbd0
qemu-nbd -d /dev/nbd0
Network
ip tuntap add dev tap0 mode tap user djgera
ip tuntap add dev tap1 mode tap user djgera
brctl addbr br0
brctl setfd br0 0
brctl addif br0 enp0s16
brctl addif br0 tap0
brctl addif br0 tap1
ip link set dev br0 up
ip link set dev tap0 up
ip link set dev tap1 up
ip addr del 192.168.0.77/24 dev enp0s16
ip addr add 192.168.0.77/24 broadcast + dev br0
ip route add default via 192.168.0.1