Deepin挂载内存盘

Deepin挂载内存盘

最近检查了一下硬盘,发现双系统的Deepin分区损害严重。笔者猜想是由于其分区太小,经常擦写的缘故吧。故此,设置内存盘。

一、修改/etc/fstab

tmpfs                        /var/cache/apt/archives            tmpfs        size=1G,mode=0777     0 0

或者

none                        /var/cache/apt/archives        tmpfs    rw,noexec,nosuid,nodev,size=3G,mode=0777 0 0

# 注意大小一定要整数而且要少于可用内存,如果不整数可以用M为单位。否则会导致机器无法启动。若需要内存为动态分配,设置挂载文件系统为none。

二、修改/etc/init.d/rcS

chown zhouyixing:zhouyixing /var/cache/apt/archives


三、设置浏览器缓存目录

mkdir -p /var/cache/apt/archives/chrome
mkdir -p /var/cache/apt/archives/firefox
if [ -d /var/cache/apt/archives/firefox ] ; then
    if [ ! -e /home/zhouyixing/.cache/mozilla ] ; then
        ln -s /var/cache/apt/archives/firefox/ /home/zhouyixing/.cache/mozilla
    fi
fi

if [ -d /var/cache/apt/archives/chrome ] ; then
    if [ ! -e /home/zhouyixing/.cache/google-chrome ] ; then
        ln -s /var/cache/apt/archives/chrome/ /home/zhouyixing/.cache/google-chrome
    fi
fi

四、附加文件

#!/bin/bash 

VAR_ACTION=
VAR_CMD=
VAR_DEST_PATH=
VAR_SRC_PATH=

function echo_red()
{ 
	echo -e "\033[31;40m" "$@" "\033[0m"
}

function echo_green()
{ 
	echo -e "\033[32;40m" "$@" "\033[0m"
}

function echo_yellow()
{ 
	echo -e "\033[33;40m" "$@" "\033[0m"
}

function echo_error()
{
	echo_red $@
}

while getopts ":a:c:d:s:" options  
do  
	case ${options} in  
	a)
		echo_green "VAR_ACTION = $OPTARG"  
		VAR_ACTION=$OPTARG
		;;  
	c)
		echo_green "VAR_CMD = $OPTARG"  
		VAR_CMD=$OPTARG
		;;  
	d)
		echo_green "VAR_DEST_PATH = $OPTARG"  
		VAR_DEST_PATH=$OPTARG
		;;
	s)
		echo_green "VAR_SRC_PATH = $OPTARG"  
		VAR_SRC_PATH=$OPTARG
		;;
	\?)
		;;
	esac
done

case ${VAR_ACTION} in
build)
	eval ${VAR_CMD}
	;;
copy)
	if [ "${VAR_DEST_PATH} " = " " ] ; then
		echo_error "destination is empty"
	elif [ "${VAR_DEST_PATH} " = " " ] ; then
		echo_error "source path is empty"
	elif [ ! -d $VAR_SRC_PATH ] ; then
		echo_error "source directory is not exist!"
	else
		if [ ! -d $VAR_DEST_PATH ] ; then
			mkdir -p $VAR_DEST_PATH
		fi

		cp -rf $VAR_SRC_PATH/* $VAR_DEST_PATH
	fi
	;;
patch)
	if [ -d ./tmp ] ; then
		echo_yellow "delete the folder ./tmp"
		rm -rf ./tmp
	fi
	mkdir ./tmp
	echo "#!/bin/bash" > ./var.sh														&&	\
	git diff --stat 																	| 	\
	grep \| 																			|	\
	awk '{for(i=3;i> var.sh			&&	\
	echo "exit 0" >> var.sh																&&	\
	chmod a+x ./var.sh																	&&	\
	/bin/bash ./var.sh 																	&&	\
	rm ./var.sh

	if [ "${VAR_DEST_PATH}" != "" ] ; then
		echo_green "move to "${VAR_DEST_PATH}" ..."
		if [ ! -d ${VAR_DEST_PATH} ] ; then
			echo_yellow "create path ${VAR_DEST_PATH}"
			mkdir -p ${VAR_DEST_PATH}
		fi
		cd ./tmp/
		cp -rf * ${VAR_DEST_PATH}
		cd ..
		rm -rf ./tmp/
		echo_green "done"
	fi
	;;
\?)
	echo_error
	;;
esac


你可能感兴趣的:(Ubuntu)