github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/Doc/BuildingInitRamFs.txt (about)

     1  Instructions for preparing initramfs for FileClient and FileServer
     2  ==================================================================
     3  
     4  Decompress and unpack the existing initramfs
     5      cd /tmp
     6      mkdir init
     7      cd init
     8      cp /boot/initramfs.img-`uname -r` initrd.gz
     9      gunzip -c -9 initrd.gz | cpio -i -d -H newc --no-absolute-filenames
    10  
    11  Copy the dynamic link libraries for the executables into the filesystem
    12  for i in `ldd /home/jlm/jlmcrypt/fileServer.exe | cut -d' ' -f3 | sed 's/^\s*//g' | egrep -v '^\s*$'`; do
    13      source=$i
    14      dir=`dirname $i`
    15      mkdir -p $dir
    16      dest=`echo $i | sed 's?^/??g'`
    17      echo "Copying $source to $dest"
    18      cp $source $dest
    19  done
    20  
    21  Copy the runtime directory into the filesystem, and get ifconfig, too
    22      mkdir -p home/jlm/jlmcrypt
    23      cp -r /home/jlm/jlmcrypt/* home/jlm/jlmcrypt/
    24      cp /sbin/ifconfig sbin/ifconfig
    25  
    26  You might want to clean out some of the unnecessary files here.
    27  
    28  Change the initscript (init) to run dmcrypt and change the way the 
    29  system disk is mounted.
    30    vim init
    31  
    32  Here is a simple script that works:
    33  
    34  -- start simple script
    35  
    36  #!/bin/sh
    37  
    38  [ -d /dev ] || mkdir -m 0755 /dev
    39  [ -d /root ] || mkdir -m 0700 /root
    40  [ -d /sys ] || mkdir /sys
    41  [ -d /proc ] || mkdir /proc
    42  [ -d /tmp ] || mkdir /tmp
    43  mkdir -p /var/lock
    44  mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
    45  mount -t proc -o nodev,noexec,nosuid proc /proc
    46  # Some things don't work properly without /etc/mtab.
    47  ln -sf /proc/mounts /etc/mtab
    48  
    49  grep -q '\<quiet\>' /proc/cmdline || echo "Loading, please wait..."
    50  
    51  # Note that this only becomes /dev on the real filesystem if udev's scripts
    52  # are used; which they will be, but it's worth pointing out
    53  if ! mount -t devtmpfs -o mode=0755 udev /dev; then
    54  	echo "W: devtmpfs not available, falling back to tmpfs for /dev"
    55  	mount -t tmpfs -o mode=0755 udev /dev
    56  	[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
    57  	[ -e /dev/null ] || mknod /dev/null c 1 3
    58  fi
    59  mkdir /dev/pts
    60  mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
    61  mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
    62  mkdir /run/initramfs
    63  # compatibility symlink for the pre-oneiric locations
    64  ln -s /run/initramfs /dev/.initramfs
    65  
    66  /sbin/ifconfig lo 127.0.0.1
    67  # can set up other networks here as needed, e.g., on eth0
    68  
    69  # mount /boot as a place to put keys between reboots (e.g., for tcService.exe)
    70  mkdir /boot
    71  mount /dev/sda1 /boot
    72  
    73  /bin/busybox sh
    74  
    75  -- end simple script
    76  
    77    - untested:
    78        swapoff -a
    79        cryptsetup [-c aes -h sha256] -s 128 -d /dev/urandom create swap /dev/sda1
    80        mkswap /dev/mapper/swap
    81        swapon /dev/mapper/swap
    82  
    83  Put initramfs back together
    84          find . | cpio -H newc -o|gzip -9 > ../initrd.img-new
    85  
    86  Copy it to the boot directory
    87    sudo cp initrd.gz /boot/initrd.img-staticLinux
    88  
    89  Change /etc/grub.d to use this new initramfs.
    90  
    91  Consult: http://manpages.ubuntu.com/manpages/karmic/man8/initramfs-tools.8.html
    92  
    93  mkdir initramfs{,-old}
    94   cd initramfs
    95   gunzip -c -9 /boot/initrd.img-2.6.32-5-686 \
    96    | cpio -i -d -H newc --no-absolute-filenames
    97   find > ../initramfs.content
    98   cd ../initramfs-old
    99   gunzip -c -9 /boot/initrd.img-2.6.32-5-686.bak \
   100    | cpio -i -d -H newc --no-absolute-filenames
   101   find > ../initramfs-old.content
   102   cd ..
   103   diff -u initramfs-old.content initramfs.content
   104  
   105  A sample init that dynamically loads the driver (don't do this) is:
   106   1 Decompress initrd into localdirectory
   107   2 Copy needed drivers in /drvs directory
   108   3 Copy fileProxy/fileClient/tcService binaries in /bin directory and required libraries in 
   109       lib and lib64 directories
   110   4 Copied keys to /bin/HWRoot directory
   111   5 Replaced init with my custom init
   112   6 Loaded tcioDD
   113   7 Configured Ethernet
   114   8 Script does not boot all services
   115   9 Package initramfs.igz
   116  10 Copy to /boot
   117  11 Modify entry for OS Tboot section in grub.cfg. replaced initrd by initramfs.igz
   118  12 Reboot machine
   119  13 From cmd line type : /bin/tcService.exe –directory /bin/ &
   120  14 tcService connected to keynegoServer on different machine.