Author Archive
Toggle Swap
by dervish on May.02, 2015, under Linux
#!/bin/bash
free_data="$(free)"
mem_data="$(echo "$free_data" | grep 'Mem:')"
free_mem="$(echo "$mem_data" | awk '{print $4}')"
buffers="$(echo "$mem_data" | awk '{print $6}')"
cache="$(echo "$mem_data" | awk '{print $7}')"
total_free=$((free_mem + buffers + cache))
used_swap="$(echo "$free_data" | grep 'Swap:' | awk '{print $3}')"
echo -e "Free memory:\t$total_free kB ($((total_free / 1024)) MB)\nUsed swap:\t$used_swap kB ($((used_swap / 1024)) MB)"
if [[ $used_swap -eq 0 ]]; then
echo "Congratulations! No swap is in use."
elif [[ $used_swap -lt $total_free ]]; then
echo "Freeing swap..."
sudo swapoff -a
sudo swapon -a
else
echo "Not enough free memory. Exiting."
exit 1
fi
Scott Severance from askubuntu.com
映画『攻殻機動隊 新劇場版』
by dervish on Apr.29, 2015, under Uncategorized
攻殻機動隊、その起源。草薙素子、出生の秘密。世界に衝撃を与えた「攻殻機動隊」の全てが明かされる――原作:士郎正宗 総監督:黄瀬和哉 脚本:冲方丁 音楽:コーネリアス キャスト:坂本真綾 他 制作:プロダクションI.G 2015年6月20日(土)全国ロードショー
Source: 映画『攻殻機動隊 新劇場版』
Ubuntu Missing Swap
by dervish on Dec.13, 2014, under Linux, Ubuntu
Fix missing swap on Ubuntu derivatives when using encrypted home directories:
$ swapon -s
Filename Type Size Used Priority
$ free
total used free shared buffers cached
Mem: 1010504 905892 104612 16964 14460 370292
-/+ buffers/cache: 521140 489364
Swap: 0 0 0
$ sudo -s
# fdisk -l | grep swap
..
Disk /dev/mapper/mint--vg-swap_1: 1069 MB, 1069547520 bytes
..
# mkswap /dev/mapper/mint--vg-swap_1 # copy UUID shown into next cmdline
mkswap: /dev/mapper/mint--vg-swap_1: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 1044476 KiB
no label, UUID=08109738-64e7-4504-8bfd-2dff2011551d
# echo "RESUME=UUID=143c43d8-0a77-4d62-a7ae-f53a8e0229a9" > /etc/initramfs-tools/conf.d/resume
# echo "cryptswap1 /dev/sdb3 /dev/urandom swap,cipher=aes-cbc-essiv:sha256" > /etc/crypttab
# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.13.0-24-generic
Warning: No support for locale: en_US.utf8
# swapon -s
Filename Type Size Used Priority
/dev/mapper/mint--vg-swap_1 partition 1044476 316 -1
# free
total used free shared buffers cached
Mem: 1010504 863964 146540 16984 12820 326476
-/+ buffers/cache: 524668 485836
Swap: 1044476 316 1044160
Script: jbcleanup.sh
by dervish on Oct.24, 2014, under Linux, Scripts
#!/bin/sh
# 20141024 - Jamey Hopkins
echo "Before: `ls *log* | wc -l` Files at `du -h . | cut -f1`"
[ 0 -ne `find *server.log -mtime +9 | wc -l` ] && find *server.log -mtime +9 | xargs gzip -v
[ 0 -ne `find *server.log.gz -mtime +30 | wc -l` ] && find *server.log.gz -mtime +30 | xargs rm
echo "After : `ls *log* | wc -l` Files at `du -h . | cut -f1`"