daily pastebin goal
69%
SHARE
TWEET

memfs

a guest Jul 23rd, 2014 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/ash
  2.  
  3. run_latehook() {
  4.    
  5.    # Mount zram/tmpfs/ramfs root
  6.    for memfs in ${memfs//,/ }; do  
  7.    if [ "$memfs" = "tmpfs" ]; then
  8.                 mount -t tmpfs tmpfs /mnt
  9.                
  10.    elif [ "$memfs" = "ramfs" ]; then
  11.                 mount -t ramfs -o size=1024m ramfs /mnt
  12.                
  13.    elif [ "$memfs" = "zram" ]; then
  14.                 modprobe zram num_devices=3
  15.                 echo 1073741824 > /sys/block/zram0/disksize
  16.                 mkfs.ext4 /dev/zram0
  17.                 mount -t ext4 /dev/zram0 /mnt
  18.    fi  
  19.    done
  20.    
  21.                    
  22.    # Unpack rootfs
  23.    msg "Unpacking rootfs..."
  24.    cd /mnt
  25.    
  26.    path=${path//,/ }
  27.    
  28.    for archfs in ${archfs//,/ }; do
  29.    if [ "$archfs" = "xz" ]; then
  30.                 xz -d < /new_root/$path/archfs.xz | cpio -imd --no-absolute-filenames > /dev/null 2>&1
  31.    
  32.    elif [ "$archfs" = "gzip" ]; then
  33.                 gzip -dc /new_root/$path/archfs.gz | cpio -imd --no-absolute-filenames > /dev/null 2>&1
  34.  
  35.    elif [ "$archfs" = "lzo" ]; then
  36.                 lzop -d < /new_root/$path/archfs.lzo | cpio -imd --no-absolute-filenames > /dev/null 2>&1
  37.    
  38.    elif [ "$archfs" = "img" ]; then
  39.                 cpio -imd --no-absolute-filenames /new_root/boot/archfs.img > /dev/null 2>&1
  40.    fi
  41.    done
  42.    
  43.    
  44.    # Switch tmpfs to new root
  45.    umount /new_root
  46.    mount -M /mnt /new_root
  47. }
  48.  
  49. # vim: set ft=sh ts=4 sw=4 et:
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top