Difference between revisions of "User:Djgera"

From ArchWiki
Jump to: navigation, search
(systemd)
(filesystem)
Line 446: Line 446:
  
 
/dev/sda10            /data/data0  xfs      ro,noatime,nosuid,nodev,noexec 0 2
 
/dev/sda10            /data/data0  xfs      ro,noatime,nosuid,nodev,noexec 0 2
/dev/sda11            /data/data1  xfs      ro,noatime,nosuid,nodev,noexec 0 2
+
/dev/sda11            /data/data1  xfs      ro,noatime,nosuid,nodev,noexec,noauto 0 2
/dev/sda12            /data/data2  xfs      ro,noatime,nosuid,nodev,noexec 0 2
+
/dev/sda12            /data/data2  xfs      ro,noatime,nosuid,nodev,noexec,noauto 0 2
  
 
/dev/sdb1              /data/data3  xfs      ro,noatime,nosuid,nodev,noexec,noauto 0 2
 
/dev/sdb1              /data/data3  xfs      ro,noatime,nosuid,nodev,noexec,noauto 0 2
Line 465: Line 465:
  
 
/dev/sda10            /data/data0  xfs      ro,noatime,nosuid,nodev,noexec 0 2
 
/dev/sda10            /data/data0  xfs      ro,noatime,nosuid,nodev,noexec 0 2
/dev/sda11            /data/data1  xfs      ro,noatime,nosuid,nodev,noexec 0 2
+
/dev/sda11            /data/data1  xfs      ro,noatime,nosuid,nodev,noexec,noauto 0 2
/dev/sda12            /data/data2  xfs      ro,noatime,nosuid,nodev,noexec 0 2
+
/dev/sda12            /data/data2  xfs      ro,noatime,nosuid,nodev,noexec,noauto 0 2
  
 
/dev/sdb1              /data/data3  xfs      ro,noatime,nosuid,nodev,noexec,noauto 0 2
 
/dev/sdb1              /data/data3  xfs      ro,noatime,nosuid,nodev,noexec,noauto 0 2
 
</nowiki>}}
 
</nowiki>}}
 
  
 
==== kmod ====
 
==== kmod ====

Revision as of 03:56, 8 October 2012

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 [backup]: Western Digital Caviar Black 2TB - 64MB Cache (Firmware: 01.00101) [WD2001FASS-00W2B0]
  • Storage [backup]: Western Digital Caviar Black 2TB - 64MB Cache (Firmware: 01.00101) [WD2001FASS-00U0B0]
  • 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: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 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 identifier: 0x79dfe14b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      133119       65536   83  Linux      (64M - ext4 - /syslinux)
/dev/sda2          133120    42076159    20971520   83  Linux      (20G - ext4 - / - 32-bit)
/dev/sda3        42076160    84019199    20971520   83  Linux      (20G - ext4 - / - 64-bit)
/dev/sda4        84019200  3907029167  1911504984    5  Extended   (1.78T)
/dev/sda5        84021248    92409855     4194304   82  Swap       (4G)
/dev/sda6        92411904   100800511     4194304   83  Linux      (4G - ext4 - /var - 32-bit)
/dev/sda7       100802560   109191167     4194304   83  Linux      (4G - ext4 - /var - 64-bit)
/dev/sda8       109193216   117581823     4194304   83  Linux      (4G - ext4 - /home - 32-bit)
/dev/sda9       117583872   125972479     4194304   83  Linux      (4G - ext4 - /home - 64-bit)
/dev/sda10      125974528  1384265727   629145600   83  Linux      (600G - xfs - /data/data0)
/dev/sda11     1384267776  3481419775  1048576000   83  Linux      (1000G - xfs - /data/data1)
/dev/sda12     3481421824  3907029167   212803672   83  Linux      (203G - xfs - /data/data2)
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
81 heads, 63 sectors/track, 765633 cylinders, total 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 identifier: 0xba469f54

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

syslinux

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

dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr.bin of=/dev/sda
extlinux -i /mnt/sda1/syslinux
cp /usr/lib/syslinux/{chain,menu}.c32 /mnt/sda1/syslinux/
/syslinux/syslinux.cfg in sda1
timeout 10

ui menu.c32


label LINUX-32
    com32 chain.c32
    append hd0 2

label LINUX-64
    com32 chain.c32
    append hd0 3


label memtest86+
    linux /memtest86+-4.20.bin


extlinux -i /mnt/sda2/boot/syslinux
cp /usr/lib/syslinux/{chain,menu}.c32 /mnt/sda2/boot/syslinux/
/boot/syslinux/syslinux.cfg in sda2
timeout 10

ui menu.c32


label 3.4.11-32
    linux /boot/vmlinuz-3.4.11-32
    initrd /boot/initramfs-3.4.11-32.img
    append root=/dev/sda2 rootfstype=ext4 ro vga=normal


label MAIN
    com32 chain.c32
    append hd0 0


extlinux -i /mnt/sda3/boot/syslinux
cp /usr/lib/syslinux/{chain,menu}.c32 /mnt/sda3/boot/syslinux/
/boot/syslinux/syslinux.cfg in sda3
timeout 10

ui menu.c32


label 3.4.11-64
    linux /boot/vmlinuz-3.4.11-64
    initrd /boot/initramfs-3.4.11-64.img
    append root=/dev/sda3 rootfstype=ext4 ro vga=normal


label MAIN
    com32 chain.c32
    append hd0 0

mkinitcpio

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


/usr/lib/initcpio/install/save_hdd_live 
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
}

systemd

/etc/locale.conf

LANG="en_US.UTF-8"
/etc/hostname
gerardo
/etc/vconsole.conf
KEYMAP="es"
FONT=""
/etc/localtime -> /usr/share/zoneinfo/America/Buenos_Aires
/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+="hdparm -q -B 255 $devnode"
ENV{ID_ATA_FEATURE_SET_AAM}=="1", RUN+="hdparm -q -M 128 $devnode"
ENV{ID_ATA_FEATURE_SET_PM}=="1", RUN+="hdparm -q -S 0 $devnode"

LABEL="save_hdd_live_end"
/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/network@.service
[Unit]
Description=Network Connectivity On %I
Wants=network.target
Before=network.target

[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

[Install]
Alias=multi-user.target.wants/network@eth0.service
/etc/conf.d/network/eth0 
address=192.168.0.77
netmask=24
broadcast=192.168.0.255
gateway=192.168.0.1
/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
├── local-fs.target.wants
├── 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@eth0.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
│   ├── sshdgenkeys.service -> /usr/lib/systemd/system/sshdgenkeys.service
│   ├── sshd.service -> /usr/lib/systemd/system/sshd.service
│   └── vnstat.service -> /usr/lib/systemd/system/vnstat.service
├── network@.service
├── printer.target.wants
│   └── cups.service -> /usr/lib/systemd/system/cups.service
├── sockets.target.wants
│   ├── avahi-daemon.socket -> /usr/lib/systemd/system/avahi-daemon.socket
│   └── cups.socket -> /usr/lib/systemd/system/cups.socket
└── sysinit.target.wants

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"

/sbin/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
/etc/apcupsd/apcupsd.conf
UPSCABLE usb
UPSTYPE usb
DEVICE /dev/usb/hid/hiddev[0-9]
LOCKFILE /var/lock
SCRIPTDIR /etc/apcupsd
PWRFAILDIR /etc/apcupsd
NOLOGINDIR /etc
ONBATTERYDELAY 6
BATTERYLEVEL 50
MINUTES 5
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0

heirloom-mailx

/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.reboot" ||
        action.id == "org.freedesktop.login1.hibernate" ||
        action.id == "org.freedesktop.login1.suspend") {
        return "no";
    }
});

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

filesystem

i686

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

/dev/sda5              none          swap      defaults 0 0

/dev/sda2              /             ext4      noatime,nodev 0 1
/dev/sda6              /var          ext4      noatime,nosuid,nodev 0 2
/dev/sda8              /home         ext4      noatime,nosuid,nodev 0 2

/dev/sda10             /data/data0   xfs       ro,noatime,nosuid,nodev,noexec 0 2
/dev/sda11             /data/data1   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2
/dev/sda12             /data/data2   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2

/dev/sdb1              /data/data3   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2

x86_64

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

/dev/sda5              none          swap      defaults 0 0

/dev/sda3              /             ext4      noatime,nodev 0 1
/dev/sda7              /var          ext4      noatime,nosuid,nodev 0 2
/dev/sda9              /home         ext4      noatime,nosuid,nodev 0 2

/dev/sda10             /data/data0   xfs       ro,noatime,nosuid,nodev,noexec 0 2
/dev/sda11             /data/data1   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2
/dev/sda12             /data/data2   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2

/dev/sdb1              /data/data3   xfs       ro,noatime,nosuid,nodev,noexec,noauto 0 2

kmod

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

xorg-server

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

xorg-xinit

/etc/X11/xinit/xserverrc
#!/bin/sh

vt=$(fgconsole) && exec /usr/bin/X -nolisten tcp "vt$vt" "$@"
/etc/udev/rules.d/61-x11-key.rules 
ACTION=="remove", GOTO="x11_input_end"

SUBSYSTEM=="input", ENV{ID_INPUT_KEY}=="?*", ENV{xkblayout}="es"

LABEL="x11_input_end"

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]
Architecture = auto

IgnorePkg    = consolekit
IgnorePkg    = pm-utils pm-quirks
IgnorePkg    = linux-headers
IgnorePkg    = handbrake handbrake-cli
IgnorePkg    = nvidia-utils opencl-nvidia

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

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

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

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

¡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
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
sed -i 's|localhost$|localhost archbase|' /tmp/archbase/etc/hosts
ln -s /usr/share/zoneinfo/America/Buenos_Aires /tmp/archbase/etc/localtime
echo 'KEYMAP="es"' > /tmp/archbase/etc/vconsole.conf
echo 'FONT=""' >> /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 /boot/vmlinuz-linux
  APPEND root=LABEL=AB_RAIZ
  INITRD /boot/initramfs-linux.img

LABEL arch-fallback
  LINUX /boot/vmlinuz-linux
  APPEND root=LABEL=AB_RAIZ
  INITRD /boot/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
Modelines for Xorg
  • For default cirrus driver.
  • Aspect Ratio: 4:3 16:10 16:9
  • DotClock below 85.50MHz (max).
(cvt 1280 960 50 ; cvt 1280 800 60 ; cvt 1280 720 65 ; cvt 1152 864 60 ; cvt 1152 720 70 ; cvt 1152 648 80 ; cvt 1024 768 75 ; cvt 1024 640 85 ; cvt 1024 576 85)
Section "Monitor"
        Identifier      "beta"
        HorizSync       10-100
        VertRefresh     10-100
        Modeline "1280x960_50.00"   83.00  1280 1352 1480 1680  960 963 967 991 -hsync +vsync
        Modeline "1280x800_60.00"   83.50  1280 1352 1480 1680  800 803 809 831 -hsync +vsync
        Modeline "1280x720_65.00"   81.75  1280 1352 1480 1680  720 723 728 750 -hsync +vsync
        Modeline "1152x864_60.00"   81.75  1152 1216 1336 1520  864 867 871 897 -hsync +vsync
        Modeline "1152x720_70.00"   80.00  1152 1216 1336 1520  720 723 729 752 -hsync +vsync
        Modeline "1152x648_80.00"   82.75  1152 1216 1336 1520  648 651 656 681 -hsync +vsync
        Modeline "1024x768_75.00"   82.00  1024 1088 1192 1360  768 771 775 805 -hsync +vsync
        Modeline "1024x640_85.00"   77.75  1024 1088 1192 1360  640 643 649 675 -hsync +vsync
        Modeline "1024x576_85.00"   69.25  1024 1080 1184 1344  576 579 584 608 -hsync +vsync
EndSection

Section "Screen"
        Identifier      "alfa"
        Monitor         "beta"
EndSection
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 eth0
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 eth0
ip addr add 192.168.0.77/24 broadcast + dev br0
ip route add default via 192.168.0.1