Preparing a Debian/Ubuntu mirror for Kabul

Jurjen Bokma

January 2013


How to configure a Debian/Ubuntu mirror that is to be taken to Kabul.

Table of Contents

For a programme to promote Open Source Awareness in Afghanistan, a colleague of mine will travel to Kabul University to teach general ICT security. For his workshops he needs an Ubuntu mirror, and likely a Debian mirror too.

Problem is: Afghanistan doesn't seem to have such a mirror. And the 800-or-so GB of a combined debian/ubuntu mirror would take about 71 hours to download, if my figures on available bandwidth still apply. Downloading only during the night so as not to hinder people reading mail, that would translate to nine days or so.

OTOH, a traveller from Europe with a one TB hard disk in their luggage may fly to Afghanistan in 10 hours (airport hassle included), and thereby transfer 27 MByte/s. Awful latency, but good bandwidth.

Preparing the external disk for boot

Procedure 9.  Put Debian on an external harddisk
  1. Connect the disk to a USB port and power it up. Then put a partition table on it. Mine looks like this:

    sudo fdisk -l /dev/sdc

    Disk /dev/sdc: 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: 0x95db3a6d

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1   *        2048     1026047      512000   83  Linux
    /dev/sdc2         1026048   210741247   104857600    5  Extended
    /dev/sdc3       210741248  3907029167  1848143960   83  Linux
    /dev/sdc5         1028096   126857215    62914560   83  Linux
    /dev/sdc6       126859264   168802303    20971520   83  Linux
    /dev/sdc7       168804352   189775871    10485760   83  Linux
    /dev/sdc8       189777920   193972223     2097152   83  Linux

  2. apprentice@pc:sudo mkswap -L swap /dev/sdc8
    apprentice@pc:sudo mkfs.ext4 -L root /dev/sdc5
    apprentice@pc:sudo mkfs.ext4 -L var /dev/sdc6
    apprentice@pc:sudo mkfs.ext4 -L tmp /dev/sdc7
    apprentice@pc:sudo mkfs.ext4 -L boot /dev/sdc1
    apprentice@pc:sudo mkfs.ext4 -L srv /dev/sdc3

  3. apprentice@pc:sudo mount LABEL=root /mnt/target/
    apprentice@pc:for i in var tmp boot srv ; do sudo install -d /mnt/target/$i && sudo mount LABEL=$i /mnt/target/$i ; done
    apprentice@pc:sudo debootstrap --arch i386 wheezy /mnt/target/
    apprentice@pc:for i in proc sys dev ; do sudo mount -o bind /$i /mnt/target/$i ; done

  4. apprentice@pc:sudo -s
    root@pc:/home/apprentice# chroot /mnt/target/
    root@pc:/# apt-get install debian-keyring locales emacs sudo linux-image-amd64 openssh-server postfix
    root@pc:/# echo "afmirror" > /etc/hostname
    root@pc:/# touch /etc/mtab
    root@pc:/# adduser sysadmin
    root@pc:/# passwd # for root

    Also add the user to /etc/sudoers

    And create /mnt/target/etc/fstab like the following:

    # Handcrafted fstab by Apprentice
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    UUID="73ea4561-87ae-49f2-ad83-bb072cd92e64"   /       ext4       errors=remount-ro          0     1
    UUID="03d7912b-7fc7-4655-8880-bb7f554ea215"   /boot   ext4       defaults                   0     2
    UUID="01b8ce4f-c19e-4822-9034-88e854d05b90"   /var    ext4       defaults                   0     2
    proc                                          /proc   proc       nodev,noexec,nosuid        0     0
    UUID="e6a434da-2a24-4f9a-bbf7-5eb2a4e2bcd1"   /tmp    ext4       defaults                   0     2
    UUID="4bbbc961-bb5e-49b8-a612-f2e3181c4a69"   none    swap       sw                         0     0
    UUID="93075563-dc88-451f-881a-a84046a89249"   /srv    ext4       defaults                   0     2
    /dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0

  5. root@pc:/# apt-get install grub2


    Although we 're in the chroot, /dev is bindmounted from the 'parent' host, so you almost certainly don't want to install to /dev/sda. I install the bootsector onto (the MBR of) /dev/sdc.


  6. root@pc:/home/apprentice# sync
    root@pc:/home/apprentice# while mount|grep -q /target ; do umount $(mount|grep /target|tail -1|awk '{print $3}') ; done