kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

tar 备份系统

tar备份系统

1
2
3
4
5
6
7
8
9
10
tar -czpvf /baksys/backup.tgz  /  --exclude=/baksys --exclude=/lost+found --exclude=/proc/* --exclude=/sys/* --exclude=/tmp/* --exclude=/dev/* --exclude=/media/* --exclude=/mnt/*

-p, --preserve-permissions, --same-permissions 解压文件权限信息(默认只为超级用户服务)。 
	此参数用于保持文件权限信息,是必要的。
--exclude= 参数列出了不需要备份的目录,可以根据实际情况自行调整,
	注意:不要忘记备份/boot目录或分区,不要备份存储备份文件的目录。 
	特别注意:--exclude=后面的目录名使用绝对路径或相对路径的方式应与需备份目录的书写方式一致即要么都用绝对路径要么都使用相对路径,
	否则会导致exclude失效,而且目录一定不能使用/xxx/的形式,必须是/xxx/*或/xxx的形式,否则也失效。 
注意,虽然/proc的目录下内容不可备份,但是/proc目录还是应该备份的,否则需要在迁移解压缩后手动mkdir增加/proc目录;
	其他几个亦同,但是/lost+found目录非linux系统需要,可全不备份。

恢复系统

1
2
3
4
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt/
cd /mnt
tar -xzpvf backup.tgz

修复MBR、grub

从ubuntu u盘执行:

1
2
3
4
5
mkdir /mnt
mount /dev/sda1 /mnt
cd /mnt

grub-install --recheck --root-directory=/mnt /dev/sda 

注意:

  1. ubuntu系统的 grub-install 64位的不能执行??? u盘中的grub-install i386可以执行???

  2. 临时进系统方法:

1
2
3
4
5
6
insmod linux
ls
root=(hd0,1)
linux /boot/vmlinuz root=/dev/sda1
initrd /boot/initrd
boot
1
2
3
4
# win7
set root=(hd0,1)
chainloader +1
boot

硬盘安装windows及MBR、grub修复

硬盘安装win7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
mount -o loop win7.iso /mnt
mount -t ntfs /dev/sda3 /tmp/kk
cp -r /mnt/* /tmp/kk/
umount /tmp/kk

reboot

https://askubuntu.com/questions/254491/failed-to-get-canonical-path-of-cow
重启后来到 grub 的引导菜单,按 c 键进入命令行模式:
grub> set root=(hd1,2)
grub> insmod ntfs
grub> ntldr /bootmgr
grub> boot

注意:

  1. 起因:从 u盘 安装极其缓慢,为什么???

  2. 从 /dev/nvmessd 的grub进入没有 ntldr 命令 ???

  3. 从 /dev/sda2 的grub进入有 ntldr 命令

  4. 技嘉主板先制作usb启动盘,加入技嘉驱动 http://download.gigabyte.cn/FileList/Utility/mb_utility_windowsimagetool.zip 方法:http://www.gigabyte.cn/WebPage/-79/usb.html 。再从u盘 cp * /tmp/kk/

修复MBR、grub

从ubuntu u盘执行:

1
2
3
4
5
mkdir /mnt
mount /dev/sda2 /mnt
cd /mnt

grub-install --recheck --root-directory=/mnt /dev/sda 

注意:

  1. ubuntu系统的 grub-install 64位的不能执行??? u盘中的grub-install i386可以执行???

  2. 临时进系统方法:

1
2
3
4
5
6
insmod linux
ls
root=(hd0,1)
linux /boot/vmlinuz root=/dev/sda1
initrd /boot/initrd
boot
1
2
3
4
# win7
set root=(hd0,1)
chainloader +1
boot

nginx ipv6、TCP_DEFER_ACCEPT

curl 7.61.1

curl 7.61.1

TCP_DEFER_ACCEPT

1
2
3
server {
	listen  80 deferred;
	...

deferred instructs to use a deferred accept() (the TCP_DEFER_ACCEPT socket option) on Linux.

ipv6

1
2
3
server {
	listen  [::]:8080; # ipv6only=on;
	...

ipv6only=on|off this parameter (0.7.42) determines (via the IPV6_V6ONLY socket option) whether an IPv6 socket listening on a wildcard address [::] will accept only IPv6 connections or both IPv6 and IPv4 connections. This parameter is turned on by default. It can only be set once on start.

Prior to version 1.3.4, if this parameter was omitted then the operating system’s settings were in effect for the socket.