作者归档:John

修改Debian软件包的依赖关系

遇到个蛋疼的事情,手动编译deb就不说了,依赖还搞的莫名其妙,自己ls再cat了一阵子没找到眉目,最后查到资料:

在Debian软件包的debian目录下有个叫control的文件,改,完。

最后再dpkg-buildpackage -b –no-sign

CentOS VM@Hyper-v磁盘扩容

GPT分区表下,CentOS标准配置,GPT信息分区在/dev/sda1,swap分区在/dev/sda2,root在/dev/sda3,思路是先新建一个分区,再合并进逻辑分区组里,原容量:16G,新容量:32G

  • 关闭虚拟机
  • 编辑磁盘,增加空间
  • 启动虚拟机
  • su到root(纯属懒癌发作不想打sudo)

fdisk /dev/sda

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

GPT PMBR size mismatch (33554431 != 67108863) will be corrected by write.(已经识别到新的空间了)
The backup GPT table is not on the end of the device. This problem will be corrected by write.

  • n,4,一路回车,新建一个分区

Partition number (4-128, default 4):
First sector (33552384-67108830, default 33552384):
Last sector, +sectors or +size{K,M,G,T,P} (33552384-67108830, default 67108830):

Created a new partition 4 of type ‘Linux filesystem’ and of size 16 GiB.

    • t,4,8e,更改分区类型为LVM

Partition number (1-4, default 4): 4
Partition type (type L to list all types): 8e

Type of partition 4 is unchanged: Linux filesystem.

  • w保存分区表
  • fdisk -l看一下分区表对不对,应该是这样的:

Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: A73C227D-BC0B-4CF0-923C-F3152ABD71751

Device Start End Sectors Size Type
/dev/sda1 2048 1230847 1228800 600M EFI System
/dev/sda2 1230848 3327999 2097152 1G Linux filesystem
/dev/sda3 3328000 33552383 30224384 14.4G Linux LVM
/dev/sda4 33552384 67108830 33556447 16G Linux filesystem

Disk /dev/mapper/Name_of_VG-root: 12.8 GiB, 13753122816 bytes, 26861568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/Name_of_VG-swap: 1.6 GiB, 1719664640 bytes, 3358720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

  • pvcreate /dev/sda4创建新分区

 Physical volume “/dev/sda4” successfully created.

  • vgdisplay 找一下分区组的名称

— Volume group —
VG Name Name_of_VG
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 14.41 GiB
PE Size 4.00 MiB
Total PE 3689
Alloc PE / Size 3689 / 14.41 GiB
Free PE / Size 0 / 0
VG UUID W*****-******-*****

 

  • vgextend Name_of_VG /dev/sda4 扩展分区组

 Volume group “Name_of_VG” successfully extended

  • lvextend /dev/Name_of_VG/root /dev/sda4 扩展逻辑分区

Size of logical volume Name_of_VG/root changed from <12.81 GiB (3279 extents) to 28.80 GiB (7374 extents).
Logical volume cl/root successfully resized.

  • resize2fs /dev/Name_of_VG/root 按网上看到的文章, 这样写会报错:

resize2fs 1.45.6 (20-Mar-2020)
resize2fs: Bad magic number in super-block while trying to open /dev/cl/root
Couldn’t find valid filesystem superblock.

  • resize2fs /dev/mapper/Name_of_VG-root 也是报错:

resize2fs 1.45.6 (20-Mar-2020)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/cl-root
Couldn’t find valid filesystem superblock.

  • 最后又查了下,原来应该这样写:xfs_growfs -d /dev/Name_of_VG/root:

meta-data=/dev/mapper/Name_of_VG-root isize=512 agcount=4, agsize=839424 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=3357696, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 3357696 to 7550976

  • df -h看下,妥了

Filesystem Size Used Avail Use% Mounted on
devtmpfs 826M 0 826M 0% /dev
tmpfs 844M 84K 844M 1% /dev/shm
tmpfs 844M 17M 827M 2% /run
tmpfs 844M 0 844M 0% /sys/fs/cgroup
/dev/mapper/cl-root 29G 8.3G 21G 29% /
/dev/sda2 976M 297M 612M 33% /boot
/dev/sda1 599M 7.3M 592M 2% /boot/efi
tmpfs 169M 0 169M 0% /run/user/0

 

Reference:

https://airzerocloud.com/blog/post/extending-linux-disk-vmware-hyper-v-centosredhat-on-the-fly-live

https://samsig.dk/extending-gpt-lvm-disk-on-centos/

Mariadb配置文件挪窝了

改了/etc/my.cnf里datadir的位置,结果一点反映都没有,把新位置的整个dir删掉都能正常启动mariadb,很匪夷所思

结果是……

配置文件从/etc/my.cnf迁移到了/etc/my.cnf.d/mariadb-server.cnf

折腾了半天才发现问题

居然被AnonymousFox 黑了……

今早发现同一个服务器上的其他网站打不开,状况非常奇怪,同服务器的部分网站完全正常,其余几个直接打不开,表现为:静态夜页面和资源完全正常,php的动态页面就像不存在一样的直接显示Apache默认主页。

查了日志看到:[access_compat:error] AH01797: client denied by server configuration

检查配置和日志莫名其妙折腾了一个多小时,最后想起来会不会是被入侵了,ls看了下文件夹果然有惊喜:

一眼就瞄到了不应该存在的php.ini,按时间排序一下就看到了这堆东西

 

接着追到wp-content下,就更热闹了

多了两个文件夹:

Fox-C和Fox-C404

多了一大堆加密的php文件

 

 

追了一下,原来是大名鼎鼎的FoxAuto by AnonymousFox

 

 

不知道是什么插件有洞被扫出来了,可惜为了排除配置问题,把日志删了(太长),只能根据文件时间推断是7月30号到今天上午之间被黑掉了。

找到了问题,接下来就简单了,重新安装一份干净的wp

把uploads文件夹移回去

装个Wordfence

完工,继续板砖