Title: debian 
Subject: This is a tail of my new-bee Debian experience with apt.
##############################################
Download Debian iso with jigdo:
    Jigsaw Download homepage:   
    Debian CD images via jigdo: 
    Written by Richard Atterer:  atterer.net>
##############################################
A program called alian can convert rpm's to .deb packages
##############################################
Cool tips: http://linuxmafia.com/pub/linux/debian-tips
##############################################
  List all packages starting with work apache2
	debian1:/etc/apache2# dpkg --list apache2*    
  List files supplied by package
        debian1:/etc/apache2# dpkg -L php4-cgi
##############################################
Nightly upgrade:
   Just update and download new packages each night, 
   and clear out useless .deb from /var/lib/dpkg/archive
     apt-get update && \
     apt-get -y --download-only dist-upgrade && \
     apt-get autoclean
   Later install
     atp-get dist-upgrade 
##############################################
Update system after new install
   #  To find the fastest mirror in North America for testing, run
   apt-spy -d testing -a north-america    
   #  Update list of current package version numbers
   apt-get update 
   #  Update pacakges that are installed on the system to current verison
   atp-get dist-upgrade
##############################################
Dangerouse:
     apt-get update           # upgrade list of current versions
     apt-get -u dist-upgrade  # also install new packages added to the dist
##############################################
  Found a great link for administering Debian
    http://developers.coedit.net/UserModeLinux
       p Learning how to use apt I ran an 
          # stop after 10 servers, specify paths to files, grab new mirrors from http.us.debian.org
          apt-spy -e 10 -c /etc/apt-spy.conf -m /var/lib/apt-spy/mirrors.txt -o /etc/apt/sources.list update 
          apt-get update
          apt-get upgrade
      which of course died at a funny point
      (complaining that the pcmcia socket in use).  
      Now most apt-* programs die with this error:
        apt-get 
          apt-get: error while loading shared libraries: /usr/lib/libapt-pkg-libc6.3-5.so.3.3: invalid ELF header
      ------------------------------------------------------
      I downloaded a new apt package from a debian ftp site, and installed:
        wget http://ftp.debian.skynet.be/ftp/debian/pool/main/a/apt/apt_0.6.25_i386.deb
        dpkg -i apt_0.6.25_i386.deb
      ------------------------------------------------------
      but dpkg errors about /var/lib/dpkg/available corruption. 
        dpkg -l
          dpkg-query: parse error, in file `/var/lib/dpkg/available' near line 157037:
          field name `menu' must be followed by colon
      ------------------------------------------------------
      I edited /var/lib/dpkg/available, to find a binary section (bunch of
      @'s), so I deleted the binary line (before making a local backup). Now I
      need a new /var/lib/dpkg/available! Oh great.
      ------------------------------------------------------
      I created an empty /var/lib/dpkg/available, and ran an update
          rm -rf /var/lib/dpkg/available
          touche /var/lib/dpkg/available
          dpkg --update-avail /var/lib/dpkg/available
      ------------------------------------------------------
      Then I installed the new apt package I got from a debian ftp site.
          dpkg -i apt_0.6.25_i386.deb
      ------------------------------------------------------
      Now dpkg and apt-get work!
      I ran an update and upgrade again:
          apt-get update
          apt-get -u upgrade -f 
      ------------------------------------------------------
      The upgrade died again (complaining that the pcmcia socket in use), but
      apt-get still works:
      
      /etc/init/network stop
      /etc/init/pcmcia stop
      ------------------------------------------------------
      This time I killed all network connections and reran the update.
          apt-get update
          apt-get -u upgrade -f 
      ------------------------------------------------------
      This time it completed without error! Ya! But some packages did not
      upgrade:
        The following packages have been kept back: 
        abiword-common abiword-gnome apt-spy bind9-host bzflag classpath discover dnsutils emacs21 emacs21-common evolution gdm
        gedit gimp1.2 gksu gnome-core gnome-media gnome-office gnomemeeting gnucash gnumeric gnuplot gpdf grip gs gtkhtml3.0
        gucharmap guessnet guile-1.6-libs libdiscover1 libgal2.0-common libglut3 libgnomeprint2.2-0 libgnomeprint2.2-data
        libgnomeprintui2.2-0 libgtksourceview1.0-0 libplplot9 libsane libxine1 ltrace motor mzscheme nautilus-cd-burner
        nautilus-media openoffice.org openoffice.org-bin openoffice.org-debian-files openoffice.org-l10n-en pdl planner r-base
        r-base-core rhythmbox tasksel vorbis-tools wing wing-data xblast 
        
        0 upgraded, 0 newly installed, 0 to remove and 58 not upgraded.
      ------------------------------------------------------
      I got many of the 'kept back' packages to install with this:
         apt-get -o Debug::pkgProblemResolver=yes dist-upgrade 
      
      ------------------------------------------------------
      This appeared to start working and then failed with the error:
      
         Errors were encountered while processing:
         /var/cache/apt/archives/classpath-common_2%3a0.12-1_all.deb
         E: Sub-process /usr/bin/dpkg returned an error code (1)
      ------------------------------------------------------
      So I tried to debug just the install of classpath-common
        apt-get -o Debug::pkgProblemResolver=yes upgrade classpath-common -f
      ------------------------------------------------------
      Almost there, but synaptic will not install due to a dependency on libapt-pkg-libc6.3-5-3.3
        apt-get install synaptic
          synaptic: Depends: libapt-pkg-libc6.3-5-3.3
      ------------------------------------------------------
      Found the library belongs to apt
        dpkg -S /usr/lib/libapt-pkg-libc6.3-5.so.3.5*
          apt: /usr/lib/libapt-pkg-libc6.3-5.so.3.5
          apt: /usr/lib/libapt-pkg-libc6.3-5.so.3.5.0
      ------------------------------------------------------
      Found the version of apt
        dpkg -l |grep apt
          ii  apt            0.6.25         Advanced front-end for dpkg
      ------------------------------------------------------
      show that apt provides libapt-pkg-libc6.3-5-3.3
        apt-cache show apt 
      ------------------------------------------------------
      The apt package is installed but the dependency is still not met.
      So I check for the version listed in my cache:
        find /var/cache/apt/archives/ -name "apt*"
          /var/cache/apt/archives/apt_0.5.27_i386.deb
      ------------------------------------------------------
      I installed the version in the cache
        dpkg -i /var/cache/apt/archives/apt_0.5.27_i386.deb
      ------------------------------------------------------
      Finally all is installed and updated.
##############################################
# Download debian ISO:
#----------------------  
 1. Get jigdo-lite from:         http://atterer.net/jigdo/#download
 2. For CD and DVD images, see:  http://www.debian.org/CD/jigdo-cd/
    
     Found:  http://us.cdimage.debian.org/jigdo-area/3.0_r4-cd/jigdo/
 3. Unpack jigdo
       tar -zxvpf /home/jstile/jigdo-bin-0.7.1.tar.bz2
       cd jigdo-bin-0.7.1/
 4. Run jigdo
       ./jigdo-lite 
       Enter mirror for jigdo: http://us.cdimage.debian.org/jigdo-area/3.0_r4-cd/jigdo/i386/woody-i386-{1_NONUS,1,2,3,4,5,6,7}.jigdo
       Files to scan: 
       Debian mirror: us
       Debian mirror: http://ftp.keystealth.org/debian/
       Debian non-US mirror: ca
       Debian non-US mirror: http://mirror.peer1.net/debian-non-US/
 5.  You should have some ISO's to burn
#####################################################
# From within kde, regular user can't eject the cdrom 
#----------------------  
      ls -alF /bin/{u,}mount
          -rwsr-xr-x  1 root root 76888 Sep 23 21:34 /bin/mount*
          -rwsr-xr-x  1 root root 39960 Sep 23 21:34 /bin/umount*
      Google: debian kde eject cdrom fails
      http://lists.debian.org/debian-user/2003/12/msg03445.html
        Can't eject my CDROM as a normal use or using the eject command.
        But I can mount.
          ls -l /dev/hdc
            brw-rw----  1 root disk 22, 0 Mar 23  2004 /dev/hdc
          chown root:cdrom /dev/hdc
          ls -l /dev/hdc
            brw-rw---- 1 root cdrom 22, 0 Mar 14 2002 /dev/hdc
        Add user to cdrom group (as well as other commonly used groups)
            cdrom:x:24:jstile
            floppy:x:25:jstile 
            audio:x:29:jstile
        Change permissions of eject
          ls -alF /usr/bin/eject
            -rwxr-xr-x  1 root root 18388 Jul 20 16:05 /usr/bin/eject*
          chmod 4755 /usr/bin/eject
          ls -alF /usr/bin/eject
            -rwsr-xr-x  1 root root 18388 Jul 20 16:05 /usr/bin/eject*
   NOTE: details about user gorups:  /usr/share/doc/base-passwd/users-and-groups.html
######################################################
# 2005-03-27 jstile: 
# Transplanted debian system from a ide desktop to a scsi desktop.
## Steps I didn't document:
# Downloaded and burned knopix iso to CD
# Booted with knopix
# mount scsi and ide disks
# fdisk to create partitions
# mkreiserfs
# mkext3
# Mounted the scsi disks
# rsync -avz / /
update-grub
grub-install /dev/sda
vi /etc/fstab
cat /etc/modules
vi /etc/modules
 	add 'aic7xxx'
man dpkg-reconfigure
apt-cache search 'kernel-image'   
dpkg -S /boot/vmlinuz-2.4.25-1-386
	
	kernel-image-2.4.25-1-386: /boot/vmlinuz-2.4.25-1-386
dpkg-reconfigure kernel-image-2.4.25-1-386
	/usr/sbin/mkinitrd: neither /dev/fd or /proc/self/fd exists!
	Try mounting the proc filesystem: mount -tproc none /proc
	Failed to create initrd image.
 
mount /proc
dpkg-reconfigure kernel-image-2.4.25-1-386
	Not touching initrd symlinks since we are being reinstalled (2.4.25-1)
	Not updating image symbolic links since we are being updated (2.4.25-1)
	Searching for GRUB installation directory ... found: /boot/grub .
	Testing for an existing GRUB menu.list file... found: /boot/grub/menu.lst .
	Searching for splash image... none found, skipping...
	Found kernel: /vmlinuz-2.4.25-1-386
	Updating /boot/grub/menu.lst ... done
######################################################
Setup apache2 with mod_php4 the debian way:
# List Installed php stuff
  dpkg --list |grep php
           
# Remove All php stuff
  dpkg -B --remove php4-cgi php4-cli php4-common php4-curl php4-domxml php4-gd php4-imagick php4-imap php4-ldap php4-mcal php4-mcrypt php4-mhash php4-mysql php4-pear php4-pgsql php4-snmp php4-xslt phpmyadmin phpsysinfo   
  dpkg -B --purge php4-cgi php4-cli php4-common php4-curl php4-domxml php4-gd php4-imagick php4-imap php4-ldap php4-mcal php4-mcrypt php4-mhash php4-mysql php4-pear php4-pgsql php4-snmp php4-xslt phpmyadmin phpsysinfo        
# List Installed apache stuff
 dpkg --list |grep apache
# Remove All apache stuff
 apt-get -o Debug::pkgProblemResolver=yes remove --purge apache-common apache-utils apache2-doc apache2-utils libapache2-svn  apache2-utils libapache2-mod-jk2
 apt-get -o Debug::pkgProblemResolver=yes remove --purge libapache2
 apt-get -o Debug::pkgProblemResolver=yes remove --purge libapache2*	    
 apt-get -o Debug::pkgProblemResolver=yes autoclean	   
# List Dependencies for mod_php
 apt-cache depends libapache2-mod-php4  
 apt-cache show    libapache2-mod-php4	
# Install Apache2, apche2-mpm-prefork, mod_php4, php4-common
 apt-get -o Debug::pkgProblemResolver=yes install -f libapache2-mod-php4 apache2-mpm-prefork apache2 php4-common libbz2-1.0 libc6 libcomerr2 libdb4.2 libexpat1 libkrb53 libpcre3 libssl0.9.7 libzzip-0-12 zlib1g mime-support   
# Filesystem layout should look like this after install
 grep -rn php /etc/apache2/{sites,mods}-enabled /etc/apache2/apache2.conf
	/etc/apache2/mods-enabled/php4.conf:1:
	/etc/apache2/mods-enabled/php4.conf:2:  AddType application/x-httpd-php .php .phtml .php3
	/etc/apache2/mods-enabled/php4.conf:3:  AddType application/x-httpd-php-source .phps
	/etc/apache2/mods-enabled/php4.load:1:LoadModule php4_module /usr/lib/apache2/modules/libphp4.so
	/etc/apache2/apache2.conf:202:DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
	/etc/apache2/apache2.conf:334:#AddType application/x-httpd-php .php
	/etc/apache2/apache2.conf:335:#AddType application/x-httpd-php-source .phps
#########################
# Found a basic problem:
#   My script had incorrect php syntax
#    correct syntax for phpinfo.php
######################### 
      	# WRONG info.php test script
      	
	
      	# CORRECT info.php test script
      	
 
# Install extra php stuff
aptitude install  php4-curl php4-domxml php4-gd php4-imagick php4-imap php4-ldap php4-mcal php4-mcrypt php4-mhash php4-mysql php4-pear php4-pgsql php4-snmp php4-xslt phpmyadmin phpsysinfo
######################################################
# Configure ssl cert for apache2, the debian way
#NOTE: this doesn't acutlly work yet...
#   the server is listening on 443, but i don't see
#   a warning about an invalid certificate.
# for this I followed notes from :http://www.ilovett.com/node/126/
  apt-get -o Debug::pkgProblemResolver=yes -f install apache2-ssl
  apache2-ssl-certificate 
  cp /usr/share/doc/apache2/examples/ssl-std.conf.gz /etc/apache2/sites-available/
  gzip -d /etc/apache2/sites-available/ssl-std.conf.gz
  a2ensite ssl-std.conf
  a2enmod ssl
  vi /etc/apache2/mods-enabled/ssl.conf
   Add:
    SSLCertificateFile    ssl/apache.pem
    SSLCertificateKeyFile ssl/apache.pem 
  vi /etc/apache2/ports.conf
   Add:
    Listen 443
  
  vi /etc/apache2/sites-enabled/000-default
   Change:
    NameVirtualHost *
   To:
    NameVirtualHost *:80
    NameVirtualHost *:443
  /etc/init.d/apache2 reload
  lsof -i tcp |grep apa
    apache2    2247     root    3u  IPv4 180628       TCP *:www (LISTEN)
    apache2    2247     root    4u  IPv4 180629       TCP *:https (LISTEN)
    apache2    2253 www-data    3u  IPv4 180628       TCP *:www (LISTEN)
    apache2    2253 www-data    4u  IPv4 180629       TCP *:https (LISTEN)
    apache2    2254 www-data    3u  IPv4 180628       TCP *:www (LISTEN)
    apache2    2254 www-data    4u  IPv4 180629       TCP *:https (LISTEN)
    apache2    2255 www-data    3u  IPv4 180628       TCP *:www (LISTEN)
    apache2    2255 www-data    4u  IPv4 180629       TCP *:https (LISTEN)
    apache2    2256 www-data    3u  IPv4 180628       TCP *:www (LISTEN)
    apache2    2256 www-data    4u  IPv4 180629       TCP *:https (LISTEN)
    apache2    2257 www-data    3u  IPv4 180628       TCP *:www (LISTEN)
    apache2    2257 www-data    4u  IPv4 180629       TCP *:https (LISTEN)
######################################################
#  Compile Kernel (debian way) 
#  to add with dma and i2c support
#
#  Reference: http://www.groupedia.com/node/view/126
######################################################
# Try to set dma manually
debian1:/# hdparm -d1 /dev/hda
   /dev/hda:
    setting using_dma to 1 (on)
    HDIO_SET_DMA failed: Operation not permitted
    using_dma	 =  0 (off)
# test the speed
debian1:/# hdparm -Tt /dev/hda
   /dev/hda:
    Timing cached reads:   496 MB in  2.01 seconds = 246.77 MB/sec
    Timing buffered disk reads:   14 MB in  3.20 seconds =   4.38 MB/sec
 debian1:~# lspci -v 
   0000:00:07.1 IDE interface: Intel Corp. 82371AB/EB/MB PIIX4 IDE (rev 01) (prog-if 80 [Master])
        Flags: bus master, medium devsel, latency 32
        I/O ports at f000 [size=16]
   0000:00:07.3 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ACPI (rev 02)
        Flags: medium devsel, IRQ 9
# Checked the settings, and dma support is loaded as a module
 aptitude install kernel-source-2.4.25-1-386 
 apt-get install -f lm-sensors-source    
 apt-cache show  i2c-source lm-sensors-source module-assistant
 cd /usr/src/
 tar -jxvpf kernel-source-2.4.25.tar.bz2
 cd kernel-source-2.4.25/
 aptitude install ncurses ncurses-dev
 cp /boot/config-2.4.25-1-386 .config
 make mrproper   # install all the modules correctly 
 make oldconfig  # upgrade .config to current available modules
 make menuconfig
  IDE, ATA and ATAPI Block devices  --->  
  # Enable IDE as Y not as module
  # Enable "Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support" as Y not as module
  # Enable "Intel PIIXn chipsets support" as Y not as module 
  # Also, I put reiserfs, msdos, and vfat as Y instead of modules.
 
  # char device->I2C->i2C support -> Y
  # char device->I2C->I2C device interface
  # char device->I2C->I2C /proc interface
  # char device->Watchdog Cards->
 make dep
# backup my boot
 rsync -avz /boot/ /boot.bak
# Compile the kernel 
 make-kpkg --initrd --rev Custom.0 kernel_image
# install
 dpkg --install /usr/src/kernel-image-2.4.25_Custom.0_i386.deb
######################################################
# kernel upgrade again to 2.4.27
######################################################
apt-get -u dselect-upgrade
 aptitude install kernel-source-2.4.27
 aptitude install kernel-package
 mkdir /root/kernel_build
 cd /root/kernel_build
 tar -xjvf /usr/src/kernel-source-2.4.27.tar.bz2
 cd kernel-source-2.4.27/
 cp /boot/config-2.4.25-1-386 .config
 make oldconfig
 
 make menuconfig
   # add reiserfs support
   File systems  ---> 
   	<*> Reiserfs support  
   # Enable IDE as Y not as module
   ATA/IDE/MFM/RLL support  ---> 
   	<*> ATA/IDE/MFM/RLL support  
   
   # Enable "Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support" as Y not as module
   ATA/IDE/MFM/RLL support  ---> 
   	<*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support 
  
   # Enable "Intel PIIXn chipsets support" as Y not as module 
   ATA/IDE/MFM/RLL support  ---> 
   	IDE, ATA and ATAPI Block devices  --->
		<*>     Intel PIIXn chipsets support
   # Save and exit
 # Compile kernel
 make-kpkg --initrd --rev Custom.0 kernel_image 
 # Install the kernel
 dpkg --install /root/kernel_build/kernel-image-2.4.27_Custom.0_i386.deb
########################
# To Remove kernel, run this:
#     dpkg --remove kernel-image-2.4.27
# Test the hdparm stuff:
hdparm -d0 /dev/hda
    /dev/hda:
     setting using_dma to 0 (off)
     using_dma    =  0 (off)
hdparm -Tt /dev/hda
    /dev/hda:
     Timing cached reads:   472 MB in  2.00 seconds = 236.00 MB/sec
     Timing buffered disk reads:   14 MB in  3.15 seconds =   4.44 MB/sec
hdparm -d1 /dev/hda
    /dev/hda:
     setting using_dma to 1 (on)
     using_dma    =  1 (on)
hdparm -Tt /dev/hda
    /dev/hda:
     Timing cached reads:   492 MB in  2.01 seconds = 244.78 MB/sec
     Timing buffered disk reads:   52 MB in  3.09 seconds =  16.83 MB/sec
 
######################################################
After installing a server, DISPLAY variable does not set when I ssh in.
Error: debian Warning: No xauth data
Problem:  need to install the program that supplies the file xauth
     aptitude install xbase-clients
######################################################
20050815 jstile:  man -k fails to find matching man pages
Fix: rebuild makewhatis databaes with:
       mandb -c 
######################################################
20060315 jstile: Need forcedeth driver for 2 onboard Nvidia nics...
But debian kernel ( 2.6.8 ) has broken forcedeth driver.
Creating custom kernel debian package from kernel.org source
 # Download the latest kernel:
 cd /usr/src
 wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.15.6.tar.bz2
 tar -jxf linux-2.6.15.6.tar.bz2
 cd linux-2.6.15.6
 # Build the kernel and package
 fakeroot make-kpkg  \
    --append_to_version "-sata_nv.forcedeth.reiserfs" \
    -revision="01" \
    --config menuconfig \
    kernel-image modules-image
 # I read that SCSI support cannot be a module when booting from Sata drives.
 # And I have a sata_nv controler, reiserfs file system, and nvidia nic.
    Device Drivers ->
      SCSI device support ->
	<*> SCSI device support
	<*> SCSI disk support
	SCSI low-level drivers ->
	  <*> NVIDIA SATA support
      Network device support ->
	<*> Network device support
	Ethernet (10 or 100Mbit) -->
	  <*>  Reverse Engineered nForce Ethernet support (EXPERIMENTAL)
    File Systems ->
      <*> Ext3 journaling file system support
      <*> Reiserfs support
  dpkg -i ../linux-image-2.6.15.6_2.6.15.6-10.00.Customi386.deb
######################################################
200603015 jstile: Now that i've got my custom kernel, I want a console server on my serial port.
  vi /boot/grub/menu.lst
     # To global section
     serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
     terminal --timeout=10 serial console
     # To the kernel line, append: 
     "console=tty0 consol=ttyS0,9600n8"
   # start a getty on the serial port
   vi /etc/inittab
     T0:23:respawn:/usb/getty -L ttyS0 9600 vt100
   # In the bios, also  set console redirect to serial port
######################################################
20060315 jstile: Dump your installed package list to a file and read it back:
 # Dump: 
 dpkg --get-selections "*" > myselections.orig
 # Install everything in package list
 dpkg --set-selections < myselections
######################################################
20061213 jstile: Install 3ware cli and web utils for 9550sx controller.
echo 'deb http://ftp.debian-unofficial.org/debian sarge main contrib non-free restricted' >> /etc/apt/sources.list
echo 'deb-src http://ftp.debian-unofficial.org/debian sarge main contrib non-free restricted' >> /etc/apt/sources.list
aptitude update
aptitude install 3ware-cli-binary
aptitude install 3ware-3dm2-binary
tw_cli
//mother> info
   Ctl   Model        Ports   Drives   Units   NotOpt   RRate   VRate   BBU
   ------------------------------------------------------------------------
   c0    9550SX-4LP   4       4        2       0        4       4       -
//mother> info c0
  Unit  UnitType  Status         %Cmpl  Stripe  Size(GB)  Cache  AVerify  IgnECC
  ------------------------------------------------------------------------------
  u0    RAID-1    OK             -      -       111.748   ON     OFF      OFF
  u1    RAID-1    OK             -      -       279.387   OFF    OFF      OFF
  Port   Status           Unit   Size        Blocks        Serial
  ---------------------------------------------------------------
  p0     OK               u0     111.79 GB   234441648     4MS0H48L
  p1     OK               u0     111.79 GB   234441648     4MS0H3CE
  p2     OK               u1     279.46 GB   586072368     4NF1ZMDA
  p3     OK               u1     279.46 GB   586072368     4NF1ZGX0
//mother> info c0 u0
  Unit     UnitType  Status         %Cmpl  Port  Stripe  Size(GB)  Blocks
  -----------------------------------------------------------------------
  u0       RAID-1    OK             -      -     -       111.748   234352640
  u0-0     DISK      OK             -      p1    -       111.748   234352640
  u0-1     DISK      OK             -      p0    -       111.748   234352640
# If I evern have to rebuild a raid, it goes something like this:
#  If 'tw_cli info c0 u0'  shows DEGRADED, the mirror has issues.
 # 1. Remove the drive
   tw_cli maint remove c0 p1
 # 2. If Rescanning drive results in N/A, drive is bad, replace
   tw_cli maint rescan c0
 # 3. Rebuilding the drive
   tw_cli maint rebuild c0 u0 p1
 # 4. Check status
  tw_cli info c0 u0
######################################################