Troubleshooting with strace

So recently I was trying to set-up a php-fpm & Nginx based server (with PHP 7 if I recall) and it would not run, I tried everything I could think of, having set up a few of these for work recently but it would just not work.

Well after much Googling I discovered a post on the Nginx forums not completely related to my troubles but it had a handy tip for debugging:

stop fpm
strace -efile /path/to/php-fpm -i > /dev/null

That command completely saved my sanity, for those who don’t know what it is (if anyone else actually reads this that is, and this is a lamens explanation) strace shows what in this case php-fpm gets up to and what files it tries to open. This led me to discover it was trying to open a particular file which was giving a permissions error I believe where it couldn’t open the file and quite shortly afterwards I was able to solve it.

If I didn’t discover that post and this command I would have given up and had a rather unproductive week I think. Well anyway here is the link to the post that originally helped me:
https://forum.nginx.org/read.php?3,148257,148272

Obviously if you run this for something else you just need to change the location of the binary, I was building php7 myself so pointed it to my own binary

If anyone else finds this useful then yay, glad I helped.

Format HDD in Linux

So very recently we needed to quickly get a new 3TB HDD set-up in Cent OS 7 as a backup server. We couldn’t afford the time to spend an age on it so when with the simple and powerful fdisk. I decided to write this so that I don’t forget how I did it, as is likely to happen.

  1. Identify the device, we used fdisk -l and was able to identify the drive: /dev/sdb
  2. Create the partition, fdisk /dev/sdb then use option p, n, and w (w is important as it actually makes the changes, otherwise they get lost when fdisk quits)
  3. Make the ext4 filesystem on partition, mkfs -t ext4 /dev/sdb1 (the 1 refers to the partition)
  4. Create a mount point, Simply just need to create a folder with which to mount the drive into, we used /mnt/backup_drive
  5. Mount the partition (temporily), mount /dev/sdb1 /mnt/backup_drive – this let us know it all worked
  6. Make the mount permanent, Edit fstab (I like to use nano but there are other ways to do this) nano /etc/fstab (you need to sudo for this to work) and enter a line like this: /dev/sdb1 /mnt/backup_drive     ext4   defaults   0  0
    You may see other lines similar to this, some systems refer to the drives using the UUID instead, admittedly I don’t know enough about that to comment other than I rememer reading that the UUID is very unique. When I discover more I shall post about it on here.