AUFS-Creation

vim /etc/initramfs-tools/scripts/init-bottom/rootaufs

chmod 755 /etc/initramfs-tools/scripts/init-bottom/rootaufs

#!/bin/sh -e
#
# /etc/initramfs-tools/scripts/init-bottom/rootaufs
#
#
# Thank you Voyage Linux, http://voyage.hk/

# Env. variables used:
# ROOT    : /dev/disk/by-uuid/nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn
# rootmnt : /root

if [ "$1" = "prereqs" ]; then
    exit 0
fi

for x in $(cat /proc/cmdline); do
    case "$x" in
       aufs=*) aufs=${x#aufs=} ;;
    esac
 done

if [ "$aufs" != "tmpfs" ]; then
    # Nothing to do
    exit 0
fi

if ! modprobe -q aufs; then
    echo "No aufs module, ABORT!"
    exit 0
fi

# Make the mount points
mkdir /aufs /rw /ro

# Mount the temp file system and move the real root out of the way
mount -t tmpfs aufs-tmpfs /rw
mount --move ${rootmnt} /ro
mount -t aufs -o dirs=/rw:/ro=ro aufs /aufs

# Make mount points on aufs file system
mkdir -p /aufs/ro /aufs/rw

# Move the real root to /ro and tmpfs to /rw
mount --move /ro /aufs/ro
mount --move /rw /aufs/rw

# Construct a fake fstab for the tmpfs. Start with the original
# and remove the root entry; construct an entry for the the aufs root.

egrep -v ' / | swap |tmpfs' /aufs/ro/etc/fstab >/aufs/etc/fstab

ROOTENT=$(grep ${ROOT} /proc/mounts | awk '{printf "%s %s\n", $3, $4}')
echo ${ROOT} /ro $ROOTENT 0 0 >>/aufs/etc/fstab

mount --move /aufs ${rootmnt}

exit 0

vim /etc/initramfs-tools/modules

add

aufs 

to the last line

vim /etc/default/grub

add aufs=tmpfs

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash aufs=tmpfs"

uncomment recovery mode

GRUB_DISABLE_RECOVERY="true"

vim /etc/grub.d/00_header

edit timeout = 0 (from -1)

update files

invoke-rc.d apparmor stop
update-rc.d -f apparmor remove
apt-get purge apparmor
update-initramfs -u
update-grub

你可能感兴趣的:(IO)