Delete a NVROM entry[reference]

June 28, 2019 分类:Linux

The EFI version 2 shell provides a command called bcfg that can do the job. You'd need to do bcfg boot dump -b to see the entries, then bcfg boot rm # to delete entry number # -- # must be the number associated with whatever entry you want to remove.

In Linux, efibootmgr can do the job: Type efibootmgr or efibootmgr -v to see the entries, then do efibootmgr -b # -B to delete entry #. (You must type these commands as root or using sudo.)

In Windows, the EasyUEFI tool should be able to handle the job, although I've only toyed with it briefly, so I can't give detailed instructions.

Fixed my corrupt database last night

March 3, 2019 分类:树莓派,Linux

For some reason, I turned off the power switch last night, before I did it, I forgot to shut down my home servers correctly. Then, it was not a surprise the database on one of my Raspi crashed. I've been encountered this issue last time.
In order to solve this problem, Follow the hint, use "journalctl -xe" command to show related information. Modify "my.cnf", add " innodb_force_recovery > 0 " then start the database, afterward comment the " innodb_force_recovery > 0" line in again, restart the database subsequently. Done.

Use a SMB directory on Apache2

February 23, 2019 分类:树莓派,Linux

Install samba client:

apt-get install  samba-common smbclient samba-common-bin smbclient  cifs-utils

mkdir /mnt/abc
mount -t cifs //yourIP/yourShare /mnt/abc

If you need to add credentials at the mount time:


mount -t cifs //server/share /mnt/abc -o user=user,pass=password,dom=domain

If you want to dismount the share later:

umount /mnt/abc

Mount permanently:

sudo nano /etc/fstab

Add: //server/share /mnt/abc cifs guest,uid=1000,iocharset=utf8,x-systemd.automount 0 0

For more information visit:
https://wiki.ubuntu.com/MountWindowsSharesPermanentlyUbuntu forum

Access Permission(May not necessary):

chown -R $USER:$USER /mnt/abc
chmod -R 755 /mnt/abc

Apache2 on Debian based OS:

Modify apache2.conf add lines:

<Directory /mnt/abc/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

</Directory>

Modify conf in sites-available directory:

    <VirtualHost *:80>
DocumentRoot /mnt/abc
ServerName myv.host.com
ServerAlias myv.host.com
ErrorLog logs/myvhost-error_log
CustomLog logs/myvhost-access_log combined
ServerAdmin [email protected]
<Directory /mnt/abc/>
    AllowOverride All
    Options +Indexes
</Directory>
</VirtualHost>

Typecho出现数据库错误

January 17, 2019 分类:树莓派,Linux

前几天突然发现我的树莓派数据库服务器挂了,想来是多次插拔移动硬盘导致意外重启,损坏了文件,表现为数据库无法运行,后来扒日志修复了。今天又突然发现租用的数据库也报错了,但查看数据库运行良好。想起来运营商发的邮件来,他们更新了管理套件相应的也会更新服务器环境。登陆phpadmin查看,是比较新的php7.1,数据库扩展有了变化,修改config.nic文件里的$db = new Typecho_Db('Mysql', 'xx_');为“$db = new Typecho_Db('Pdo_Mysql', 'xx_'); 就好了。基本上遇到问题都不必惊慌,查log和搜索总能解决的。当然了,定时备份总没有坏处。

DD&fdisk

November 3, 2016 分类:Linux

fdisk和dd命令
查看:
$ sudo fdisk -u -l
备份:
$ dd bs=512 count=[fdisk命令中最大的end数+1] if=/dev/sda6 of=/sysbackup.img
恢复:
$ dd if=sysbackup.img of=/dev/sda
压缩备份:
$ dd bs=512 count=[fdisk命令中最大的end数+1] if=/dev/sda6 | gzip -6 > /sysbackup.img.gz
恢复:
$ gzip -dc /sysbackup.img.gz | dd of=/dev/sda

最好先umount所有 if和of 设备的分区。后执行sudo sync。

如果对整个硬盘进行备份和恢复 count=[fdisk命令中最大的end数+1] bs=512可以去掉。

当你刚装完redhat 7.3第一次启动时,总会死掉。主要原因是Linux在安装时探测到有usb-uhci和ehci-hcd两个控制器,但在启动时,加载完usb-uhci再加载ehci-hcd就会有冲突。分析认为redhat7.3系统内核在支持USB2.0标准上存在问题。在其他版本的Linux中均不存在此问题。

解决办法:在lilo或grub启动时用命令行传递参数init=/sbin/init。这样在启动后就不运行其他服务而直接启动shell。然后运行
mount -o remount,rw / 使/ 可写,init直接启动的系统默认只mount /为只读
然后vi /etc/modules.config文件(modules.conf)
删除alias usb-controller1 ehci-hcd一行。或前面加#注释掉
然后mount -o remount,ro / 使/ 只读,避免直接关机破坏文件系统
然后就可以按Ctrl-Alt-Delete直接重启了
或许,你有更简单的办法:换USB键盘和鼠标为PS2接口,启动后修改/etc/modules.config文件。
linux压缩文件为.tar.gz的命令

  1. .tar格式

解包: tar -xvf FileName.tar
打包: tar -cvf FileName.tar DirName(注:tar是打包,不是压缩)

  1. .gz格式

解压1:gunzip FileName.gz
解压2:gzip -d FileName.gz
压缩:gzip FileName

  1. .tar.gz格式

解压: tar -zxvf FileName.tar.gz
压缩: tar -zcvf Filename.tar.gz DirName

  1. .bz2格式

解压1: bzip2 -d filename.bz2
解压2: bunzip2 filename.bz2
压缩: bzip2 -z filename

  1. .tar.bz2格式

解压: tar -jxvf filename.tar.bz2
压缩: tar -jcvf filename.tar.bz2 dirname

  1. .bz格式

解压1: bzip2 -d filename.bz
解压2: bunzip2 filename.bz

  1. .tar.bz格式

解压:tar -jxvf filename.tar.bz

  1. .Z格式

解压: uncompress filename.Z
压缩:compress filename

  1. .tar.Z格式

解压: tar -Zxvf filename.tar.Z
压缩: tar -Zcvf filename.tar.Z dirname

  1. .tgz格式

解压: tar -zxvf filename.tgz

  1. .tar.tgz格式

解压: tar -zxvf filename.tar.tgz
压缩: tar zcvf filename.tar.tgz filename

  1. .zip格式

解压: unzip filename.zip
压缩: zip Filename.zip dirname

  1. .lha格式

解压: lha -e filename.lha
压缩: lha -a filename.lha filename

  1. .rar格式

解压: rar a filename.rar
压缩: rar e filename.rar