Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- casper.orig 2012-05-17 12:48:23.786986671 -0400
- +++ casper 2012-05-17 13:19:54.204228445 -0400
- @@ -142,6 +142,13 @@ is_nice_device() {
- return 1
- }
- +# Load zram if not loaded
- +load_zram() {
- + if [ ! -b /dev/zram0 ]; then
- + modprobe zram zram_num_devices=4
- + fi
- +}
- +
- copy_live_to() {
- copyfrom="${1}"
- copytodev="${2}"
- @@ -151,11 +158,22 @@ copy_live_to() {
- if [ "${copytodev}" = "ram" ]; then
- # copying to ram:
- - freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
- - mount_options="-o size=${size}k"
- + freespace=$(awk '/^MemTotal:/{f=$2} END{print f / 2}' /proc/meminfo)
- + mount_options=""
- free_string="memory"
- - fstype="tmpfs"
- - dev="/dev/shm"
- + fstype="ext2"
- + # zram0 reserved for swap, so use zram1
- + dev="/dev/zram1"
- + # Load if not loaded
- + load_zram
- + # If we didn't load enough, that's a problem
- + if [ ! -b "${dev}" ]; then
- + [ "$quiet" != "y" ] && log_warning_msg "${dev} is not a block device (zram loaded without zram_num_devices high enough?)."
- + return 1
- + fi
- + # Because of file system overhead, add 10%
- + echo $(( freespace * 1024 * 11 / 10 )) > /sys/block/zram1/disksize
- + mkfs.ext2 "${dev}"
- else
- # it should be a writable block device
- if [ -b "${copytodev}" ]; then
- @@ -425,10 +443,11 @@ setup_unionfs() {
- rofsstring=${rofsstring%:}
- mkdir -p /cow
- - cowdevice="tmpfs"
- - cow_fstype="tmpfs"
- + cowdevice="/dev/zram2"
- + cow_fstype="ext2"
- cow_mountopt="rw,noatime,mode=755"
- +
- # Looking for "${root_persistence}" device or file
- if [ -n "${PERSISTENT}" ]; then
- cowprobe=$(find_cow_device "${root_persistence}")
- @@ -439,6 +458,16 @@ setup_unionfs() {
- else
- [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium"
- fi
- + else
- + # Load if not loaded
- + load_zram
- + # If we didn't load enough, that's a problem
- + if [ ! -b "${cowdevice}" ]; then
- + [ "$quiet" != "y" ] && log_warning_msg "${cowdevice} is not a block device (zram loaded without zram_num_devices high enough?)."
- + return 1
- + fi
- + echo $(( freespace * 1024 )) > /sys/block/zram2/disksize
- + mkfs.ext2 "${cowdevice}"
- fi
- mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || panic "Can not mount $cowdevice on /cow"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement