这个脚本是我买了一个刷好armbian系统的玩客云,然后自己安装好了宝塔,最后发现磁盘根本不够用,才6G多,于是又买了一张SD卡,因为SD卡终身保固,而且不占地方。
后来参照宝塔官网自己写了一个脚本把SD卡挂载到WWW目录。
对于那些没有安装任何东西的小伙伴,大家可以执行下面的脚本:
echo -e "" echo -e "格式化SD卡..." echo -e "" sleep 2 mkfs.ext4 /dev/mmcblk0p1 echo -e "" echo -e "挂载SD卡..." echo -e "" sleep 2 mount /dev/mmcblk0p1 /www echo "/dev/mmcblk0p1 /www ext4 defaults 0 0" >> /etc/fstab echo -e "" echo -e "处理完成" echo -e ""
注意:/www为需要挂载的目录
对于安装了宝塔并且还有一点数据的朋友,可以使用下面的脚本:
#!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATHLANG=en_US.UTF-8stop_service(){/etc/init.d/bt stopif [ -f "/etc/init.d/nginx" ]; then/etc/init.d/nginx stop > /dev/null 2>&1fiif [ -f "/etc/init.d/httpd" ]; then/etc/init.d/httpd stop > /dev/null 2>&1fiif [ -f "/etc/init.d/mysqld" ]; then/etc/init.d/mysqld stop > /dev/null 2>&1fiif [ -f "/etc/init.d/pure-ftpd" ]; then/etc/init.d/pure-ftpd stop > /dev/null 2>&1fiif [ -f "/etc/init.d/tomcat" ]; then/etc/init.d/tomcat stop > /dev/null 2>&1fiif [ -f "/etc/init.d/redis" ]; then/etc/init.d/redis stop > /dev/null 2>&1fiif [ -f "/etc/init.d/memcached" ]; then/etc/init.d/memcached stop > /dev/null 2>&1fiif [ -f "/www/server/panel/data/502Task.pl" ]; thenrm -f /www/server/panel/data/502Task.plif [ -f "/etc/init.d/php-fpm-52" ]; then/etc/init.d/php-fpm-52 stop > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-53" ]; then/etc/init.d/php-fpm-53 stop > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-54" ]; then/etc/init.d/php-fpm-54 stop > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-55" ]; then/etc/init.d/php-fpm-55 stop > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-56" ]; then/etc/init.d/php-fpm-56 stop > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-70" ]; then/etc/init.d/php-fpm-70 stop > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-71" ]; then/etc/init.d/php-fpm-71 stop > /dev/null 2>&1fifi}start_service(){/etc/init.d/bt startif [ -f "/etc/init.d/nginx" ]; then/etc/init.d/nginx start > /dev/null 2>&1fiif [ -f "/etc/init.d/httpd" ]; then/etc/init.d/httpd start > /dev/null 2>&1fiif [ -f "/etc/init.d/mysqld" ]; then/etc/init.d/mysqld start > /dev/null 2>&1fiif [ -f "/etc/init.d/pure-ftpd" ]; then/etc/init.d/pure-ftpd start > /dev/null 2>&1fiif [ -f "/etc/init.d/tomcat" ]; then/etc/init.d/tomcat start > /dev/null 2>&1fiif [ -f "/etc/init.d/redis" ]; then/etc/init.d/redis start > /dev/null 2>&1fiif [ -f "/etc/init.d/memcached" ]; then/etc/init.d/memcached start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-52" ]; then/etc/init.d/php-fpm-52 start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-53" ]; then/etc/init.d/php-fpm-53 start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-54" ]; then/etc/init.d/php-fpm-54 start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-55" ]; then/etc/init.d/php-fpm-55 start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-56" ]; then/etc/init.d/php-fpm-56 start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-70" ]; then/etc/init.d/php-fpm-70 start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-71" ]; then/etc/init.d/php-fpm-71 start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-72" ]; then/etc/init.d/php-fpm-71 start > /dev/null 2>&1fiif [ -f "/etc/init.d/php-fpm-73" ]; then/etc/init.d/php-fpm-71 start > /dev/null 2>&1fiecho "True" > /www/server/panel/data/502Task.pl}echo -e ""echo -e "停止宝塔服务"echo -e ""sleep 3stop_serviceecho -e ""echo -e "数据备份..."echo -e ""sleep 2mv /www /bt-backupecho -e ""echo -e "格式化SD卡..."echo -e ""sleep 2mkfs.ext4 /dev/mmcblk0p1echo -e ""echo -e "挂载SD卡..."echo -e ""sleep 2mkdir /wwwmount /dev/mmcblk0p1 /wwwecho "/dev/mmcblk0p1 /www ext4 defaults 0 0" >> /etc/fstabecho -e ""echo -e "数据还原中..."echo -e ""cp -r -p -a /bt-backup/* /wwwecho -e ""echo -e "处理完成"echo -e ""echo -e "启动宝塔服务"echo -e ""start_servicerm -rf /bt-backup#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH LANG=en_US.UTF-8 stop_service(){ /etc/init.d/bt stop if [ -f "/etc/init.d/nginx" ]; then /etc/init.d/nginx stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/httpd" ]; then /etc/init.d/httpd stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/mysqld" ]; then /etc/init.d/mysqld stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/pure-ftpd" ]; then /etc/init.d/pure-ftpd stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/tomcat" ]; then /etc/init.d/tomcat stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/redis" ]; then /etc/init.d/redis stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/memcached" ]; then /etc/init.d/memcached stop > /dev/null 2>&1 fi if [ -f "/www/server/panel/data/502Task.pl" ]; then rm -f /www/server/panel/data/502Task.pl if [ -f "/etc/init.d/php-fpm-52" ]; then /etc/init.d/php-fpm-52 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-53" ]; then /etc/init.d/php-fpm-53 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-54" ]; then /etc/init.d/php-fpm-54 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-55" ]; then /etc/init.d/php-fpm-55 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-56" ]; then /etc/init.d/php-fpm-56 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-70" ]; then /etc/init.d/php-fpm-70 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-71" ]; then /etc/init.d/php-fpm-71 stop > /dev/null 2>&1 fi fi } start_service() { /etc/init.d/bt start if [ -f "/etc/init.d/nginx" ]; then /etc/init.d/nginx start > /dev/null 2>&1 fi if [ -f "/etc/init.d/httpd" ]; then /etc/init.d/httpd start > /dev/null 2>&1 fi if [ -f "/etc/init.d/mysqld" ]; then /etc/init.d/mysqld start > /dev/null 2>&1 fi if [ -f "/etc/init.d/pure-ftpd" ]; then /etc/init.d/pure-ftpd start > /dev/null 2>&1 fi if [ -f "/etc/init.d/tomcat" ]; then /etc/init.d/tomcat start > /dev/null 2>&1 fi if [ -f "/etc/init.d/redis" ]; then /etc/init.d/redis start > /dev/null 2>&1 fi if [ -f "/etc/init.d/memcached" ]; then /etc/init.d/memcached start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-52" ]; then /etc/init.d/php-fpm-52 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-53" ]; then /etc/init.d/php-fpm-53 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-54" ]; then /etc/init.d/php-fpm-54 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-55" ]; then /etc/init.d/php-fpm-55 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-56" ]; then /etc/init.d/php-fpm-56 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-70" ]; then /etc/init.d/php-fpm-70 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-71" ]; then /etc/init.d/php-fpm-71 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-72" ]; then /etc/init.d/php-fpm-71 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-73" ]; then /etc/init.d/php-fpm-71 start > /dev/null 2>&1 fi echo "True" > /www/server/panel/data/502Task.pl } echo -e "" echo -e "停止宝塔服务" echo -e "" sleep 3 stop_service echo -e "" echo -e "数据备份..." echo -e "" sleep 2 mv /www /bt-backup echo -e "" echo -e "格式化SD卡..." echo -e "" sleep 2 mkfs.ext4 /dev/mmcblk0p1 echo -e "" echo -e "挂载SD卡..." echo -e "" sleep 2 mkdir /www mount /dev/mmcblk0p1 /www echo "/dev/mmcblk0p1 /www ext4 defaults 0 0" >> /etc/fstab echo -e "" echo -e "数据还原中..." echo -e "" cp -r -p -a /bt-backup/* /www echo -e "" echo -e "处理完成" echo -e "" echo -e "启动宝塔服务" echo -e "" start_service rm -rf /bt-backup#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH LANG=en_US.UTF-8 stop_service(){ /etc/init.d/bt stop if [ -f "/etc/init.d/nginx" ]; then /etc/init.d/nginx stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/httpd" ]; then /etc/init.d/httpd stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/mysqld" ]; then /etc/init.d/mysqld stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/pure-ftpd" ]; then /etc/init.d/pure-ftpd stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/tomcat" ]; then /etc/init.d/tomcat stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/redis" ]; then /etc/init.d/redis stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/memcached" ]; then /etc/init.d/memcached stop > /dev/null 2>&1 fi if [ -f "/www/server/panel/data/502Task.pl" ]; then rm -f /www/server/panel/data/502Task.pl if [ -f "/etc/init.d/php-fpm-52" ]; then /etc/init.d/php-fpm-52 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-53" ]; then /etc/init.d/php-fpm-53 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-54" ]; then /etc/init.d/php-fpm-54 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-55" ]; then /etc/init.d/php-fpm-55 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-56" ]; then /etc/init.d/php-fpm-56 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-70" ]; then /etc/init.d/php-fpm-70 stop > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-71" ]; then /etc/init.d/php-fpm-71 stop > /dev/null 2>&1 fi fi } start_service() { /etc/init.d/bt start if [ -f "/etc/init.d/nginx" ]; then /etc/init.d/nginx start > /dev/null 2>&1 fi if [ -f "/etc/init.d/httpd" ]; then /etc/init.d/httpd start > /dev/null 2>&1 fi if [ -f "/etc/init.d/mysqld" ]; then /etc/init.d/mysqld start > /dev/null 2>&1 fi if [ -f "/etc/init.d/pure-ftpd" ]; then /etc/init.d/pure-ftpd start > /dev/null 2>&1 fi if [ -f "/etc/init.d/tomcat" ]; then /etc/init.d/tomcat start > /dev/null 2>&1 fi if [ -f "/etc/init.d/redis" ]; then /etc/init.d/redis start > /dev/null 2>&1 fi if [ -f "/etc/init.d/memcached" ]; then /etc/init.d/memcached start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-52" ]; then /etc/init.d/php-fpm-52 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-53" ]; then /etc/init.d/php-fpm-53 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-54" ]; then /etc/init.d/php-fpm-54 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-55" ]; then /etc/init.d/php-fpm-55 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-56" ]; then /etc/init.d/php-fpm-56 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-70" ]; then /etc/init.d/php-fpm-70 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-71" ]; then /etc/init.d/php-fpm-71 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-72" ]; then /etc/init.d/php-fpm-71 start > /dev/null 2>&1 fi if [ -f "/etc/init.d/php-fpm-73" ]; then /etc/init.d/php-fpm-71 start > /dev/null 2>&1 fi echo "True" > /www/server/panel/data/502Task.pl } echo -e "" echo -e "停止宝塔服务" echo -e "" sleep 3 stop_service echo -e "" echo -e "数据备份..." echo -e "" sleep 2 mv /www /bt-backup echo -e "" echo -e "格式化SD卡..." echo -e "" sleep 2 mkfs.ext4 /dev/mmcblk0p1 echo -e "" echo -e "挂载SD卡..." echo -e "" sleep 2 mkdir /www mount /dev/mmcblk0p1 /www echo "/dev/mmcblk0p1 /www ext4 defaults 0 0" >> /etc/fstab echo -e "" echo -e "数据还原中..." echo -e "" cp -r -p -a /bt-backup/* /www echo -e "" echo -e "处理完成" echo -e "" echo -e "启动宝塔服务" echo -e "" start_service rm -rf /bt-backup
注意:上面这个脚本使用的时候会自动备份宝塔数据,但是玩客云的剩余储存小于www目录的使用量时,就需要自己手动备份,清空一定量的空间,必须保证玩客云的剩余储存大于www目录的使用量。
这样看起来是不是空间大了好多了

© 版权声明
THE END
暂无评论内容