RealTechTalk (RTT) - Linux/Server Administration/Related

We have years of knowledge with technology, especially in the IT (Information Technology) industry. 

realtechtalk.com will always have fresh and useful information on a variety of subjects from Graphic Design, Server Administration, Web  Hosting Industry and much more.

This site will specialize in unique topics and problems faced by web hosts, Unix/Linux administrators, web developers, computer technicians, hardware, networking, scripting, web design and much more. The aim of this site is to explain common problems and solutions in a simple way. Forums are ineffective because they have a lot of talk, but it's hard to find the answer you're looking for, and as we know, the answer is usually not there. No one has time to scour the net for forums and read pages of irrelevant information on different forums/threads. RTT just gives you what you're looking for.

  • wget how to resume download!


    It's very simple you just use the "-c" switch and wget will resume the file (make sure you are in the same directory) or specify -O /path/to/partialdownload.zip

    wget -c http://someurl/file.zip


  • strange vi errors in Linux Mint/Ubuntu line 58: E488: Trailing characters: t_Sbet line 63: E171: Missing :endif


    This happens on any file an even just typing "vi" whereas it never happened before.  I suspect an update or environment variable is causing this issue

    When entering vi I get this weird stuff

    line   58:
    E488: Trailing characters: t_Sbet
    line   63:
    E171: Missing :endif

    When exiting vi I get this weird stuff

      t_Sb=^[[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m


  • MySQL Add multiple IPs for remote user including root howto


    To grant the IP 192.168.2.4 to user mysqlguy

    GRANT ALL ON *.* TO 'mysqlguy'@'192.168.2.4';

    To allow any IP for mysqlguy just use the wildcard % character


    GRANT ALL ON *.* TO 'mysqlguy'@'%';

    Also note it is normal and fine to have multiple entries in the mysql table.


  • cPanel error Access denied for user 'root'@'localhost' when adding remote MySQL IP address solution


    Error while connecting to MYSQL: (XID 4ea7s9) Access denied for user 'root'@'localhost' (using password: YES) at /usr/local/cpanel/Cpanel/Mysql.pm line 181
    

    Solution

    This error occurs because the /root/.my.cnf has the wrong/outdated password for MySQL root user.  Simply edit /root/.my.cnf with the correct user. This normally happens if you update outside of cPanel.

     

     


  • Text Editors - Top Linux Ubuntu/Debian/Mint Options


    1.) gedit/pluma

    both very good the only thing I wish is that there was an autosave for unsaved documents!  The only other competitor which is similar but I prefer less is kwrite (although I think kwrite may have proper autosave)

    pluma seems to be a renamed gedit yet gedit is still installable on Linux Mint)
     

    2.) kwrite/kate

    very similar to gedit/pluma but doesn't seem as nice and smooth

     

    3.) leafpad

    very basic like Microsoft Notepad Text Editor

    4.) Scribes

    again more for coding seems heavy duty/slow to load and weird

    5.) Cream

    seems ancient and a basic code editor


  • Linux shows my drive as being dead is it really? Buffer I/O error on device sdb, logical block 0 sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00


    Normally the below would indicate a failing or failed drive.  In this case the SATA port was unplugged and sometimes the Linux kernel/motherboard even with AHCI just don't play nice and can't handle it.

    What happened is I plugged in a new drive after removing another one.  However the log shows that after the old drive was plugged in the Linux kernel kept complaining thinking the drive was there but not responding properly.  This continued even with reseating the new drive.
    So if you've removed an old drive/dead drive and the port doesn't work on the new one, don't assume your new drive is DOA.  Instead reboot or try a new SATA port to be sure.

    May 23 15:01:03 box2 kernel: __ratelimit: 1401 callbacks suppressed
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 20 00
    May 23 15:01:03 box2 kernel: __ratelimit: 1402 callbacks suppressed
    May 23 15:01:03 box2 kernel: end_request: I/O error, dev sdb, sector 0
    May 23 15:01:03 box2 kernel: __ratelimit: 1471 callbacks suppressed
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 0
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 1
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 2
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 3
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00
    May 23 15:01:03 box2 kernel: end_request: I/O error, dev sdb, sector 0
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 0
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 3a 38 60 28 00 00 08 00
    May 23 15:01:03 box2 kernel: end_request: I/O error, dev sdb, sector 976773160
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 122096645
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 3a 38 60 28 00 00 08 00
    May 23 15:01:03 box2 kernel: end_request: I/O error, dev sdb, sector 976773160
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 122096645
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 20 00
    May 23 15:01:03 box2 kernel: end_request: I/O error, dev sdb, sector 0
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 0
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 1
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:03 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00
    May 23 15:01:03 box2 kernel: end_request: I/O error, dev sdb, sector 0
    May 23 15:01:03 box2 kernel: Buffer I/O error on device sdb, logical block 0
    May 23 15:01:07 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:07 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 20 00
    May 23 15:01:07 box2 kernel: end_request: I/O error, dev sdb, sector 0
    May 23 15:01:07 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:07 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00
    May 23 15:01:07 box2 kernel: end_request: I/O error, dev sdb, sector 0
    May 23 15:01:07 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:07 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 3a 38 60 28 00 00 08 00
    May 23 15:01:07 box2 kernel: end_request: I/O error, dev sdb, sector 976773160
    May 23 15:01:07 box2 kernel: sd 3:0:0:0: [sdb]  Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    May 23 15:01:07 box2 kernel: sd 3:0:0:0: [sdb] CDB: Read(10): 28 00 3a 38 60 28 00 00 08 00
    May 23 15:01:07 box2 kernel: end_request: I/O error, dev sdb, sector 976773160
    

    As we can see the same drive comes up fine on another port.

    However the drive was working fine and kept throwing errors like above so a reboot was required. This is the first time I've seen an issue like this.  It seems like the other port's issue affected the entire bus from working with any new device.

     

     


  • use ffmpeg to watermark videos if mencoder/bmovl fail


    If you have this problem: http://realtechtalk.com/mencoder_bmovl_error_vf_bmovl_Unknown_command_Ignoring_-1860-articles

    Then ffmpeg is for you.  Go here if you are using Linux Mint and cannot find or install it to use an external PPA.

    Easy solution and how to use ffmpeg to watermark:

    ffmpeg -i  yourvideo.mp4 -i yourwatermark.jpg -filter_complex "overlay=10:10" outputfile.mp4

    Source: another great ffmpeg watermark tutorial


  • mencoder bmovl error vf_bmovl: Unknown command: ''. Ignoring.


    Based on this tutorial: http://www.linuxjournal.com/content/overlay-images-video-using-mplayer-and-mencoder

    mencoder -oac pcm -ovc raw -vf bmovl=0:0:tfifo -o $output $file


    vf_bmovl: Unknown command: ''. Ignoring.  

    If you get this error use ffmpeg instead and follow this quick/easy tutorial

    Full script as follows does not work on mencoder on Linux Mint 17:

    MEncoder 1.1-4.8 (C) 2000-2012 MPlayer Team
     

     

    #!/bin/bash
    #does work error
    #vf_bmovl: Unknown command: ''. Ignoring.

    watermark=$1
    watermark="FINAL.jpg"
    watermark_height=600
    watermark_width=500
    file=$2
    output=$file-watermark.mp4
    if [ -z "$watermark" ] || [ -z "$file" ]; then
       echo "Usage $0 watermarkfile.jpg file.mp4"
       exit 1
    fi
    #convert watermark to rgba
    convert $watermark tlogo.rgba
    #Copy logo to fifo
    rm -f tfifo
    mkfifo tfifo

    (echo "RGBA32 500 600 0 0 0 1" ; cat tlogo.rgba ) >tfifo &
    mencoder -oac pcm -ovc raw -vfm bmovl=0:0:$watermark -o $output $file


    rm -f tfifo
    rm -f tlogo.rgba

     


  • Linux Mint/Ubuntu/Debian Nvidia driver becomes slow graphics performance issue


    I've had this issue since Ubuntu 9 and now even on Linux Mint 17 no matter what latest version of the Nvidia proprietary driver that I use.  It just becomes slower and slower and only gets better after rebooting or restarting Xorg.

    Someone here has it as well

    https://askubuntu.com/questions/822449/graphics-becomes-slow-after-a-while/917886

    It's very frustrating that this issue has been recurring with all OS's, drivers and different Nvidia cards I've had with no resolution.  I am almost considering going ATI if that driver doesn't have the slowdown issue

     

     

     

     


  • Linux Mint missing ffmpeg solution to install from Ubuntu PPA


    This is very annoying that ffmpeg is missing from Linux Mint!  They have ffmpeg2theora which is a totally different codec and does not work as ffmpeg does at all (it is basically totally different).

    However on Linux Mint 17 I was able to use a Ubuntu PPA and sucessfully install ffmpeg!

    https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media

    Adding this PPA to your system

    You can update your system with unsupported packages from this untrusted PPA by adding ppa:mc3man/trusty-media to your system's Software Sources. (Read about installing)

    sudo add-apt-repository ppa:mc3man/trusty-media
    sudo apt-get update

    Solution Now Install ffmpeg!
          

    sudo apt-get install ffmpeg


  • phpBB3 slow and internal dummy connection


    Using Apache 2.2 and PHP 5.6 PHPBB3 is very slow to respond.  Actually for some reason it takes so long to even register a log entry in access_log as in several seconds or a few minutes later it shows up in Apache.  All other vhosts and Apache access stops working and freezes until the request to access PHPBB3 slowly completes.

    It seems to randomly be slow if you stop using it whether for posting or reading the forums.  I've migrated to different machines including SSD and the problem has not changed at all.  Some have posted that the internal dummy connection means Apache is killing off dead workers.

    I've never had an issue like this with any PHP app except PHPBB3


    80.38.44.5 - whichuser [19/May/2017:03:23:37 -0400] "GET /forums/cron.php?cron_type=cron.task.core.tidy_warnings HTTP/1.1" 200 43 "https://192.168.5.8/forums/posting.php?f=4&mode=edit&p=25&t=24&sid=71000a75c63243f82054d4717c6316bf" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
    127.0.0.1 - - [19/May/2017:03:23:42 -0400] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.15 (CentOS) (internal dummy connection)"


    127.0.0.1 - - [19/May/2017:03:26:23 -0400] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.15 (CentOS) (internal dummy connection)"

     

    this issue is accompanied by a delay in any logging activity of a few minutes and then suddenly it loads the destination page and a cron script:

    192.168.1.29 - whichuser [25/May/2017:01:50:15 -0400] "POST /phpBB3/ucp.php?mode=login&sid=b5a1c0e5f9bb2a9474e8ceaee3f21c8e HTTP/1.1" 302 - "https://192.168.1.144/phpBB3/viewtopic.php?f=4&t=31&sid=f9b1b31d209b729fda25227ccc27d2e7" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
    192.168.1.29 - whichuser [25/May/2017:01:50:15 -0400] "GET /phpBB3/viewtopic.php?f=4&t=31&sid=713b30d33575fcedca22f04c9d3d7739 HTTP/1.1" 200 27900 "https://192.168.1.144/phpBB3/viewtopic.php?f=4&t=31&sid=f9b1b31d209b729fda25227ccc27d2e7" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
    192.168.1.29 - whichuser [25/May/2017:01:50:16 -0400] "GET /phpBB3/cron.php?cron_type=cron.task.core.tidy_cache HTTP/1.1" 200 43 "https://192.168.1.144/phpBB3/viewtopic.php?f=4&t=31&sid=713b30d33575fcedca22f04c9d3d7739" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
    127.0.0.1 - - [25/May/2017:01:50:22 -0400] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.15 (CentOS) (internal dummy connection)"


  • check if Apache uses worker MPM or prefork MPM




    apachectl -l
    Compiled in modules:
      core.c
      prefork.c
      http_core.c
      mod_so.c



    It is "prefork.c" so in httpd.conf these settings are what you would use (if you use worker.c it won't have any impact):

    <IfModule prefork.c>
    StartServers      2
    MinSpareServers   5
    MaxSpareServers   20
    ServerLimit      300
    MaxClients       300
    #MaxRequestsPerChild  0
    MaxRequestsPerChild 100
    </IfModule>


  • text to speech for Linux


    espeak - is horrible and sounds very old and robotic
    echo "hello there"|espeak

    #don't know how to use
    mbrola and plugins
    cicero

    jovie just seems to be a graphical interface to espeak

    There is also sbreader/sapi

    Google's Text To Speech Works Quite Well

    #!/bin/bash
    say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$*&tl=en"; }
    say $*

    How to use the script:

    ./script.sh "hello there my name is John"

    The above produces an error by plays just fine:

    mplayer: could not connect to socket
    mplayer: No such file or directory


  • How to convert xlsx/xls Excel file into csv


    A lot of times these files seem to lag and be incredibly slow even if just a few dozens rows of data.

    Here is how you can convert it with "gnumeric":

    ssconvert file.xlsx file.csv
     

    You may get lots of weird errors like this but the conversion seems to work fine:

    (ssconvert:15244): GLib-GObject-WARNING **: g_object_set_valist: object class 'SheetObjectImage' has no property named 'style'

    (ssconvert:15244): GLib-GObject-WARNING **: g_object_set_valist: object class 'SheetObjectImage' has no property named 'style'

    (ssconvert:15244): GLib-GObject-WARNING **: g_object_set_valist: object class 'SheetObjectImage' has no property named 'style'

    (ssconvert:15244): GLib-GObject-WARNING **: g_object_set_valist: object class 'SheetObjectImage' has no property named 'style'

    (ssconvert:15244): GLib-GObject-WARNING **: g_object_set_valist: object class 'SheetObjectImage' has no property named 'style'

    (ssconvert:15244): GLib-GObject-WARNING **: g_object_set_valist: object class 'SheetObjectImage' has no property named 'style'

    (ssconvert:15244): GLib-GObject-WARNING **: g_object_set_valist: object class 'SheetObjectImage' has no property named 'style'


  • Linux bash script how to generate a random password using /dev/urandom


    This command will generate a random password using all letters and numbers that is 20 characters wrong based on /dev/urandom (for the most truly random output).

    echo `< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-20};echo;`


  • ssh forward multiple ports in the same connection and command even works with NAT!


    You can actually just pass multiple "-L" statements to achieve this.

    An example is as below:

    ssl -L 80:192.168.10.5:80 -L 443:192.168.10.5:443 -L 2068:192.168.10.5:2068 -L 8192:192.168.10.5:8192  user@remotehost.com
     

    The above essentially is saying forward ports 80,443,2068,8192 to the remote IP of 192.168.10.5 (even though it is behind NAT).  Essentially SSH will do the NAT part even if there is no NAT translation/ masquerade on the target.

    Remember the port number on the left is the local port number you will access by and the number on the right is the destination IP's port


  • How to create openssl md5 password hash to use in /etc/shadow using bash


    Very useful in embedded and other non-standard deployments.  The above makes a random salt of 14 random characters from /dev/urandom (you can change the -14 to whatever number of characters you want for your salt).

    openssl passwd -1 -salt `< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-14};echo;` YourPassword

    Output:

    $1$eW-ScuyL$f/iKMJ5mbJ..7bSzvX6EO0
     

     


  • Avocent DSR8020 KVM/IP - Network Connect Error - Solution


    This error is commonly due to Java security or TLS settings but there is a second issue with forwarded ports that also causes it.

     

    1. Java Security/TLS Settings issue:

    This article has the solution to change them all in Linux automatically

    2. Port Forwarding Issue if your Avocent DSR is behind NAT/private IP

    One would assume if you can get to the interface successfully via port 80/443 that all would be well but it's not enough.

    Actually a port scan shows the following ports are open on the DSR:

    PORT     STATE SERVICE
    80/tcp   open  http
    443/tcp  open  https
    2068/tcp open  advocentkvm
    3211/tcp open  avsecuremgmt
    3871/tcp open  avocent-adsap
    8192/tcp open  sophos
    

    You could forward all above ports but for normal functionality they are not required unless you are using the Avocent software I believe.

    Forward these ports to your private IP of the Avocent DSR:

    80,443,2068,8192

    An example in iptables of how to forward the ports:

    -s 192.168.5.4/32 #this is the only public IP that can access it (you can do away with this line if you want any remote IP to have access but for security this is recommended.  I find the unit itself tends to crash from attacks/hacking attempts when left wide open to the public.

    iptables -A PREROUTING -t nat -s 192.16.5.4/32 -d 103.2.5.2/32 -p tcp -m multiport --dports 80,443,2068,8192,3871,3211 -j DNAT --to 192.168.10.5

    The same portforwarding can also be achieved with OpenSSH like this:

    *Replace 192.168.10.5 with the NAT IP of your Avocent DSR unit

    ssl -L 80:192.168.10.5:80 -L 443:192.168.10.5:443 -L 2068:192.168.10.5:2068 -L 8192:192.168.10.5:8192  user@remotehost.com
     

    Other related Avocent DSR issues

    http://realtechtalk.com/Avocent_Unable_to_load_resource_avctVideojar-1646-articles

    http://realtechtalk.com/Avocent_8020_KVM_Java_Icedtea_Viewer_-1702-articles


  • PHP Parse error: syntax error, unexpected '[' in phpBB3/vendor/react/promise/src/functions.php on line 15


    The solution is simple this happens if you don't meet the requirements.  In my case PHP 5.4 was required but I had PHP 5.3 installed.  Once I installed a newer version the install of PHPBB was successful.


  • tar extraction changes ownership of /root directory


    I have a tar and when extracting it changes /root to a uid and gid of the source server which is bad especially for /root!

    You can get around this by extracting as follows:

    Add the -o switch which means "--no-same-owner"

    tar -o -zxvf sometar.tar.gz


  • Centos 7 Migration Guide from Centos 6


    Centos 7 is no cakewalk, there are many fundamental features and basic utilities that are missing or even completely renamed or different!

    List of utilities and how to get them:

     

    ifconfig

    yum -y install net-tools

    killall

    yum -y install psmisc

     

     


  • ubuntu Linux colour dropper picker


    gpick is a great and simple tool now that I now how to use it

    sudo apt-get install gpick

    The trick is to find "the swatch"

    I was in a rush and was frustrated that it wouldn't work how I expected and I had to memorize the hex code of the color my mouse was over.

    There is something it tells you to do which is "Click on the swatch area" (click onthe honeycomb graphic area that is the swatch) and then whenever you hit the "spacebar" the code will be recorded on the right side for you to copy and refer to later. 


  • zip warning: name not matched: in Linux Solution


    There are usually two reasons for this.

    #1 The most common is that you need to enable the -r (recursive) flag with zip to make it recurse into directories.

    So the solution is to use -r

    zip -r somefile.zip yourfiles

    #2 If you are using bash scripting based on ls without the full path or for some other reason the full path is missing, zip looks for the files in the current directory so this will always fail.

    filelist=`ls -1 thedirectory`

    The problem is that ls just lists the files off as if it were in the current directory and this is why zip is complaining (essentially the files do not exist to zip because it is being told to look in the wrong/current directory).

    If this is your issue you can correct it like so:

     

    filelist=`ls -1d thedirectory/*`

    You add the "-d" switch and also /* at the end of the directory.

     


  • ls in Linux with full directory path with files howto


    Normally an ls will just produce the actual contents of the current or target directory eg.

    ls mydir

    myfile1

    myfile2

    myfile3

    But what if you need to find the full or relative path to another program that cares whether that be zip or etc.?

    You need the "-d" switch and the asterisk inside the actual directory.

    ls -d mydir/*

    mydir/myfile1

    mydir/myfile2

    mydir/myfile3

     


  • bash how to check if a symlink exists as a file or directory


    To check if a file/directory is a symlink in bash:

    if [ -L /some/path/file ]; then

    echo "OK we're a symlink"

    fi

     

    That's all there is to it.


  • css .ul and .li how to remove the identation padding/margin from list items?


    A common mistake is people think you should tell the li padding to be 0px but this is wrong.

    All you need is the following code in line:

    <ul style="margin:0px">

    <li>your item</li>

    <li>your item</li>

    </ul>

    In a css class:

    .yourclass {

    ul.margin: 0px;

    }


  • how to extract .xz file in Linux Centos/Debian/Ubuntu


    tar -xvJf somefile.tar.xz

    It is very annoying that so many are now using the .xz archive format as standard instead of .tar.gz but nevertheless above is how you would extract it with the "J" flag (not lower case j as that is for bz).


  • Linux how to whois query other gTLDs such as .club solution


    whois in Linux is incredibly out of date and does not seem to recognize most new TLDs domains, but there is a quick and easy tip/hack/tweak for this.

    An example of new TLD's site as .review .site .club

    whois somesite.club

    No whois server is known for this kind of object.
     

    bash to the rescue

    Now I did try to apply this in .bashrc but DO NOT!  I think the * wildcard or something else in the code causes a recursive infinite loop that will slow or cash your computer. (I am not kidding I had a load of 1000!).

    1.) The bash script (finds the whois server for the .tld and queries it):

    #!/bin/bash
    server=$1
    whois -h `whois "$1" -h whois.iana.org| grep whois:| sed -e s/whois:\s*//` "$1"

    2.) Save it to a file in your home ~/whoisserver.sh

    3.) Edit ~/.bashrc

    Add the following:

    function whois() { /home/yourdir/whoisserver.sh $1; }

    To apply instantly in your current shell/bash:

    source .bashrc

    The reason I used a function is because it supports variables whereas a bash "alias" does not.


  • How to verify SSL SHA-1 Certificate Fingerprnit Signature of your mail/web server to avoid hijacking/man-in-the-middle attacks


    This is especially helpful if you run your own servers.  If you are presented with an error message or warning that the signature has changed or does not match the IP/domain you are connecting to you always want to verify manually.

    So your e-mail/web client will show you an SHA-1 fingerprint like this:

    "Could not verify this certificate because the issuer is unkown" or other reasons such as a mismatch in IP/domain.

    It will also show you the "SHA1 fingerprint".   Copy this and compare below with the results of your actual server certificate.

    How to verify it against the actual certificate on your server?:

    openssl x509 -fingerprint -in /pathto/your-certificate.crt -noout

    SHA1 Fingerprint=CD:32:57:8A:66:18:71:87:81:B8:A5:F6:2E:52:3D:15:C5:A9:41:06

    How to manually fetch the SHA1 certificate straight from the server to compare?

    openssl s_client -showcerts -connect yourdomain.com:port 2>/dev/null|openssl x509 -fingerprint -noout

    Conclusion

    This is an important and good way to verify that you are actually talking to who you think you are and that there is no direct interception or Middleman attack.


  • Linux Ubuntu Mint how to view RAW image files .arw?


    I just use "ufraw" and it does the trick perfectly. Now I wish I could figure out how to batch convert them into .jpg with ImageMagick (it seems support for .raw is not guaranteed or it has to be compiled in).

    apt-get install ufraw


  • ecryptfs errors


    ecryptfs-mount-private
    Enter your login passphrase:
    Inserted auth tok with sig [ee16d84] "into the user session keyring
    mount: No such file or directory"


    [  156.118113] ecryptfs_mount: kern_path() failed
    [  156.118431] Reading sb failed; rc = [-2]
    [  164.233055] traps: mate-notificati[3472] trap int3 ip:7f43d7002c13 sp:7fff162c6600 error:0
    [  166.017061] ecryptfs_mount: kern_path() failed
    [  166.017323] Reading sb failed; rc = [-2]

    The reason for this is that you don't have the .Private directory for your user symlinked from /home/.ecryptfs/user/.Private to your home directory or .Private does not exist (common mistake when migrating ecryptfs data to another system).

    Solution:

    rsync -Phaz /home/.ecryptfs/yourusername/.Private ~


  • What happens when you unplug 1 or more devices from an mdadm RAID array to simulate a failure in Linux Ubuntu/Centos/Debian?



    In short the two drives in the array were /dev/sdd and /dev/sde.  The kernel sees they were unplugged and have gone down as you can see below.
    mdadm caught the first one being unplugged /dev/sde and disabled the missing drive.  However when the final drive that was part of the array is unplugged it didn't notice at all.  Instead it complains about an IO error later for drives that the kernel knows do not exist anymore.

    [45817.162728] ata4: exception Emask 0x10 SAct 0x0 SErr 0x1810000 action 0xe frozen
    [45817.162744] ata4: SError: { PHYRdyChg LinkSeq TrStaTrns }
    [45817.162757] ata4: hard resetting link
    [45817.162763] ata4: nv: skipping hardreset on occupied port
    [45817.875776] ata4: SATA link down (SStatus 0 SControl 300)
    [45822.876730] ata4: hard resetting link
    [45822.876743] ata4: nv: skipping hardreset on occupied port
    [45823.188801] ata4: SATA link down (SStatus 0 SControl 300)
    [45823.188825] ata4: limiting SATA link speed to 1.5 Gbps
    [45828.189782] ata4: hard resetting link
    [45828.189796] ata4: nv: skipping hardreset on occupied port
    [45828.501840] ata4: SATA link down (SStatus 0 SControl 300)
    [45828.501862] ata4.00: disabled
    [45828.501889] ata4: EH complete
    [45828.501917] ata4.00: detaching (SCSI 4:0:0:0)
    [45828.507327] sd 4:0:0:0: [sde] Synchronizing SCSI cache
    [45828.507413] sd 4:0:0:0: [sde]
    [45828.507419] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    [45828.507425] sd 4:0:0:0: [sde] Stopping disk
    [45828.507443] sd 4:0:0:0: [sde] START_STOP FAILED
    [45828.507448] sd 4:0:0:0: [sde]
    [45828.507451] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    [45828.513870] md/raid10:md2: Disk failure on sde3, disabling device.
    [45828.513870] md/raid10:md2: Operation continuing on 1 devices.
    [45828.515601] md/raid1:md0: Disk failure on sde1, disabling device.
    [45828.515601] md/raid1:md0: Operation continuing on 1 devices.
    [45828.515699] md/raid1:md1: Disk failure on sde2, disabling device.
    [45828.515699] md/raid1:md1: Operation continuing on 1 devices.
    [45828.550897] RAID1 conf printout:
    [45828.550907]  --- wd:1 rd:2
    [45828.550914]  disk 0, wo:1, o:0, dev:sde1
    [45828.550919]  disk 1, wo:0, o:1, dev:sdd1
    [45828.550922] RAID1 conf printout:
    [45828.550926]  --- wd:1 rd:2
    [45828.550929]  disk 0, wo:1, o:0, dev:sde2
    [45828.550933]  disk 1, wo:0, o:1, dev:sdd2
    [45828.557889] RAID1 conf printout:
    [45828.557891] RAID1 conf printout:
    [45828.557898]  --- wd:1 rd:2
    [45828.557901]  disk 1, wo:0, o:1, dev:sdd2
    [45828.557908]  --- wd:1 rd:2
    [45828.557913]  disk 1, wo:0, o:1, dev:sdd1
    [45828.564720] RAID10 conf printout:
    [45828.564742]  --- wd:1 rd:2
    [45828.564749]  disk 0, wo:1, o:0, dev:sde3
    [45828.564751]  disk 1, wo:0, o:1, dev:sdd3
    [45828.569892] RAID10 conf printout:
    [45828.569895]  --- wd:1 rd:2
    [45828.569898]  disk 1, wo:0, o:1, dev:sdd3
    [45828.584569] md: unbind

    [45828.584599] md: unbind

    [45828.601887] md: export_rdev(sde2)
    [45828.606689] md: unbind

    [45828.609925] md: export_rdev(sde1)
    [45828.625934] md: export_rdev(sde3)
    [45853.787165] ata3: exception Emask 0x10 SAct 0x0 SErr 0x1910000 action 0xe frozen
    [45853.787181] ata3: SError: { PHYRdyChg Dispar LinkSeq TrStaTrns }
    [45853.787194] ata3: hard resetting link
    [45853.787199] ata3: nv: skipping hardreset on occupied port
    [45854.502904] ata3: SATA link down (SStatus 0 SControl 300)
    [45859.503897] ata3: hard resetting link
    [45859.503910] ata3: nv: skipping hardreset on occupied port
    [45859.815936] ata3: SATA link down (SStatus 0 SControl 300)
    [45859.815959] ata3: limiting SATA link speed to 1.5 Gbps
    [45864.816953] ata3: hard resetting link
    [45864.816970] ata3: nv: skipping hardreset on occupied port
    [45865.128991] ata3: SATA link down (SStatus 0 SControl 300)
    [45865.129016] ata3.00: disabled
    [45865.129049] ata3: EH complete
    [45865.129082] ata3.00: detaching (SCSI 3:0:0:0)
    [45865.134492] sd 3:0:0:0: [sdd] Synchronizing SCSI cache
    [45865.134606] sd 3:0:0:0: [sdd]
    [45865.134612] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    [45865.134618] sd 3:0:0:0: [sdd] Stopping disk
    [45865.134638] sd 3:0:0:0: [sdd] START_STOP FAILED
    [45865.134643] sd 3:0:0:0: [sdd]
    [45865.134647] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK


    [46361.713303] Buffer I/O error on device md2, logical block 0
    [46361.713321] Buffer I/O error on device md2, logical block 1
    [46361.713333] Buffer I/O error on device md2, logical block 2
    [46361.713343] Buffer I/O error on device md2, logical block 3
    [46361.713352] Buffer I/O error on device md2, logical block 0
    [46361.713374] Buffer I/O error on device md2, logical block 177343231
    [46361.713383] Buffer I/O error on device md2, logical block 177343231
    [46361.713479] Buffer I/O error on device md2, logical block 0
    [46361.713491] Buffer I/O error on device md2, logical block 1
    [46361.713500] Buffer I/O error on device md2, logical block 2


    See below it believes the last drive (sdd) to be unplugged is still plugged in!


    Personalities : [raid10] [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4]
    md0 : active raid1 sdd1[2]
          20955008 blocks super 1.2 [2/1] [_U]
       
    md1 : active raid1 sdd2[1]
          2097088 blocks [2/1] [_U]
       
    md2 : active raid10 sdd3[2]
          709372928 blocks super 1.2 512K chunks 2 far-copies [2/1] [_U]
          bitmap: 0/6 pages [0KB], 65536KB chunk

     


  • Migrating from Linux Mint 17.2 mdadm RAID array to a new one (because I upgraded to larger drives).



    1.) Replicate the number of partitions in your new drives.
    gdisk /dev/sda
    gdisk /dev/sdb

    I created 3 partitions of the same same size.
    partition #1: +1G (/boot)
    partition #2: +60G (swap)
    partition #3: rest of it (/)

    #note if you are using GPT/gdisk you need to create separate a partition at least 1MB in size (in my case I would a 4th partition and mark it type ef02).

    Note again do not make my mistake.  You cannot just mark your grub /boot partition as ef02, it will not boot (despite grub2 not complaining during install).


    gdisk /dev/sdc
    GPT fdisk (gdisk) version 0.8.8

    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present

    Found valid GPT with protective MBR; using GPT.

    Command (? for help): t
    Partition number (1-3): 1
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): ef02
    Changed type of partition to 'BIOS boot partition'

    Command (? for help): wq

    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
    PARTITIONS!!




    2.) Create 3 new mdadm arrays that are suitable:


    Note the first mdadm array is my boot so I use RAID 1 and metadata=0.90 (or it will not be able to read/boot)


    mdadm --create /dev/md51 --metadata=0.90 --level 1 --raid-devices 2 /dev/sdb1 /dev/sdc1
    mdadm --create /dev/md52 --level 10 --layout f2 --raid-devices 2 /dev/sdb2 /dev/sdc2
    mdadm --create /dev/md53 --level 10 --layout f2 --raid-devices 2 /dev/sdb3 /dev/sdc3


    Note md51=/boot
         md52=swap
         md53=/
    3.) Create appropraite filesystems:

    mkfs.ext4 /dev/md51
    mkswap /dev/md52
    mkfs.ext4 /dev/md53

    Note md51=/boot
         md52=swap
         md53=/

    4.) Mount them and prepare to migrate

    I am going to use /mnt/newinstall as the staging ground.

    #make staging dir
    mkdir -p /mnt/newinstall
    #make boot and / inside stage:


    #mount them
    mount /dev/md53 /mnt/newinstall/
    mkdir -p /mnt/newinstall/boot
    mount /dev/md51 /mnt/newinstall/boot


    5.) Migrate with rsync

    I am going to omit /media/* and /mnt/* to avoid copying other mounted devices

    *If you have ecryptfs you will want to exclude /home/user if mounted so you don't copy both encrypted and decrypted files (doubling your storage usage and also exposing an unencrypted copy of your data).


    rsync -Pha --exclude=/proc/* --exclude=/sys/* --exclude=/home/user/* --exclude=/media/* --exclude=/mnt/* / /mnt/newinstall/
    #rsync the .ecryptfs info to your user or you will lose access be unable to auto-mount it

    rsync -Phaz /home/user/.ecryptfs /mnt/newinstall/home/user

    rsync -Phaz /home/user/.Private /mnt/newinstall/home/user

    6.) chroot and prepare environment.
    mount=/mnt/newinstall
    for bind in dev sys proc; do
    mount -o bind /$bind /$mount/$bind
    done

    chroot /mnt/newinstall
    grub-install /dev/sda
    grub-install /dev/sdb
    update-grub



    #update mdadm
    #backup
    cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf-`date +%Y-%m-%d-%s`
    mdadm --detail --brief --scan > /etc/mdadm/mdadm.conf



    #update /etc/fstab /boot, /, and swap, with the right blkid
    vi /etc/fstab

    UUID=1119d26-da8e-4317-a5cb-834402b90501 /               ext4    errors=remount-ro 0       1
    UUID=22296bff-79c5-4d19-b343-e21d10c5fe9b TYPE=ext4 /boot           ext4    defaults        0       2
    UUID=44423ded-5e6b-4f16-9ca9-b8ef69ce00ed none            swap    sw              0       0


    blkid /dev/md51
    blkid /dev/md52
    blkid /dev/md53

    Note md51=/boot
         md52=swap
         md53=/

    #update initramfs

    update-initramfs -u


  • Linux how to reformat html file code solution


    The solution is simply "tidy"/Tidy-HTML.  It will take your poorly formatted HTML code (and I mean files that span just a few lines that are unreadable) and fix it up.

    Note the command below does everything in place.  *Make sure you take a backup of all .html files*

    It also seems to break html5 code/templates so beware.

    tidy -im yourfile.html

    An automated way in bash:

    cd /your/website/directory

    for html in `find .|grep ".html$"`; do

    tidy -im $html

    done


  • ENOM how to do a 301 redirect to another domain/site


    Just manage your domain in Enom and choose "Host Records"

    Choose "URL Redirect" as the record type.

    As shown below choose the URL and add "?redir_mode=301" to the end of it.

    To test the 301 and make sure it is a 301 (unlike Godaddy which really did a 302 when I chose 301!).

     


  • ENOM TRANSFER passwords do not match - solution


    The "passwords do not match" implies or makes it appear that your auth code is wrong but actually you have to click "View additional settings" and then see there are 2 password fields to manage the domain once it is transferred (the password is typed twice for confirmation).  Simply fill out a password twice or remove the first password fields contents and all will be well.

     

    The Solution:

    Fix the issue with the "Access Password".  Either remove the first password field's contents or type your password in both fields.


  • Linux how to check http headers using bash/curl for SEO


    What code is being returned or where is a URL/domain redirecting you to?  Curl makes this easy and simple:

    curl -I yourdomain.com


  • mdadm: CREATE group disk not found Incrementally started RAID arrays. Incrementally starting RAID arrays...


    mdadm won't boot in Ubuntu/Mint/Debian anymore.

    You just get the following in a loop:

    mdadm: CREATE group disk not found
    
    Incrementally started RAID arrays.
    
    Incrementally starting RAID arrays...
    
    mdadm: CREATE group disk not found
    
    Incrementally started RAID arrays.
    
    Incrementally starting RAID arrays...
    
    mdadm: CREATE group disk not found
    
    Incrementally started RAID arrays.
    
    Incrementally starting RAID arrays...
    
    mdadm: CREATE group disk not found
    
    Incrementally started RAID arrays.
    
    Incrementally starting RAID arrays...

    Solution

    In Linux Mint 17.2 which is based on Ubuntu/Debian the issue was I am using the 3.0 Kernel, but I upgraded the kernel to a 4.4.

    Simply "hold shift" before the grub boot screen and boot your old 3.0 kernel and remove the 4.4 to boot again.

    There is definitely some bug or incompatibility that was introduced, it may be in the initramfs etc.. but this is a quick fix in case you can't boot.


  • Linux SAMBA does not work with symlinks


    At first I thought it's just not possible but there is actually an option that can be enabled to make symlinks work with Samba.

    Then I put this under the [global] section
    Note: It's "wide links" and not "wide symlinks" (some other sites have incorrect info which was a frustrating waste of time :))
     

    Add this to your smb.conf

    follow symlinks = yes
    wide links = yes
    unix extensions = no


     


  • How to Execute PHP in .html files with Apache in Linux Centos/Debian/Ubuntu etc


    Add this to the .htaccess file

    #right/working:

    AddType application/x-httpd-php .html .htm
     

    #wrong (won't work in many cases):
    AddHandler application/x-httpd-php5 .html .htm


  • mdadm how to recover from failed drive


    Remove the failed partition /dev/sde1

     mdadm --manage /dev/md99 -r /dev/sde1
    mdadm: hot removed /dev/sde1 from /dev/md99

     

    Now add another drive back to replace it:


     # mdadm --manage /dev/md99 -a /dev/sdf1
    mdadm: added /dev/sdf1

     

    A "cat /proc/mdstat" should show it resyncing if all is well.


  • yum Packages skipped because of dependency problems:


    Solution:

    yum -y install --skip-broken package-you-want-to-install

    Packages skipped because of dependency problems:
        php56w-mysql-5.6.30-1.w6.x86_64 from webtatic
    Error:  Multilib version problems found. This often means that the root
           cause is something else and multilib version checking is just
           pointing out that there is a problem. Eg.:
          
             1. You have an upgrade for apr which is missing some
                dependency that another package requires. Yum is trying to
                solve this by installing an older version of apr of the
                different architecture. If you exclude the bad architecture
                yum will tell you what the root cause is (which package
                requires what). You can try redoing the upgrade with
                --exclude apr.otherarch ... this should give you an error
                message showing the root cause of the problem.
          
             2. You have multiple architectures of apr installed, but
                yum can only see an upgrade for one of those arcitectures.
                If you don't want/need both architectures anymore then you
                can remove the one with the missing update and everything
                will work.
          
             3. You have duplicate versions of apr installed already.
                You can use "yum check" to get yum show these errors.
          
           ...you can also use --setopt=protected_multilib=false to remove
           this checking, however this is almost never the correct thing to
           do as something else is very likely to go wrong (often causing
           much more problems).
          
           Protected multilib versions: apr-1.3.9-5.el6_2.i686 != apr-1.5.2-2.x86_64
    Error: Protected multilib versions: apr-util-1.3.9-3.el6_0.1.i686 != apr-util-1.5.4-2.x86_64


  • Using a proxy with yum in Centos 6


    Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
    12: Timeout on http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
    Error: Cannot find a valid baseurl for repo: base



    You would think this should be fine and simple like using a proxy with most other software?
    However you would be severely mistaken to think like I did!

    First of all yum CANNOT even use a SOCKS server, it only supports http://!
    Fine, so we will set one in yum.conf like so: proxy=http://somehost:8080

    Another way is to set an all_proxy or http_proxy environment variable (this saves you from adding the proxy to yum itself but beware it means all operations are proxied):

    export all_proxy="http://someurl:8080"
    #or
    export http_proxy="http://someurl:8080"


    Let's do a yum update:

    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
    12: Timeout on http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
    Error: Cannot find a valid baseurl for repo: base


    The problem is that due to Squid's caching nature you will never get a proper result so the mirror list operation will always fail.

    How can you fix it?
    It's a pain, you have to go to your repos and comment out all the "mirrorlist" lines and uncomment "baseurl" lines (be sure to backup the .conf/repo before you do this).

    It is really too bad there is no "seamless" way of proxying yum.


  • How Do you Open/Extract .WARC Internet Archive Files on Linux Ubuntu/Mint/Centos?


    Get the python "warc extractor" from here.  WARC just seems to be such an unnecessary and complicated format.  Why not use tar, rar, zip etc...?

     

    ./warc-extractor.py -dump content !http:content-type:pdf yourfile.warc

  • How To Disable htaccess inheritance or exclude a directory


    The only real way us to do the following in the root of your site's .htaccess

    RewriteRule ^somedirectory-not-to-inherit/.*$ - [L]


  • root/home directory has ownership changed to the wrong user/owner mysteriously


    I figured out what caused this but don't have the solution just yet.  I would deploy a certain script from a .tar.gz to some servers and found that /root was always owned by user and group "1000.1000".  This corresonded to the user who made the .tar.gz.

    For some reason when extract normally with "tar -zxvf file.tar.gz" it impacts the parent directories ownership.  There must be some recursion going on or possibly the .tar.gz but I haven't found the solution.


  • mdadm and lvm how to completely disable and remove vg/pv/lv


    In short the solution is just to use vgremove for the actual /dev/mapper device:

    vgremove /dev/mapper/backups-backuplv


     

    box mnt # mdadm --manage /dev/md8 --stop
    mdadm: Cannot get exclusive access to /dev/md8:Perhaps a running process, mounted filesystem or active volume group?
    box mnt # lv
    lvchange     lvconvert    lvcreate     lvdisplay    lvextend     lvm          lvmchange    lvmconf      lvmdiskscan  lvmdump      lvmsadc      lvmsar       lvreduce     lvremove     lvrename     lvresize     lvs          lvscan
    box mnt # pvdisplay
      --- Physical volume ---
      PV Name               /dev/md8
      VG Name               backups
      PV Size               7.28 TiB / not usable 4.00 MiB
      Allocatable           yes
      PE Size               4.00 MiB
      Total PE              1907688
      Free PE               20251
      Allocated PE          1887437
      PV UUID               IDnmlM-2r3q-McwV-y2at-djxK-DvPM-sFqlTo
      
    box mnt # pvchange --help
      pvchange: Change attributes of physical volume(s)

    pvchange
        [-a|--all]
        [-A|--autobackup y|n]
        [-d|--debug]
        [-f|--force]
        [-h|--help]
        [-t|--test]
        [-u|--uuid]
        [-x|--allocatable y|n]
        [--metadataignore y|n]
        [-v|--verbose]
        [--addtag Tag]
        [--deltag Tag]
        [--version]
        [PhysicalVolumePath...]

    box mnt # pvchange --help^C
    box mnt # pvremove /dev/md8
      PV /dev/md8 belongs to Volume Group backups so please use vgreduce first.
      (If you are certain you need pvremove, then confirm by using --force twice.)
    box mnt # vgdisplay
      --- Volume group ---
      VG Name               backups
      System ID            
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  2
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                1
      Open LV               0
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               7.28 TiB
      PE Size               4.00 MiB
      Total PE              1907688
      Alloc PE / Size       1887437 / 7.20 TiB
      Free  PE / Size       20251 / 79.11 GiB
      VG UUID               DwxSxL-UmcV-TyjM-TUa1-ef4w-lrK5-cipxiI
      
    box mnt # vgremove /dev/^C
    box mnt # ls /dev/m
    mapper/  mcelog   md/      md0      md0p1    md1      md1p1    md2      md20     md2p1    md8      md99     mem      mpt2ctl 
    box mnt # ls /dev/m
    mapper/  mcelog   md/      md0      md0p1    md1      md1p1    md2      md20     md2p1    md8      md99     mem      mpt2ctl 
    box mnt # ls /dev/mapper/
    backups-backuplv  control          
    box mnt # vgremove /dev/mapper/backups-backuplv
      Invalid volume group name: backups/backuplv
      Run `vgremove --help' for more information.
    box mnt # vgremove /dev/mapper/backups
    Do you really want to remove volume group "backups" containing 1 logical volumes? [y/n]: y
    Do you really want to remove and DISCARD active logical volume backuplv? [y/n]: y
      Logical volume "backuplv" successfully removed
      Volume group "backups" successfully removed
    box mnt #
     


  • sshd[10470]: Authentication refused: bad ownership or modes for directory /root


    This can be a case of bad permissions or modes as the error says.  Normally one would assume permissions but often a script may change ownership of /root to something else.

    This was the case half the time I've encountered this.

    So in short make sure ownership is correct

    chown -R root.root /root


  • LG Phoenix 2 Escape Disable AT&T Phonebook/Contacts Error Message


    A friend has this issue where you try to go to contacts and you get a message saying you need to enable data (basically if you are not really on the AT&T network).

    The Solution - You can disable this by the following code in the dialer:

    *#*#2666#*#*


  • mdadm frozen and doesn't realize array is dead/missing failed due to unplugged drives


    This was a surprising bug but I unplugged all drives for an array md127.  At first it was just 1 drive and mdadm seemed to notice this.  I unplugged the second drive taking the array offline but mdadm did not realize it was offline and still showed a non-existent disk as being part of it.  This created problems trying to unmount it or even to stop this array with mdadm freezing. 

    As for how to fix it I can only think of making sure you are not in a mounted path of the array, unmount it and then manually stop the array but this didn't seem to work until the hung task kicked in.

    mdadm --manage /dev/md127 --stop

     

    The resulting kernel messages are what followed:

     

    8586.047108] EXT4-fs error (device md127): __ext4_get_inode_loc:3932: inode #12058625: block 48234528: comm pool: unable to read itable block
    [48586.047119] EXT4-fs (md127): previous I/O error to superblock detected
    [48586.047207] Buffer I/O error on device md127, logical block 0
    [48586.047216] lost page write due to I/O error on md127
    [48586.248009] md: super_written gets error=-19, uptodate=0
    [48594.634065] md: super_written gets error=-19, uptodate=0
    [48594.634173] Buffer I/O error on device md127, logical block 91258880
    [48594.634186] lost page write due to I/O error on md127
    [48594.634221] JBD2: Error -5 detected when updating journal superblock for md127-8.
    [48594.634286] Buffer I/O error on device md127, logical block 91258880
    [48594.634299] lost page write due to I/O error on md127
    [48594.634329] JBD2: Error -5 detected when updating journal superblock for md127-8.
    [48594.635892] EXT4-fs (md127): previous I/O error to superblock detected
    [48594.635974] Buffer I/O error on device md127, logical block 0
    [48594.635984] lost page write due to I/O error on md127
    [48594.837653] md: super_written gets error=-19, uptodate=0
    [48851.459776] init: smbd main process (1204) killed by TERM signal
    [48966.998219] Buffer I/O error on device md127, logical block 0
    [48966.998241] Buffer I/O error on device md127, logical block 0
    [48966.998267] Buffer I/O error on device md127, logical block 183110512
    [48966.998277] Buffer I/O error on device md127, logical block 183110512
    [48966.998295] Buffer I/O error on device md127, logical block 183110526
    [48966.998304] Buffer I/O error on device md127, logical block 183110526
    [48966.998315] Buffer I/O error on device md127, logical block 0
    [48966.998329] Buffer I/O error on device md127, logical block 1
    [48966.998337] Buffer I/O error on device md127, logical block 1
    [48966.998357] Buffer I/O error on device md127, logical block 183110527
    [49172.119413] md: md20 stopped.
    [49172.193601] md: bind<sdf1>
    [49184.251750] quiet_error: 124 callbacks suppressed
    [49184.251764] Buffer I/O error on device md127, logical block 183110512
    [49184.251778] Buffer I/O error on device md127, logical block 183110512
    [49184.251799] Buffer I/O error on device md127, logical block 183110526
    [49184.251808] Buffer I/O error on device md127, logical block 183110526
    [49184.251823] Buffer I/O error on device md127, logical block 0
    [49184.251831] Buffer I/O error on device md127, logical block 0
    [49184.251846] Buffer I/O error on device md127, logical block 1
    [49184.251854] Buffer I/O error on device md127, logical block 1
    [49184.251869] Buffer I/O error on device md127, logical block 183110527
    [49184.251877] Buffer I/O error on device md127, logical block 183110527
    [49210.081588] INFO: task mdadm:16228 blocked for more than 120 seconds.
    [49210.081605]       Tainted: P           OE 3.16.0-38-generic #52~14.04.1-Ubuntu
    [49210.081610] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [49210.081616] mdadm           D ffff88080fd530c0     0 16228  15783 0x00000004
    [49210.081627]  ffff88005539fc70 0000000000000082 ffff880804045180 ffff88005539ffd8
    [49210.081635]  00000000000130c0 00000000000130c0 ffff880804721460 ffff88005539fd98
    [49210.081642]  ffff88005539fda0 7fffffffffffffff ffff880804045180 0000000000000000
    [49210.081649] Call Trace:
    [49210.081668]  [<ffffffff817699f9>] schedule+0x29/0x70
    [49210.081677]  [<ffffffff81768dd9>] schedule_timeout+0x229/0x2a0
    [49210.081687]  [<ffffffff81087ef6>] ? __queue_work+0x136/0x320
    [49210.081694]  [<ffffffff810881aa>] ? __queue_delayed_work+0xaa/0x1a0
    [49210.081701]  [<ffffffff81088509>] ? try_to_grab_pending+0xa9/0x160
    [49210.081709]  [<ffffffff8176a4f6>] wait_for_completion+0xa6/0x160
    [49210.081718]  [<ffffffff810a1550>] ? wake_up_state+0x20/0x20
    [49210.081728]  [<ffffffff811fc97f>] writeback_inodes_sb_nr+0x7f/0xb0
    [49210.081735]  [<ffffffff811fc9d5>] writeback_inodes_sb+0x25/0x30
    [49210.081745]  [<ffffffff812039cd>] sync_filesystem+0x2d/0xa0
    [49210.081753]  [<ffffffff8120af24>] fsync_bdev+0x24/0x60
    [49210.081764]  [<ffffffff81366183>] blkdev_ioctl+0x433/0x7b0
    [49210.081772]  [<ffffffff8120a5c1>] block_ioctl+0x41/0x50
    [49210.081779]  [<ffffffff811e7360>] do_vfs_ioctl+0x2e0/0x4c0
    [49210.081788]  [<ffffffff811d96c5>] ? SYSC_newfstat+0x25/0x30
    [49210.081795]  [<ffffffff811e75c1>] SyS_ioctl+0x81/0xa0
    [49210.081804]  [<ffffffff8176da4d>] system_call_fastpath+0x1a/0x1f
    [49210.866657] quiet_error: 260 callbacks suppressed
    [49210.866670] Buffer I/O error on device md127, logical block 183110512
    [49210.866685] Buffer I/O error on device md127, logical block 183110512
    [49210.866705] Buffer I/O error on device md127, logical block 183110526
    [49210.866715] Buffer I/O error on device md127, logical block 183110526
    [49210.866729] Buffer I/O error on device md127, logical block 0
    [49210.866738] Buffer I/O error on device md127, logical block 0
    [49210.866753] Buffer I/O error on device md127, logical block 1
    [49210.866762] Buffer I/O error on device md127, logical block 1
    [49210.866777] Buffer I/O error on device md127, logical block 183110527
    [49210.866786] Buffer I/O error on device md127, logical block 183110527
    [49218.834738] md127: detected capacity change from 750020722688 to 0
    [49218.834759] md: md127 stopped.
    [49218.834776] md: unbind<sdc1>
    [49218.839214] md: export_rdev(sdc1)
    [49275.360612] init: smbd main process (16150) killed by TERM signal
    [49330.104883] INFO: task mdadm:16228 blocked for more than 120 seconds.
    [49330.104892]       Tainted: P           OE 3.16.0-38-generic #52~14.04.1-Ubuntu
    [49330.104895] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [49330.104898] mdadm           D ffff88080fd530c0     0 16228  15783 0x00000004
    [49330.104904]  ffff88005539fc70 0000000000000082 ffff880804045180 ffff88005539ffd8
    [49330.104908]  00000000000130c0 00000000000130c0 ffff880804721460 ffff88005539fd98
    [49330.104911]  ffff88005539fda0 7fffffffffffffff ffff880804045180 0000000000000000
    [49330.104916] Call Trace:
    [49330.104929]  [<ffffffff817699f9>] schedule+0x29/0x70
    [49330.104933]  [<ffffffff81768dd9>] schedule_timeout+0x229/0x2a0
    [49330.104939]  [<ffffffff81087ef6>] ? __queue_work+0x136/0x320
    [49330.104942]  [<ffffffff810881aa>] ? __queue_delayed_work+0xaa/0x1a0
    [49330.104946]  [<ffffffff81088509>] ? try_to_grab_pending+0xa9/0x160
    [49330.104949]  [<ffffffff8176a4f6>] wait_for_completion+0xa6/0x160
    [49330.104955]  [<ffffffff810a1550>] ? wake_up_state+0x20/0x20
    [49330.104960]  [<ffffffff811fc97f>] writeback_inodes_sb_nr+0x7f/0xb0
    [49330.104963]  [<ffffffff811fc9d5>] writeback_inodes_sb+0x25/0x30
    [49330.104969]  [<ffffffff812039cd>] sync_filesystem+0x2d/0xa0
    [49330.104973]  [<ffffffff8120af24>] fsync_bdev+0x24/0x60
    [49330.104979]  [<ffffffff81366183>] blkdev_ioctl+0x433/0x7b0
    [49330.104983]  [<ffffffff8120a5c1>] block_ioctl+0x41/0x50
    [49330.104987]  [<ffffffff811e7360>] do_vfs_ioctl+0x2e0/0x4c0
    [49330.104992]  [<ffffffff811d96c5>] ? SYSC_newfstat+0x25/0x30
    [49330.104995]  [<ffffffff811e75c1>] SyS_ioctl+0x81/0xa0
    [49330.104999]  [<ffffffff8176da4d>] system_call_fastpath+0x1a/0x1f
    [49488.994434] md/raid10:md20: active with 1 out of 2 devices
    [49488.994492] md20: detected capacity change from 0 to 750020722688
    [49489.014456]  md20: unknown partition table
    [49505.301904] EXT4-fs (md20): recovery complete
    [49505.319010] EXT4-fs (md20): mounted filesystem with ordered data mode. Opts: (null)
    [49524.680801] systemd-hostnamed[16729]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!
    [49570.151706] INFO: task mdadm:16228 blocked for more than 120 seconds.
    [49570.151723]       Tainted: P           OE 3.16.0-38-generic #52~14.04.1-Ubuntu
    [49570.151728] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [49570.151734] mdadm           D ffff88080fd530c0     0 16228  15783 0x00000004
    [49570.151745]  ffff88005539fc80 0000000000000082 ffff880804045180 ffff88005539ffd8
    [49570.151753]  00000000000130c0 00000000000130c0 ffff880804721460 ffff88005539fda8
    [49570.151761]  ffff88005539fdb0 7fffffffffffffff ffff880804045180 0000000000000000
    [49570.151768] Call Trace:
    [49570.151787]  [<ffffffff817699f9>] schedule+0x29/0x70
    [49570.151796]  [<ffffffff81768dd9>] schedule_timeout+0x229/0x2a0
    [49570.151806]  [<ffffffff81087ef6>] ? __queue_work+0x136/0x320
    [49570.151813]  [<ffffffff810881aa>] ? __queue_delayed_work+0xaa/0x1a0
    [49570.151820]  [<ffffffff8108857d>] ? try_to_grab_pending+0x11d/0x160
    [49570.151828]  [<ffffffff8176a4f6>] wait_for_completion+0xa6/0x160
    [49570.151837]  [<ffffffff810a1550>] ? wake_up_state+0x20/0x20
    [49570.151846]  [<ffffffff811fca85>] sync_inodes_sb+0xa5/0x1c0
    [49570.151857]  [<ffffffff812039fb>] sync_filesystem+0x5b/0xa0
    [49570.151865]  [<ffffffff8120af24>] fsync_bdev+0x24/0x60
    [49570.151876]  [<ffffffff81366183>] blkdev_ioctl+0x433/0x7b0
    [49570.151883]  [<ffffffff8120a5c1>] block_ioctl+0x41/0x50
    [49570.151891]  [<ffffffff811e7360>] do_vfs_ioctl+0x2e0/0x4c0
    [49570.151899]  [<ffffffff811d96c5>] ? SYSC_newfstat+0x25/0x30
    [49570.151906]  [<ffffffff811e75c1>] SyS_ioctl+0x81/0xa0
    [49570.151915]  [<ffffffff8176da4d>] system_call_fastpath+0x1a/0x1f
    [49690.175082] INFO: task mdadm:16228 blocked for more than 120 seconds.
    [49690.175099]       Tainted: P           OE 3.16.0-38-generic #52~14.04.1-Ubuntu
    [49690.175104] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [49690.175110] mdadm           D ffff88080fd530c0     0 16228  15783 0x00000004
    [49690.175121]  ffff88005539fc80 0000000000000082 ffff880804045180 ffff88005539ffd8
    [49690.175129]  00000000000130c0 00000000000130c0 ffff880804721460 ffff88005539fda8
    [49690.175136]  ffff88005539fdb0 7fffffffffffffff ffff880804045180 0000000000000000
    [49690.175144] Call Trace:
    [49690.175164]  [<ffffffff817699f9>] schedule+0x29/0x70
    [49690.175172]  [<ffffffff81768dd9>] schedule_timeout+0x229/0x2a0
    [49690.175182]  [<ffffffff81087ef6>] ? __queue_work+0x136/0x320
    [49690.175190]  [<ffffffff810881aa>] ? __queue_delayed_work+0xaa/0x1a0
    [49690.175197]  [<ffffffff8108857d>] ? try_to_grab_pending+0x11d/0x160
    [49690.175205]  [<ffffffff8176a4f6>] wait_for_completion+0xa6/0x160
    [49690.175214]  [<ffffffff810a1550>] ? wake_up_state+0x20/0x20
    [49690.175224]  [<ffffffff811fca85>] sync_inodes_sb+0xa5/0x1c0
    [49690.175234]  [<ffffffff812039fb>] sync_filesystem+0x5b/0xa0
    [49690.175242]  [<ffffffff8120af24>] fsync_bdev+0x24/0x60
    [49690.175253]  [<ffffffff81366183>] blkdev_ioctl+0x433/0x7b0
    [49690.175261]  [<ffffffff8120a5c1>] block_ioctl+0x41/0x50
    [49690.175268]  [<ffffffff811e7360>] do_vfs_ioctl+0x2e0/0x4c0
    [49690.175277]  [<ffffffff811d96c5>] ? SYSC_newfstat+0x25/0x30
    [49690.175284]  [<ffffffff811e75c1>] SyS_ioctl+0x81/0xa0
    [49690.175293]  [<ffffffff8176da4d>] system_call_fastpath+0x1a/0x1f
    [49810.198423] INFO: task mdadm:16228 blocked for more than 120 seconds.
    [49810.198438]       Tainted: P           OE 3.16.0-38-generic #52~14.04.1-Ubuntu
    [49810.198443] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [49810.198449] mdadm           D ffff88080fd530c0     0 16228  15783 0x00000004
    [49810.198461]  ffff88005539fc80 0000000000000082 ffff880804045180 ffff88005539ffd8
    [49810.198469]  00000000000130c0 00000000000130c0 ffff880804721460 ffff88005539fda8
    [49810.198476]  ffff88005539fdb0 7fffffffffffffff ffff880804045180 0000000000000000
    [49810.198483] Call Trace:
    [49810.198503]  [<ffffffff817699f9>] schedule+0x29/0x70
    [49810.198512]  [<ffffffff81768dd9>] schedule_timeout+0x229/0x2a0
    [49810.198522]  [<ffffffff81087ef6>] ? __queue_work+0x136/0x320
    [49810.198530]  [<ffffffff810881aa>] ? __queue_delayed_work+0xaa/0x1a0
    [49810.198537]  [<ffffffff8108857d>] ? try_to_grab_pending+0x11d/0x160
    [49810.198545]  [<ffffffff8176a4f6>] wait_for_completion+0xa6/0x160
    [49810.198554]  [<ffffffff810a1550>] ? wake_up_state+0x20/0x20
    [49810.198563]  [<ffffffff811fca85>] sync_inodes_sb+0xa5/0x1c0
    [49810.198574]  [<ffffffff812039fb>] sync_filesystem+0x5b/0xa0
    [49810.198582]  [<ffffffff8120af24>] fsync_bdev+0x24/0x60
    [49810.198593]  [<ffffffff81366183>] blkdev_ioctl+0x433/0x7b0
    [49810.198601]  [<ffffffff8120a5c1>] block_ioctl+0x41/0x50
    [49810.198608]  [<ffffffff811e7360>] do_vfs_ioctl+0x2e0/0x4c0
    [49810.198617]  [<ffffffff811d96c5>] ? SYSC_newfstat+0x25/0x30
    [49810.198624]  [<ffffffff811e75c1>] SyS_ioctl+0x81/0xa0
    [49810.198638]  [<ffffffff8176da4d>] system_call_fastpath+0x1a/0x1f
     


  • Unable to mount location Failed to retrieve share list from server: No such file or directory solution


    Cannot even "Browse Network" when clicking on "Windows Network"

    Unable to mount location
    Failed to retrieve share list from server: No such file or directory

    logs:

    [2017/02/14 00:16:44.271314,  0] ../source3/nmbd/nmbd.c:58(terminate)
      Got SIGTERM: going down...
    [2017/02/13 17:35:41.797944,  0] ../lib/util/become_daemon.c:124(daemon_ready)
      STATUS=daemon 'nmbd' finished starting up and ready to serve connections
    [2017/02/14 01:36:51.984161,  0] ../source3/libsmb/nmblib.c:873(send_udp)
      Packet send failed to 192.168.1.255(138) ERRNO=Invalid argument
    [2017/02/14 01:36:51.984314,  0] ../source3/libsmb/nmblib.c:873(send_udp)
      Packet send failed to 192.168.1.255(137) ERRNO=Invalid argument
    [2017/02/14 01:36:51.984353,  0] ../source3/nmbd/nmbd_packets.c:179(send_netbios_packet)
      send_netbios_packet: send_packet() to IP 192.168.1.255 port 137 failed
    [2017/02/14 01:36:51.984390,  0] ../source3/nmbd/nmbd_nameregister.c:582(register_name)
      register_name: Failed to send packet trying to register name __MSBROWSE__<01>

     

    Solution

    • problem was a missing share (share mount point was not active or mounted due to drives being dead/disconnected) in /etc/samba/smb.conf
    • had to fix it and restart nmbd and smbd manually (restarting samba itself for some reason did nothing).

    sudo service nmbd restart
    sudo service smbd restart

     


  • mdadm how to make inactive array active


    This happens when you assemble array it doesn't mean it will be active for many reasons:

    md20 : inactive sdf1[2](S)
          732442488 blocks super 1.2

    Solution:

     sudo mdadm --manage /dev/md20  --run


  • ImageMagick how to trim white space automatically in Linux


    convert -trim yourimage.png

    That's all there is to it, very simple, clean and quick!


  • curl: (1) Protocol "https not supported or disabled in libcurl"


    This seems to only happen from a bash script but it's not clear why it works from the terminal but not from a bash script.


  • Centos 5 OpenSSL does not support TLS 1.2 Apache Error


    [Thu Jan 26 14:13:31 2017] [notice] caught SIGTERM, shutting down
    [Thu Jan 26 14:14:00 2017] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Thu Jan 26 14:14:00 2017] [error] Server certificate is expired: 'Server-Cert'
    [Thu Jan 26 14:14:00 2017] [notice] SSL FIPS mode disabled
    [Thu Jan 26 14:14:07 2017] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Thu Jan 26 14:14:07 2017] [error] Server certificate is expired: 'Server-Cert'
    [Thu Jan 26 14:14:07 2017] [notice] SSL FIPS mode disabled



    Stopping httpd:                                            [  OK  ]
    Starting httpd: Syntax error on line 101 of /etc/httpd/conf.d/ssl.conf:
    SSLProtocol: Illegal protocol 'TLSv1.2'
                                                               [FAILED]

    Solution

    Edit ssl.conf and remove the TLSv1.2 line.  Upgrade to Centos 6 or a newer distro for TLS 1.2 support which is much more secure .


  • DRBD Split-brain solution


    Uh oh

    [17925926.174277] block drbd0: Handshake successful: Agreed network protocol version 96
    [17925926.174325] block drbd0: conn( WFConnection -> WFReportParams )
    [17925926.174342] block drbd0: Starting asender thread (from drbd0_receiver [1682])
    [17925926.174432] block drbd0: data-integrity-alg: <not-used>
    [17925926.174581] block drbd0: drbd_sync_handshake:
    [17925926.174586] block drbd0: self 2AAE66AF9252D6DB:2815BF75CBEA0687:E303F24CF2826E13:E302F24CF2826E13 bits:73000 flags:0
    [17925926.174591] block drbd0: peer 24F1983D580A1E83:2815BF75CBEA0686:E303F24CF2826E12:E302F24CF2826E13 bits:93874 flags:0
    [17925926.174596] block drbd0: uuid_compare()=100 by rule 90
    [17925926.174602] block drbd0: helper command: /sbin/drbdadm initial-split-brain minor-0
    [17925926.180872] block drbd0: meta connection shut down by peer.
    [17925926.181041] block drbd0: conn( WFReportParams -> NetworkFailure )
    [17925926.181055] block drbd0: asender terminated
    [17925926.181058] block drbd0: Terminating asender thread
    [17925926.207698] block drbd0: helper command: /sbin/drbdadm initial-split-brain minor-0 exit code 0 (0x0)
    [17925926.207704] block drbd0: Split-Brain detected but unresolved, dropping connection!
    [17925926.207876] block drbd0: helper command: /sbin/drbdadm split-brain minor-0
    [17925926.209653] block drbd0: helper command: /sbin/drbdadm split-brain minor-0 exit code 0 (0x0)
    [17925926.209659] block drbd0: conn( NetworkFailure -> Disconnecting )
    [17925926.209668] block drbd0: error receiving ReportState, l: 4!
    [17925926.209839] block drbd0: Connection closed
    [17925926.209846] block drbd0: conn( Disconnecting -> StandAlone )
    [17925926.209862] block drbd0: receiver terminated
    [17925926.209865] block drbd0: Terminating receiver thread


    [root@box18 ~]# cat /proc/drbd
    version: 8.3.13 (api:88/proto:86-96)
    GIT-hash: 83ca112086600faacab2f157bc5a9324f7bd7f77 build by root@sighted, 2012-10-09 12:47:51
     0: cs:WFConnection ro:Secondary/Unknown ds:UpToDate/DUnknown A r-----
        ns:0 nr:0 dw:983961744 dr:1225316590 al:3645772 bm:110268 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:1619916
    [root@box18 ~]# drbdadm connect r0
    DRBD module version: 8.3.13
       userland version: 8.3.16
    preferably kernel and userland versions should match.
    0: Failure: (125) Device has a net-config (use disconnect first)
    Command 'drbdsetup 0 net ipv4:192.168.5.2.18:7788 ipv4:192.168.5.2.17:7788 A --set-defaults --create-device --after-sb-0pri=discard-least-changes --after-sb-1pri=consensus' terminated with exit code 10


    [root@box18 ~]# drbdadm connect r0
    DRBD module version: 8.3.13
       userland version: 8.3.16
    preferably kernel and userland versions should match.
    0: Failure: (125) Device has a net-config (use disconnect first)
    Command 'drbdsetup 0 net ipv4:192.168.5.2.18:7788 ipv4:192.168.5.2.17:7788 A --set-defaults --create-device --after-sb-0pri=discard-least-changes --after-sb-1pri=consensus' terminated with exit code 10
     

    Solution


    drbdadm disconnect r0

    drbdadm -- --discard-my-data connect r0



    #On the main active node


    drbdadm connect r0
     cat /proc/drbd
    version: 8.3.13 (api:88/proto:86-96)
    GIT-hash: 83ca112086600faacab2f157bc5a9324f7bd7f77 build by root@sighted, 2012-10-09 12:47:51
     0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent A r-----
        ns:3580 nr:0 dw:1597648248 dr:12347577 al:12090 bm:58295 lo:13 pe:169 ua:85 ap:1 ep:1 wo:b oos:3289420
        [>....................] sync'ed:  0.2% (3289420/3290212)K
        finish: 1:08:31 speed: 792 (792) K/sec


    #on the dead node that is rejoining


     cat /proc/drbd
    version: 8.3.13 (api:88/proto:86-96)
    GIT-hash: 83ca112086600faacab2f157bc5a9324f7bd7f77 build by root@sighted, 2012-10-09 12:47:51
     0: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate A r-----
        ns:0 nr:151088 dw:984106508 dr:1225316590 al:3645772 bm:110390 lo:61 pe:0 ua:2 ap:0 ep:3 wo:b oos:3170888
        [>....................] sync'ed:  3.8% (3170888/3290212)K
        finish: 0:11:48 speed: 4,472 (3,508) want: 20,480 K/sec
     


  • How to Properly Secure SSL/TLS Apache Settings against Heartbleed Poodle (TLS) Poodle (SSLv3) FREAK BEAST CRIME


    Many users still are not aware but simply patching OpenSSL does not secure you against many known and easy to exploit attacks that will render your encryption useless by an attacker.

    Use the following setings in /etc/httpd/conf.d/ssl.conf
     

    SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !CAMELLIA !SEED !3DES !RC4 !aNULL !eNULL !LOW !MD5 !EXP !PSK !SRP !DSS"
    SSLProtocol -all +TLSv1.2 -SSLv3 -SSLv2

    The above passed all tests on RapidSSL https://cryptoreport.rapidssl.com/checker/views/certCheck.jsp

    Vulnerabilities checked:
    • Heartbleed
    • Poodle (TLS)
    • Poodle (SSLv3)
    • FREAK
    • BEAST
    • CRIME

    Essentially what the above does is disable all known exploitable/weak ciphers and forces only TLS1.2 which is the only known secure version of TLS at this moment.  The settings above protect you against the listed vulnerabilities (just make sure you have a recent enough OpenSSL version that does support TLS 1.2, older distributions such as Centos 5 do not).


  • K9 Mail Android Cannot See or View E-mails Disappear after reading - with Dovecot server. Solution


    This actually only happened after an e-mail server ran out of space due to run away log files.  Normal Desktop clients were not affected.   It appeared to be a bug in K9 mail but even reinstalling/wiping all settings did not fix it (read e-mails would still not reappear).

    This is moreso a bug in Dovecot where it probably messes up the index files.

    How do you fix this in Dovecot/your e-mail server?

    You need to delete the dovecot index and related files so they can be rebuilt.  Note if you have a lot of e-mails and a Desktop client this will force it to redownload all e-mails (possibly thousands or more for some users).  But it is the only way I could fix the issue in my K9 Mail Android client.

    cd /var/spool/mail/yourdomain/youraccount/Maildir/.yourfolder

    #Backup dovecot files

    mkdir 00-dovecotbk

    #delete dovecot files

    rm -rf dovecot.*

     


  • The folder contents could not be displayed connection refused - solution


    This happened while updating Linux Mint/Debian/Ubuntu on a remote SMB/Samba share.

    Solution

    After waiting for updates to complete things will work normally but it really is strange that the service actually stops working or is disabled for so long during the update.  It is likely the update process stops the serivce and only restarts after the update is complete.


  • Setting Up System for First Use... Please Wait... - WHMCS Installer


    This happens sometimes that it takes a fair amount of time for some WHMCS installations but it usually ends up completing eventually.


  • ERROR 2013 (HY000): Lost connection to MySQL server during query


    The solution is simple but strange, if you copy your /var/lib/mysql directory to another server and think it will work, be sure to check if you have /var/log/mysql and binary log files.  If you do, the server will not work and will give you errors like below and crash without the proper log files.

    UPDATE user SET password=password("newpass") WHERE user='root';
    flush privileges;

    ERROR 2013 (HY000): Lost connection to MySQL server during query

    No connection. Trying to reconnect...
    Connection id:    1
    Current database: *** NONE ***

    Database changed



    /var/log/mysqld.log output:

    As we can see it is crashing and also looking for non-existent logfiles.




    170116  2:31:44  InnoDB: Started; log sequence number 4 1641421037
    170116  2:31:44 [Note] /usr/libexec/mysqld: ready for connections.
    Version: '5.1.73'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
    170116  2:31:45  InnoDB: Assertion failure in thread 140102772668160 in file handler/ha_innodb.cc line 875
    InnoDB: Failing assertion: cset == 0
    InnoDB: We intentionally generate a memory trap.
    InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
    InnoDB: If you get repeated assertion failures or crashes, even
    InnoDB: immediately after the mysqld startup, there may be
    InnoDB: corruption in the InnoDB tablespace. Please refer to
    InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html
    InnoDB: about forcing recovery.
    07:31:45 UTC - mysqld got signal 6 ;
    This could be because you hit a bug. It is also possible that this binary
    or one of the libraries it was linked against is corrupt, improperly built,
    or misconfigured. This error can also be caused by malfunctioning hardware.
    We will try our best to scrape up some info that will hopefully help
    diagnose the problem, but since we have already crashed,
    something is definitely wrong and this may fail.

    key_buffer_size=16384
    read_buffer_size=262144
    max_used_connections=0
    max_threads=151
    thread_count=0
    connection_count=0
    It is possible that mysqld could use up to
    key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 49909 K  bytes of memory
    Hope that's ok; if not, decrease some variables in the equation.

    Thread pointer: 0x0
    Attempting backtrace. You can use the following information to find out
    where mysqld died. If you see no messages after this, something went
    terribly wrong...
    stack_bottom = 0 thread_stack 0x20000
    /usr/libexec/mysqld(my_print_stacktrace+0x29) [0x8509f9]
    /usr/libexec/mysqld(handle_fatal_signal+0x483) [0x6a3f13]
    /lib64/libpthread.so.0(+0xf7e0) [0x7f6c44f1c7e0]
    /lib64/libc.so.6(gsignal+0x35) [0x7f6c435505e5]
    /lib64/libc.so.6(abort+0x175) [0x7f6c43551dc5]
    /usr/libexec/mysqld() [0x72d7ab]
    /usr/libexec/mysqld(dict_mem_table_add_col+0x20e) [0x7605de]
    /usr/libexec/mysqld(dict_load_table+0x99e) [0x75bf8e]
    /usr/libexec/mysqld(dict_load_table_on_id+0x403) [0x75cd13]
    /usr/libexec/mysqld(row_purge_step+0x39c) [0x7b360c]
    /usr/libexec/mysqld(que_run_threads+0x55b) [0x7a255b]
    /usr/libexec/mysqld(trx_purge+0x332) [0x7cc902]
    /usr/libexec/mysqld(srv_master_thread+0x708) [0x7c5298]
    /lib64/libpthread.so.0(+0x7aa1) [0x7f6c44f14aa1]
    /lib64/libc.so.6(clone+0x6d) [0x7f6c43606aad]
    The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
    information that should help you find out what is causing the crash.
    170116 02:31:45 mysqld_safe Number of processes running now: 0
    170116 02:31:45 mysqld_safe mysqld restarted
    170116  2:31:45 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
    170116  2:31:45  InnoDB: Initializing buffer pool, size = 8.0M
    170116  2:31:45  InnoDB: Completed initialization of buffer pool
    InnoDB: The log sequence number in ibdata files does not match
    InnoDB: the log sequence number in the ib_logfiles!
    170116  2:31:45  InnoDB: Database was not shut down normally!
    InnoDB: Starting crash recovery.
    InnoDB: Reading tablespace information from the .ibd files...
    InnoDB: Restoring possible half-written data pages from the doublewrite
    InnoDB: buffer...
    InnoDB: In a MySQL replication slave the last master binlog file
    InnoDB: position 0 6823363, file name bin.000001
    InnoDB: Last MySQL binlog file position 0 611287495, file name /var/log/mysql/bin.000118
    170116  2:31:45  InnoDB: Started; log sequence number 4 1641421037
    170116  2:31:45 [Note] /usr/libexec/mysqld: ready for connections.
    Version: '5.1.73'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution

    The solution

    Make sure you copy /var/log/mysql as well.


  • if script bash check if socket file (mysql.sock) exists


    The "-S" switch is important as it works with sockets if you use "-f" it will not detect the socket file is there.

     

    if [ ! -S "/var/lib/mysql/mysql.sock" ]; then

     echo "Socket does not exist, restarting"

     service mysqld restart

    fi


  • ioncube loader install howto on PHP/Centos


    Disclaimer, before starting this I do not like ioncube, it is great to protect your source code, but a big pain to setup this extension since it has to be done manually.  Further, fi you do a PHP update ioncube may no longer work, causing important sites or services to not work (I wish authors would take another approach).

    1.) Download from here: https://www.ioncube.com/loaders.php

    2.) Extract the contents and copy the appropriate .so file somewhere.

    If you want to be sure of what file to use, you can use the load wizard php file and it will tell you exactly which one to use and copy.

    3.) Edit /etc/php.ini and add the following line (of course edit the path to suit your situation):

    zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_7.0.so
     

    Errors from the loader wizard:

    ionCube installation : missing zend_extension

    This means you didn't add the zend_extension line above in step#3 to your php.ini file


  • apc_shm_attach: shmat failed: in Unknown on line 0 & apc_shm_create: shmget(0, 67108864, 914) failed PHP Solution


    PHP Fatal error:  PHP Startup: apc_shm_create: shmget(0, 67108864, 914) failed: Invalid argument. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment. in Unknown on line 0
    PHP Fatal error:  PHP Startup: apc_shm_attach: shmat failed: in Unknown on line 0

    This error is not at all fun because it actually prevents Apache/httpd from starting or working at all. It will die during restart

    [root@phpbox stats]# service httpd status
    httpd dead but subsys locked


    Solution - Increase shmmax value in sysctl.conf to 256MB:

    Edit /etc/sysctl.conf

    kernel.shmmax  = 268435456



    sysctl -p


  • MySQLD Server shutdown remotely unexpectedly


    170110  5:35:23 [Note] /usr/libexec/mysqld: Normal shutdown

    170110  5:35:23 [Note] Event Scheduler: Purging the queue. 0 events
    170110  5:35:23  InnoDB: Starting shutdown...
    170110  5:35:24  InnoDB: Shutdown completed; log sequence number 0 12765401
    170110  5:35:24 [Note] /usr/libexec/mysqld: Shutdown complete

    170110 05:35:24 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

    This could be an accidental shutdown or the work of hackers which is something that I have before.  Finding the cause is another issue as there is no MySQL logging of when and what user initiated the shutdown.


  • cPanel Install Error kernel ipv6 module support solution


    2017-01-12 14:25:36  529 (ERROR): The installer was unable to verify that your kernel supports IPv6.
    2017-01-12 14:25:36  530 (ERROR): The message received when trying to create an IPv6 socket was Address already in use

    2017-01-12 14:25:36  531 (ERROR): Please ensure that the ipv6 module is enabled and loaded in your kernel.
    2017-01-12 14:25:36  532 (FATAL): Exiting...

    Solution

    This happened in the middle of an install that I restarted.  The only way to fix it was to restart the VPS/Server as certainly even older kernels support IPV6.


  • bash count length of string and characters


    variable="abc hello"

    How do you count it (note blank/white space counts as a character too)?

    echo "${#variable}"

    9


  • PayPal Subscription Howto Creation Automatic Payments Manual


    An easy way to pay companies and friends/family since PayPal does not have an option when sending money to make it a subscription:

    • "business" = The e-mail or PayPal ID of the person/organization to pay to.
    • a3 The recurring amount "eg. 115" will be 115 USD
    • p3 The time period (eg. 2)
    • t3 Unit of time period m=monthly,w=weekly,y=yearly
    • item_name = "the note/product service reason you are paying handy for both you and the receiver to remember what it is payment for"


    Just use this code and insert into an html file.

    <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick-subscriptions">
    <input type="hidden" name="business" value="emailofperson@hotmail.com">
    <input type="hidden" name="a3" value="115">
    <input type="hidden" name="p3" value="2">
    <input type="hidden" name="t3" value="w">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="item_name" value="Notes/nameofproduct">
    <input type="hidden" name="amount" value="115">
    <input type="hidden" name="src" value="1">
    <input type="image" src="" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
    </form>


  • bind/named rndc: connect failed: 127.0.0.1#953: connection refused (solution)


    service named status
    rndc: connect failed: 127.0.0.1#953: connection refused
    named (pid  10557) is running...


    Check /var/log/messages:
    Jan  4 17:06:22 storagebox named[10753]: none:0: open: /etc/rndc.key: permission denied
    Jan  4 17:06:22 storagebox named[10753]: couldn't add command channel 127.0.0.1#953: permission denied
    Jan  4 17:06:22 storagebox named[10753]: none:0: open: /etc/rndc.key: permission denied
    Jan  4 17:06:22 storagebox named[10753]: couldn't add command channel ::1#953: permission denied


    Solution:

    chown named.named /etc/rndc.key
    service named restart
    service named status

    It is all good now!

    version: 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6_8.3
    CPUs found: 8
    worker threads: 8
    number of zones: 20
    debug level: 0
    xfers running: 0
    xfers deferred: 0
    soa queries in progress: 0
    query logging is OFF
    recursive clients: 0/0/1000
    tcp clients: 0/100
    server is up and running
    named (pid  11067) is running...


  • PYCURL ERROR 22 - The requested URL returned error: 404 Not Found Solution


    # yum -y install qemu-kvm
    Loaded plugins: fastestmirror
    Setting up Install Process
    Loading mirror speeds from cached hostfile
     * base: mirror.lzu.edu.cn
     * elrepo: ftp.utexas.edu
     * epel: ftp.jaist.ac.jp
     * extras: mirrors.aliyun.com
     * openvz-kernel-rhel6: mirror.fdcservers.net
     * openvz-utils: mirror.fdcservers.net
     * updates: mirrors.nwsuaf.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package qemu-kvm.x86_64 2:0.12.1.2-2.491.el6_8.3 will be installed
    http://mirror.fdcservers.net/openvz/kernel/branches/rhel6-2.6.32/current/repodata/91e2997c1b30cadc1c17b524b44d4e3f65af4215-filelists.sqlite.bz2: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
    Trying other mirror.
    To address this issue please refer to the below knowledge base article

    https://access.redhat.com/articles/1320623

    If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

    http://openvz.mirror.ausnetservers.net.au/kernel/branches/rhel6-2.6.32/current/repodata/91e2997c1b30cadc1c17b524b44d4e3f65af4215-filelists.sqlite.bz2: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
    Trying other mirror.

    Solution

    yum clean all


  • grep only certain file types howto


    This can save a lot of time, otherwise grep will go through an entire directory recursively searching every type of file but what if you are sure you only need to search txt or php files?

    grep -r -i --include=*.php "what you are searching for" /the/path/to/search


  • MySQL Allow Access from Remote Host IP and Update All Users


    Change Host="192.168.5.99" with the remote IP allowed (this is of course more secure but also cumbersome if your IP changes).  You could also have a single layer of protection that specifies the IP via firewall or both (of course both are far mor secure).

    UPDATE user SET Host="192.168.5.99" where Host="localhost"
    or for any/wildcard
    UPDATE user SET Host="%" where Host="localhost"


  • fdisk wq causes hung process


    I created a new partition table on a newly plugged in device and it caused fdisk to hang (even force kill does not work).  It also may be a bad drive or some other issue because fdisk -l hangs after the first 2 HDDs (totaly of 8 HDDs on this system):


    [1232879.903596] INFO: task fdisk:27176 blocked for more than 120 seconds.
    [1232879.903607]       Tainted: P           OE 3.16.0-38-generic #52~14.04.1-Ubuntu
    [1232879.903609] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [1232879.903612] fdisk           D ffff88102fd130c0     0 27176  27054 0x00000000
    [1232879.903619]  ffff880aaf987d50 0000000000000082 ffff880fff807010 ffff880aaf987fd8
    [1232879.903622]  00000000000130c0 00000000000130c0 ffff880f7ec4dbb0 ffff880aaf987e78
    [1232879.903626]  ffff880aaf987e80 7fffffffffffffff ffff880fff807010 ffffffff81203970
    [1232879.903629] Call Trace:
    [1232879.903643]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1232879.903649]  [<ffffffff817699f9>] schedule+0x29/0x70
    [1232879.903653]  [<ffffffff81768dd9>] schedule_timeout+0x229/0x2a0
    [1232879.903657]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1232879.903663]  [<ffffffff815d14e5>] ? md_make_request+0xd5/0x220
    [1232879.903666]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1232879.903671]  [<ffffffff815e6027>] ? dm_request+0x107/0x1a0
    [1232879.903674]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1232879.903678]  [<ffffffff8176a4f6>] wait_for_completion+0xa6/0x160
    [1232879.903683]  [<ffffffff810a1550>] ? wake_up_state+0x20/0x20
    [1232879.903688]  [<ffffffff8134f35e>] submit_bio_wait+0x5e/0x70
    [1232879.903693]  [<ffffffff8135b4ca>] blkdev_issue_flush+0x5a/0x90
    [1232879.903699]  [<ffffffff81267f99>] ext4_sync_fs+0xe9/0x140
    [1232879.903702]  [<ffffffff81203990>] sync_fs_one_sb+0x20/0x30
    [1232879.903707]  [<ffffffff811d7cb2>] iterate_supers+0xb2/0x110
    [1232879.903710]  [<ffffffff81203a95>] sys_sync+0x55/0x90
    [1232879.903715]  [<ffffffff8176da4d>] system_call_fastpath+0x1a/0x1f
    [1232999.926891] INFO: task fdisk:27176 blocked for more than 120 seconds.
    [1232999.926902]       Tainted: P           OE 3.16.0-38-generic #52~14.04.1-Ubuntu
    [1232999.926904] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [1232999.926907] fdisk           D ffff88102fd130c0     0 27176  27054 0x00000000
    [1232999.926914]  ffff880aaf987d50 0000000000000082 ffff880fff807010 ffff880aaf987fd8
    [1232999.926918]  00000000000130c0 00000000000130c0 ffff880f7ec4dbb0 ffff880aaf987e78
    [1232999.926921]  ffff880aaf987e80 7fffffffffffffff ffff880fff807010 ffffffff81203970
    [1232999.926924] Call Trace:
    [1232999.926938]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1232999.926945]  [<ffffffff817699f9>] schedule+0x29/0x70
    [1232999.926949]  [<ffffffff81768dd9>] schedule_timeout+0x229/0x2a0
    [1232999.926952]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1232999.926959]  [<ffffffff815d14e5>] ? md_make_request+0xd5/0x220
    [1232999.926962]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1232999.926967]  [<ffffffff815e6027>] ? dm_request+0x107/0x1a0
    [1232999.926971]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1232999.926974]  [<ffffffff8176a4f6>] wait_for_completion+0xa6/0x160
    [1232999.926980]  [<ffffffff810a1550>] ? wake_up_state+0x20/0x20
    [1232999.926985]  [<ffffffff8134f35e>] submit_bio_wait+0x5e/0x70
    [1232999.926989]  [<ffffffff8135b4ca>] blkdev_issue_flush+0x5a/0x90
    [1232999.926995]  [<ffffffff81267f99>] ext4_sync_fs+0xe9/0x140
    [1232999.926999]  [<ffffffff81203990>] sync_fs_one_sb+0x20/0x30
    [1232999.927003]  [<ffffffff811d7cb2>] iterate_supers+0xb2/0x110
    [1232999.927007]  [<ffffffff81203a95>] sys_sync+0x55/0x90
    [1232999.927011]  [<ffffffff8176da4d>] system_call_fastpath+0x1a/0x1f
    [1233119.950269] INFO: task fdisk:27176 blocked for more than 120 seconds.
    [1233119.950285]       Tainted: P           OE 3.16.0-38-generic #52~14.04.1-Ubuntu
    [1233119.950290] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [1233119.950296] fdisk           D ffff88102fd130c0     0 27176  27054 0x00000000
    [1233119.950308]  ffff880aaf987d50 0000000000000082 ffff880fff807010 ffff880aaf987fd8
    [1233119.950316]  00000000000130c0 00000000000130c0 ffff880f7ec4dbb0 ffff880aaf987e78
    [1233119.950323]  ffff880aaf987e80 7fffffffffffffff ffff880fff807010 ffffffff81203970
    [1233119.950330] Call Trace:
    [1233119.950350]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1233119.950362]  [<ffffffff817699f9>] schedule+0x29/0x70
    [1233119.950370]  [<ffffffff81768dd9>] schedule_timeout+0x229/0x2a0
    [1233119.950378]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1233119.950389]  [<ffffffff815d14e5>] ? md_make_request+0xd5/0x220
    [1233119.950396]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1233119.950405]  [<ffffffff815e6027>] ? dm_request+0x107/0x1a0
    [1233119.950413]  [<ffffffff81203970>] ? do_fsync+0x80/0x80
    [1233119.950420]  [<ffffffff8176a4f6>] wait_for_completion+0xa6/0x160
    [1233119.950430]  [<ffffffff810a1550>] ? wake_up_state+0x20/0x20
    [1233119.950439]  [<ffffffff8134f35e>] submit_bio_wait+0x5e/0x70
    [1233119.950447]  [<ffffffff8135b4ca>] blkdev_issue_flush+0x5a/0x90
    [1233119.950457]  [<ffffffff81267f99>] ext4_sync_fs+0xe9/0x140
    [1233119.950465]  [<ffffffff81203990>] sync_fs_one_sb+0x20/0x30
    [1233119.950473]  [<ffffffff811d7cb2>] iterate_supers+0xb2/0x110
    [1233119.950481]  [<ffffffff81203a95>] sys_sync+0x55/0x90
    [1233119.950490]  [<ffffffff8176da4d>] system_call_fastpath+0x1a/0x1f


  • ADATA SU800 256GB 3D NAND Flash SSD Test & Review


    I keep reading these drives are slower, but they are cheap and still SSD and work very fast for my needs.

    As you can see the sequential read is 481-491MB/s, if I put them in MDADM RAID10 mode (normal RAID1) they should give me well over 900MB/s and with redundancy and being very cheap for what they offer.


    [1232206.315622] scsi 8:0:1:0: Direct-Access     ATA      ADATA SU800      1A   PQ: 0 ANSI: 6
    [1232206.315649] scsi 8:0:1:0: SATA: handle(0x000a), sas_addr(0x4433221105000000), phy(5), device_name(0x0000000000000000)
    [1232206.315657] scsi 8:0:1:0: SATA: enclosure_logical_id(0x500605b0079b94b0), slot(5)
    [1232206.315764] scsi 8:0:1:0: atapi(n), ncq(y), asyn_notify(n), smart(y), fua(y), sw_preserve(y)
    [1232206.315773] scsi 8:0:1:0: qdepth(32), tagged(1), simple(0), ordered(0), scsi_level(7), cmd_que(1)
    [1232206.316834] sd 8:0:1:0: [sdj] 500118192 512-byte logical blocks: (256 GB/238 GiB)
    [1232206.316849] sd 8:0:1:0: [sdj] 4096-byte physical blocks
    [1232206.316948] sd 8:0:1:0: Attached scsi generic sg8 type 0
    [1232206.319196] sd 8:0:1:0: [sdj] Write Protect is off
    [1232206.319209] sd 8:0:1:0: [sdj] Mode Sense: 7f 00 10 08
    [1232206.319452] sd 8:0:1:0: [sdj] Write cache: enabled, read cache: enabled, supports DPO and FUA
    [1232206.323356]  sdj: unknown partition table
    [1232206.326505] sd 8:0:1:0: [sdj] Attached SCSI disk

    homebox user # dd if=/dev/sdj of=/dev/null bs=1M count=10000
    10000+0 records in
    10000+0 records out
    10485760000 bytes (10 GB) copied, 21.3731 s, 491 MB/s


    homebox user # dd if=/dev/sdk of=/dev/null bs=1M count=10000
    10000+0 records in
    10000+0 records out
    10485760000 bytes (10 GB) copied, 21.7838 s, 481 MB/s


  • mdadm kernel panic if trying to change --layout on a RAID10


    It is already known this is not possible

     

    mdadm --create /dev/md3 --level 10 --layout=f2 --raid-devices=2 /dev/sdc1 /dev/sdd1
    mdadm: /dev/sdc1 appears to be part of a raid array:
           level=raid10 devices=2 ctime=Sat Dec 24 18:44:29 2016
    mdadm: /dev/sdd1 appears to be part of a raid array:
           level=raid10 devices=2 ctime=Sat Dec 24 18:44:29 2016
    Continue creating array? y
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md3 started.
    [root@node ~]# mount/
    [root@node ~]# mkdir /mnt/md3
    [root@node ~]# mount /dev/md3 /mnt


  • remove gpt partition linux



    sudo fdisk /dev/sdh

    WARNING: GPT (GUID Partition Table) detected on '/dev/sdh'! The util fdisk doesn't support GPT. Use GNU Parted.


    WARNING: The size of this disk is 8.0 TB (8001563221504 bytes).
    DOS partition table format can not be used on drives for volumes
    larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
    partition table format (GPT).


    The device presents a logical sector size that is smaller than
    the physical sector size. Aligning to a physical sector (or optimal
    I/O) size boundary is recommended, or performance may be impacted.


    sudo fdisk /dev/sdh

    WARNING: GPT (GUID Partition Table) detected on '/dev/sdh'! The util fdisk doesn't support GPT. Use GNU Parted.


    WARNING: The size of this disk is 8.0 TB (8001563221504 bytes).
    DOS partition table format can not be used on drives for volumes
    larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
    partition table format (GPT).


    The device presents a logical sector size that is smaller than
    the physical sector size. Aligning to a physical sector (or optimal
    I/O) size boundary is recommended, or performance may be impacted.

    Command (m for help): q

    user@storbox2419:~$ sudo gdisk /dev/sdh
    GPT fdisk (gdisk) version 0.8.8

    Partition table scan:
      MBR: MBR only
      BSD: not present
      APM: not present
      GPT: present

    Found valid MBR and GPT. Which do you want to use?
     1 - MBR
     2 - GPT
     3 - Create blank GPT

    Your answer: 1

    Command (? for help): p
    Disk /dev/sdh: 15628053167 sectors, 7.3 TiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): D09B1DC2-7324-4D04-9EFA-7F2C0581B8FA
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 15628053133
    Partitions will be aligned on 8-sector boundaries
    Total free space is 11333216875 sectors (5.3 TiB)

    Number  Start (sector)    End (sector)  Size       Code  Name
       1          131070      4294967294   2.0 TiB     8300  Linux filesystem

    Command (? for help): wq

    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
    PARTITIONS!!

    Do you want to proceed? (Y/N): y
    OK; writing new GUID partition table (GPT) to /dev/sdh.
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot.
    The operation has completed successfully.


  • mdadm mirrored RAID1 performance using RAID10 -f2 (Far Layout) is the solution


    The only way I've found in mdadm to make 2 drives perform like a proper RAID 1 (eg. the read speed should be 2x that of a single drive) is to use the --layout=f2 (far 2).

     

    mdadm raid10 performance issues.
    Be very aware that mdadm seems to default to layout=n2 (which means near). In this scenario it means it is like mdadm RAID 1 performance (you get maximum read speeds of a single drive).

    dd if=/dev/md126 of=/dev/null bs=1M count=2000
    2000+0 records in
    2000+0 records out
    2097152000 bytes (2.1 GB) copied, 6.46397 s,
    180 MB/s

    Now look at the difference in the same drives in layout=f2 (which means far).

    dd if=/dev/md126 of=/dev/null bs=1M count=2000
    2000+0 records in
    2000+0 records out
    2097152000 bytes (2.1 GB) copied, 6.46397 s,
    324 MB/s

    As we can see the speed is nearly double (a small amount of bandwidth appears to be lost as overhead due to mdadm)

     


  • MySQL [ERROR] /usr/libexec/mysqld: Table './eximstats/sends' is marked as crashed and last (automatic?) repair failed solution


    You are checking your MySQL logs in /var/log/mysqld.log and come across an error like this:

    161222 18:03:40 [ERROR] /usr/libexec/mysqld: Table './eximstats/sends' is marked as crashed and last (automatic?) repair failed
     

    The Solution:


    cd /var/lib/mysql/eximstats
    myisamchk -r sends.MYI


    - recovering (with sort) MyISAM-table 'sends.MYI'
    Data records: 71129
    - Fixing index 1
    - Fixing index 2
    - Fixing index 3
    - Fixing index 4
    - Fixing index 5
    - Fixing index 6
    - Fixing index 7
    Data records: 133388


  • How to clear all iptables rules for all tables and chains


    iptables -F
    iptables -t nat -F
    iptables -t mangle -F

    This is as simple as it gets.


  • iptables how to forward localhost port to remote public IP


    iptables -t nat -A OUTPUT -m addrtype --src-type LOCAL --dst-type LOCAL -p tcp --dport 3306 -j DNAT --to-destination ip.ip.ip.ip
    iptables -t nat -A POSTROUTING -m addrtype --src-type LOCAL --dst-type UNICAST -j MASQUERADE

    sysctl -w net.ipv4.conf.all.route_localnet=1

    Make sure you substitute "ip.ip.ip.ip" for your real public IP and also the "--dport 3306" for the port you want to forward.

    Finally run the sysctl command and also update your /etc/sysctl.conf

    You can update sysctl.ctl to allow the routing of localhost with the following command:

    echo "net.ipv4.conf.all.route_localnet=1" >> /etc/sysctl.conf

    Now this all seems simple and good but it did take some research and hunting down.  Be warned and understand that forwarding localhost/127.0.0.1 requires this method and the typical other examples do not work.  Some examples of solutions that do not work with localhost:

     

    iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to ip.ip.ip.ip:3306
    iptables -t nat -A POSTROUTING -d ip.ip.ip.ip -j MASQUERADE


     

    iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to ip.ip.ip.ip
    iptables -A FORWARD -p tcp -d ip.ip.ip.ip --dport 3306 -j ACCEPT
    iptables -t nat -A POSTROUTING -j MASQUERADE


  • mcp55 NIC not working at boot on Centos 6.6-6.8




    forcedeth 0000:00:08.0: irq 25 for MSI/MSI-X
    forcedeth 0000:00:08.0: eth0: MSI enabled
    forcedeth 0000:00:08.0: eth0: no link during initialization
    ADDRCONF(NETDEV_UP): eth0: link is not ready
    forcedeth 0000:00:08.0: eth0: link up
    ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready


    Dec  1 18:21:32 box15 kernel: forcedeth: Reverse Engineered nForce ethernet driver. Version 0.64.
    Dec  1 18:21:32 box15 kernel: ACPI: PCI Interrupt Link [LMAC] enabled at IRQ 18
    Dec  1 18:21:32 box15 kernel: forcedeth 0000:00:08.0: PCI INT A -> Link[LMAC] -> GSI 18 (level, high) -> IRQ 18
    Dec  1 18:21:32 box15 kernel: forcedeth 0000:00:08.0: ifname eth0, PHY OUI 0x5043 @ 1, addr 6c:f0:49:a0:58:00
    Dec  1 18:21:32 box15 kernel: forcedeth 0000:00:08.0: highdma csum vlan pwrctl mgmt gbit lnktim msi desc-v3
    Dec  1 18:21:32 box15 kernel: ACPI: PCI Interrupt Link [LMA2] enabled at IRQ 17
    Dec  1 18:21:32 box15 kernel: forcedeth 0000:00:09.0: PCI INT A -> Link[LMA2] -> GSI 17 (level, high) -> IRQ 17
    Dec  1 18:21:32 box15 kernel: forcedeth 0000:00:09.0: ifname eth1, PHY OUI 0x5043 @ 2, addr 6c:f0:49:a0:58:01
    Dec  1 18:21:32 box15 kernel: forcedeth 0000:00:09.0: highdma csum vlan pwrctl mgmt gbit lnktim msi desc-v3


    =================


    sd 0:0:0:0: Attached scsi generic sg0 type 0
    forcedeth: Reverse Engineered nForce ethernet driver. Version 0.64.
    ACPI: PCI Interrupt Link [LMAC] enabled at IRQ 18
      alloc irq_desc for 18 on node 0
      alloc kstat_irqs on node 0
    forcedeth 0000:00:08.0: PCI INT A -> Link[LMAC] -> GSI 18 (level, high) -> IRQ 18
    forcedeth 0000:00:08.0: setting latency timer to 64
    forcedeth 0000:00:08.0: ifname eth0, PHY OUI 0x5043 @ 1, addr 6c:f0:49:a0:58:00
    forcedeth 0000:00:08.0: highdma csum vlan pwrctl mgmt gbit lnktim msi desc-v3
    ACPI: PCI Interrupt Link [LMA2] enabled at IRQ 17
      alloc irq_desc for 17 on node 0
      alloc kstat_irqs on node 0
    forcedeth 0000:00:09.0: PCI INT A -> Link[LMA2] -> GSI 17 (level, high) -> IRQ 17
    forcedeth 0000:00:09.0: setting latency timer to 64
    forcedeth 0000:00:09.0: ifname eth1, PHY OUI 0x5043 @ 2, addr 6c:f0:49:a0:58:01
    forcedeth 0000:00:09.0: highdma csum vlan pwrctl mgmt gbit lnktim msi desc-v3



    =================



    [    6.932843] forcedeth 0000:00:08.0: ifname eth0, PHY OUI 0x5043 @ 1, addr 6c:f0:49:6a:28:24
    [    6.932852] forcedeth 0000:00:08.0: highdma csum vlan pwrctl mgmt gbit lnktim msi desc-v3
    [    6.933161] ACPI: PCI Interrupt Link [LMA2] enabled at IRQ 17
    [    6.933167]   alloc irq_desc for 17 on node 0
    [    6.933170]   alloc kstat_irqs on node 0
    [    6.933182] forcedeth 0000:00:09.0: PCI INT A -> Link[LMA2] -> GSI 17 (level, high) -> IRQ 17
    [    6.933188] forcedeth 0000:00:09.0: setting latency timer to 64
    [    7.454541] forcedeth 0000:00:09.0: ifname eth1, PHY OUI 0x5043 @ 2, addr 6c:f0:49:6a:28:25
    [    7.454546] forcedeth 0000:00:09.0: highdma csum vlan pwrctl mgmt gbit lnktim msi desc-v3


    =================

    echo "options forcedeth msi=0 msix=0" > /etc/modprobe.d/forcedeth.conf

    forcedeth: Reverse Engineered nForce ethernet driver. Version 0.64.
    forcedeth 0000:00:08.0: PCI INT A -> Link[LMAC] -> GSI 18 (level, high) -> IRQ 18
    forcedeth 0000:00:08.0: setting latency timer to 64
    forcedeth 0000:00:08.0: ifname eth0, PHY OUI 0x5043 @ 1, addr 6c:f0:49:a0:58:00
    forcedeth 0000:00:08.0: highdma csum vlan pwrctl mgmt gbit lnktim desc-v3
    forcedeth 0000:00:09.0: PCI INT A -> Link[LMA2] -> GSI 17 (level, high) -> IRQ 17
    forcedeth 0000:00:09.0: setting latency timer to 64
    forcedeth 0000:00:09.0: ifname eth1, PHY OUI 0x5043 @ 2, addr 6c:f0:49:a0:58:01
    forcedeth 0000:00:09.0: highdma csum vlan pwrctl mgmt gbit lnktim desc-v3
    forcedeth 0000:00:08.0: eth0: no link during initialization
    forcedeth 0000:00:08.0: eth0: link up
     


  • OpenVZ mass ip update


    The file ipupdate.txt should look like this:

    ip.ip.ip.ip ctid


    while read -r; do
    ip=$REPLY
    setip=`echo $ip|awk '{print $1}'`
    ctid=`echo $ip|awk '{print $2}'`
    echo "vzctl set $ctid --ipadd $setip --save"
    vzctl set $ctid --ipadd $setip --save
    done < ipupdate.txt


  • Centos extremely secure iptables setup


    If you want to make sure only a certain IP can access your server for any service or protocol here is a way to do it (just be sure you have access to the IP(s) mentioned or you will be locked out).

     

    iptables -F
    iptables -A INPUT -i lo -j ACCEPT
    iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

    iptables -A INPUT -p tcp -s IP.IP.IP.IP -j ACCEPT

    iptables -A INPUT -j DROP
    service iptables save


  • OpenVZ Solution CPT ERR: c02fa000,73 :CPT: lock fd is closed incorrectly: 1 and vps-net_add ERROR: Unable to add route ip route add 192.168.5.2 dev venet0


    The only solution after trying many suggestions was to simply restart the "vz" service (definitely not preferable).

    Even doing an ifdown and ifup for venet0 did not help.

    ifup venet0
    Bringing up interface venet0:
    Configuring interface venet0:
    net.ipv4.conf.venet0.send_redirects = 0
    RTNETLINK answers: Network is down

    Some errors from log:

     

    CPT ERR: d2dc6000,54819 :Failed ot lookup path '/dev/shm'
    CPT ERR: d2dc6000,54819 :Failed to restore mount point: dev 'tmpfs', type 'tmpfs', path '/dev/shm'
    CPT ERR: d2dc6000,54819 :rst_namespace: -2

     

    =====================


    CPT ERR: f3f70000,30222 :rst_file: -2 98752
    CPT ERR: f3f70000,30222 :rst_files: -2
    CPT ERR: f3f70000,30222 :make_baby: -2
    CPT ERR: f3f70000,30222 :rst_clone_children
    unregister net_device: 'tun0' not found
    unregister net_device: 'tun1' not found
    unregister net_device: 'tun2' not found
    unregister net_device: 'tun3' not found
    unregister net_device: 'tun4' not found
    kobject_add failed for tun0 with -EEXIST, don't try to register things with the same name in the same directory.
     [<c04eec02>] kobject_add+0x141/0x167
     [<c0561c1c>] class_device_add+0x9d/0x3b4
     [<fc1ff49e>] __ve_dev_move+0x17f/0x1b4 [vzmon]
     [<fc1ff534>] fini_venet+0x61/0x81 [vzmon]
     [<fc200731>] env_cleanup+0x3e/0x185 [vzmon]
     [<fc2008a0>] vzmond_helper+0x28/0x34 [vzmon]
     [<fc200878>] vzmond_helper+0x0/0x34 [vzmon]
     [<c062d243>] kernel_thread_helper+0x7

     

    CPT ERR: c02fa000,73 :CPT: lock fd is closed incorrectly: 1

    Starting container...
    Container is mounted
    Adding IP address(es): 192.168.5.2
    RTNETLINK answers: No such device
    vps-net_add ERROR: Unable to add route ip route add 192.168.5.2 dev venet0
    Container start failed (try to check kernel messages, e.g. "dmesg | tail")
    Killing container ...
    Container was stopped
    Container is unmounted

    Solution

    service vz restart


  • mdadm change wrong device name md127 fix and solution in Linux


    md127 issue, it should be /dev/md3 per mdadm.conf

    Any time something is mounted as md127 it almost always means there is no entry for this mdadm array in the mdadm.conf in initramfs (which is separate from your actual /etc/mdadm.conf).

    cat /etc/mdadm.conf
    ARRAY /dev/md3 metadata=1.2 UUID=b6722845:381cc94e:7a2c5b5f:8e3b7c4f


    The reason for this is something strange, most Linux OS's bizarrely always keep their own copy of /etc/mdadm.conf in the initram for the kernel, it will not automatically update or check the newest contents on your root partition.
    This is why so many people have the problem and try different hacks and fixes that I have never seen work (eg. reassembling etc...).

    Solution In Centos here is how you would fix the problem (assuming your /etc/mdadm.conf is correct/updated):


    dracat --force


  • /dev/drbd0: State change failed: (-2) Need access to UpToDate data solution


    Everytime I've seen this error "/dev/drbd0: State change failed: (-2) Need access to UpToDate data" it is because DRBD has no disk:


    cat /proc/drbd
    version: 8.3.13 (api:88/proto:86-96)
    GIT-hash: 83ca112086600faacab2f157bc5a9324f7bd7f77 build by root@sighted, 2012-10-09 12:47:51
     0: cs:Connected ro:Secondary/Secondary ds:Diskless/Inconsistent A r-----
        ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0

    Solution

    The reason is one of two, there is really no disk, your disk failed, or MOST commonly you've misconfigured DRBD to use a device or partition that does not exist.  In many cases this is simply because the device name has changed or the disk has been replaced etc.  So double check what disks are there and which is the correct device/partition and update /etc/drbd.conf accordingly.

     

     


  • forcedeth MCP55 Nforce3600 Nvidia Network NIC Card Not working in Linux at 1gigabit speeds


    Now many people report this card simply not working in various Linux distros and kernels.  My issue is different, it always works at 100mbit (eg. plugged into a 100mbit switch) but no matter what 1000M/gigabit switch I would try, it would never work.

    The link would be up (the lights were on) and the OS detected the link as being up as well but it wouldn't work at all and could not pass data in or out (not even a ack/ping).

    There is one simple solution and command I used on Linux Mint but should apply to most other kernels and distributions such as Debian, Ubuntu etc..:

     

    rmmod forcedeth;modprobe forcedeth msi=0 msix=0&
     

    *Do not forget the &/ampersand as if you are working remotely you will be cut off since the second part that brings the NIC back up will not get executed.

    Make the change permanent

    echo "rmmod forcedeth;modprobe forcedeth msi=0 msix=0&" >> /etc/rc.local


  • How to Normalize and Increase the Volume on M4A files in Linux


    M4A is a weird format, so you have to be creative here is a quick copy of what I did. 

    Basically you need to convert to .wav to make use of them and then I converted the resulting .wav into an mp3 (nice small file size and basically universally playable):

     

    =======

     

    sudo apt-get install mpg321 mp3gain faad normalize lame

     faad "Voice 002 (copy).m4a"

    faad "Voice 002 (copy).m4a"
     *********** Ahead Software MPEG-4 AAC Decoder V2.7 ******************

     Build: May  1 2012
     Copyright 2002-2004: Ahead Software AG
     http://www.audiocoding.com
     Floating point version

     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License.

     **************************************************************************

    Voice 002 (copy).m4a file info:

    LC AAC    4107.565 secs, 2 ch, 44100 Hz


    normalize-audio "Voice 002 (copy).wav"
    Computing levels...
     Voice 002 (copy). 100% done, ETA 00:00:00 (batch 100% done, ETA 00:00:00)
    Applying adjustment of 6.22dB to Voice 002 (copy).wav...
     Voice 002 (copy). 100% done, ETA 00:00:00 (batch 100% done, ETA 00:00:00)

      ---------------------
     | Config:  2 Ch       |
      ---------------------
     | Ch |    Position    |
      ---------------------
     | 00 | Left front     |
     | 01 | Right front    |
      ---------------------

    Decoding Voice 002 (copy).m4a took: 45.95 sec. 89.39x real-time.



    # not loud enough?
    #run again with the -g parameter and the manual decibel increase
    normalize-audio -g 20 "Voice 002 (copy).wav"

    #convert to mp3

    lame "Voice 002 (copy).wav"


  • DRBD Slow Performance - 99.99 % [jbd2/drbd0-8] highiowait solution


    Tired of checking iotop and seeing that your drbd partition is using 99.99% of io all the time and finding your drbd device performs slow in general?

    This is especially an issue in versions of DRBD in the 8.3 tree in particular one documented case is on "8.3.13" but it likely applies to other devices.

    The symptoms are that resyncing is fine and normal but any reasonable amount of activity is very slow and lagged and creates a high server load and consequently high io wait.  You may not notice it though until you apply a reasonable load or usage to the server and DRBD device.

    In some kernels and some versions you may get the following error in dmesg

    block drbd0: [drbd0_worker/1670] sock_sendmsg time expired, ko = 4294967295

    *But we have seen many cases where the above error is not present (perhaps an older kernel or module does not recognize it is being blocked).

    Here are some quick sysctl.conf kernel tuning tips that have changed a server's load from 10-18, to less than 1.

    Add or edit these in sysctl.conf to solve the issue

    net.ipv4.tcp_rmem = 131072  131072  10485760
    net.ipv4.tcp_wmem = 131072  131072  10485760
    vm.dirty_ratio = 10
    vm.dirty_background_ratio = 4

     

    This is a preferable way rather than hacking or changing DRBD settings by upgrading the userland or kernel manually or while it runs (results can be unpredictable) whereas this kernel tuning has virtually no risk or impact on DRBD except a positive one.


  • Linux how to enable and disable NCQ


    To disable NCQ in the Linux kernel (change sda to match your device).

    echo 1 > /sys/block/sda/device/queue_depth

    To enable NCQ (change sda to match your device).

    echo 31 > /sys/block/sda/device/queue_depth


  • error code:0xc0000005 windows 2012 datacenter


    When installing Windows 2012 I cannot get around that error for some reason it just keeps on happening.

     

    code:0xc0000005


  • cPanel how to change main IP to fix licensing issue


    Your cPanel may not work if you enter your non-main IP when setting it up.  The way to fix it is to go back to the setup screen by removing the following file:

    rm /etc/.whostgrft


  • How to completely remove mdadm array


    First you have to stop it.

    mdadm --stop /dev/md0

    Then you can remove it:

    mdadm --remove /dev/md0


  • mdadm zero-superblock to solve md device created on root device


    It is possible to tell mdadm to create an md device on a raw disk even though it will give you an error, it writes a superblock and this corrupts the partition table which can result in your system not booting.

    To fix it just zero the super-block on the offending device that you made the mistake in.

    Eg: /dev/sda

    mdadm --zero-superblock /dev/sda

    It is also a way of starting fresh if you wanted to create a new array.


  • grubby fatal error: unable to find a suitable template solution Centos


    vzkernel-2.6.32-042stab116.2.x86_64.rpm                                                                                                                                                                               |  33 MB     00:06    
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : vzkernel-2.6.32-042stab116.2.x86_64                                                                                                                                                                                       1/1
    grubby fatal error: unable to find a suitable template


    #note how menu.lst is a normal file.  It should be a symlink to grub.conf
    #because of this grubby will use grub.conf which does not match the current setup in menu.lst used for booting
    #
     ls -al /boot/grub/
    total 292
    drwxr-xr-x 2 root root   4096 Aug 10 15:07 .
    dr-xr-xr-x 5 root root   4096 Aug 10 15:06 ..
    -rw-r--r-- 1 root root  13396 Jul  9  2015 e2fs_stage1_5
    -rw-r--r-- 1 root root  12636 Jul  9  2015 fat_stage1_5
    -rw-r--r-- 1 root root  11780 Jul  9  2015 ffs_stage1_5
    -rw------- 1 root root    798 Aug 10 15:07 grub.conf
    -rw-r--r-- 1 root root  11772 Jul  9  2015 iso9660_stage1_5
    -rw-r--r-- 1 root root  13284 Jul  9  2015 jfs_stage1_5
    -rw------- 1 root root    764 Aug  8 19:11
    menu.lst

    #to fix it you need to move menu.lst to grub.conf and make a symlink to menu.lst from grub.conf
    cd /boot/grub
    mv menu.lst grub.conf
    ln -s grub.conf menu.lst

     

    Now see that menu.lst is a symlink and the kernel will install.

    ls -al /boot/grub/menu.lst
    lrwxrwxrwx 1 root root 9 Aug 10 15:12 /boot/grub/menu.lst -> grub.conf

    vzkernel-2.6.32-042stab116.2.x86_64.rpm                                                                                                                                                                               |  33 MB     00:03    
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : vzkernel-2.6.32-042stab116.2.x86_64                                                                                                                                                                                       1/1
      Verifying  : vzkernel-2.6.32-042stab116.2.x86_64                                                                                                                                                                                       1/1

    Installed:
      vzkernel.x86_64 0:2.6.32-042stab116.2                                                                                                                                                                                                     

    Complete!


  • Linux How To Recover Partition Table from Kernel and Restore Centos/Debian etc..


    We've all done this at some point, you work on the wrong shell window and this was my first time making this mistake but I deleted a partition table in fdisk, recreated it and saved it with "wq" and even ran partprobe!  If you haven't rebooted yet then you can still recover your partition table, otherwise you're in big trouble.

    Fortunately since it was a live system and in use the kernel still had to use the old table like below:

    Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
    Warning: Error fsyncing/closing /dev/md127: Input/output error
    Warning: Error fsyncing/closing /dev/md126: Input/output error
    Warning: Error fsyncing/closing /dev/md125: Input/output error

    Other places on the internet don't properly explain the procedure for recovery which can be done but you need the right side of instructions and info.

    Step 1 -Find your device directory in /sys/block/sda/sda1 (change the /sda and /sda1 to match your disk device name and partition number).

    You have to do a cat on the 'start' and 'size' which represents the starting sector of the partition and the 'size' represents how many sectors it is. 


    #take the size value and subtract 1 from it or you will not get the original or correct result
    fdisk /dev/sda
    #press u to change to sectors which is what /sys/block/sda goes by
     /sys/block/sda
    [root@server1 sda]# cat sda1/start
    2048
    [root@server1 sda]# cat sda1/size
    1024000

    [root@server1 sda]# cat sda2/start
    1026048
    [root@server1 sda]# cat sda2/size
    1464121344
     

     Step 2 -Use fdisk to take the above sector information and input it (remembering to subtract 1 from the size when telling fdisk the end sector)

    "Press u" to switch to sector mode once you run:

    fdisk /dev/sda



    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First sector (63-1465149167, default 63): 2048
    Last sector, +sectors or +size{K,M,G} (2048-1465149167, default 1465149167): +1023999

    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 2
    First sector (63-1465149167, default 63): 1026048
    Last sector, +sectors or +size{K,M,G} (1026048-1465149167, default 1465149167): +1464121343

    ##########


    and for those who do a normal fdisk -l /dev/sda and wonder why you can't duplicate the cylinder setup is because you need to press "u" and deal with sectors.

    Using sectors shows that you can actually end and start a partition on the same cylinder and in other ways cylinders will not work for:


       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1          64      512000   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              64       91202   732060672   83  Linux




    ###########


  • weird mv error mv: inter-device move failed:


    mv -f /home/user/Downloads/android-studio/ /mnt/sda3/
    mv: inter-device move failed: ‘/home/user/Downloads/android-studio/’ to ‘/mnt/sda3/android-studio’; unable to remove target: Is a directory


  • Apache Log Error Message when starting


    Usage: geoiplookup [-h] [-?] [-d custom_dir] [-f custom_file] [-v] [-i] [-l] <ipaddress|hostname>
    Usage: geoiplookup [-h] [-?] [-d custom_dir] [-f custom_file] [-v] [-i] [-l] <ipaddress|hostname>
    grep: Address: No such file or directory
    grep: not: No such file or directory
    grep: found: No such file or directory
    sh: -c: line 1: syntax error near unexpected token `|'
    sh: -c: line 1: `|cut -d ',' -f 2'
     


  • OpenVZ Migration Hostnode Containers from Centos 5 to Centos 6


    migrating from an old OpenVZ (Centos 5) to new OpenVZ (Centos 6)
    Also if migrating from 32-bit HN to 64-bit your RAM will probably be much bigger than it should be!
    16x bigger

    eg. 32bit HN:

                 total       used       free     shared    buffers     cached
    Mem:           256         16        239          0          0          0
    -/+ buffers/cache:         16        239
    Swap:            0          0          0


    eg. 64bit HN with same config:


    free -m
                 total       used       free     shared    buffers     cached
    Mem:          3906         42       3863          0          0         33
    -/+ buffers/cache:          9       3897
    Swap:        28614          0      28614



    Error: required UB parameter swappages not set

     vzctl start 27000
    Starting container...
    Error: required UB parameter swappages not set
    Saving VE layout 'simfs' to the VE config file
    CT configuration saved to /etc/vz/conf/27000.conf
    [root@server18 conf]# vzlist
    Container(s) not found
    [root@server18 conf]# vzctl start 27000
    Starting container...
    Error: required UB parameter swappages not set

    vzctl set 27000 --swappages 0:unlimited --save

     vzctl set 27000 --swappages 0:unlimited --save
    CT configuration saved to /etc/vz/conf/27000.conf
    [root@server18 conf]# vzctl start 27000
    Starting container...
    stat(/vz/root/27000): No such file or directory
    stat(/vz/root/27000): No such file or directory
    stat(/vz/root/27000): No such file or directory
    Initializing quota ...
    Container is mounted
    Adding IP address(es): 98.158.135.57 98.158.135.58
    Setting CPU units: 1000
    Setting devices
    Container start in progress...


  • Linux Mint 17 How to Enable File Sharing Option in File Manager


    I still cannot understand how this would not be enabled by default and I struggled to find the reason why with manually installing samba etc.. wondering why the option for sharing was not in the menu.

    On Linux Mint "MATE" the package is called "caja-share" and on Cinnamon it is called "nemo-share" so edit the below command as necessary:

     

    apt-get install caja-share
    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    The following package was automatically installed and is no longer required:
      libsctp1
    Use 'apt-get autoremove' to remove it.
    The following extra packages will be installed:
      caja-extensions-common caja-gksu caja-open-terminal
    The following NEW packages will be installed:
      caja-share
    The following packages will be upgraded:
      caja-extensions-common caja-gksu caja-open-terminal
    3 upgraded, 1 newly installed, 0 to remove and 469 not upgraded.
    Need to get 113 kB of archives.
    After this operation, 145 kB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 http://packages.linuxmint.com/ rafaela/import caja-open-terminal amd64 1.10.1-1+rafaela [10.8 kB]
    Get:2 http://packages.linuxmint.com/ rafaela/import caja-gksu amd64 1.10.1-1+rafaela [8,016 B]
    Get:3 http://packages.linuxmint.com/ rafaela/import caja-extensions-common all 1.10.1-1+rafaela [75.1 kB]
    Get:4 http://packages.linuxmint.com/ rafaela/import caja-share amd64 1.10.1-1+rafaela [19.2 kB]
    Fetched 113 kB in 0s (154 kB/s)      
    (Reading database ... 184362 files and directories currently installed.)
    Preparing to unpack .../caja-open-terminal_1.10.1-1+rafaela_amd64.deb ...
    Unpacking caja-open-terminal (1.10.1-1+rafaela) over (1.10.0-1+rafaela) ...
    Preparing to unpack .../caja-gksu_1.10.1-1+rafaela_amd64.deb ...
    Unpacking caja-gksu (1.10.1-1+rafaela) over (1.10.0-1+rafaela) ...
    Preparing to unpack .../caja-extensions-common_1.10.1-1+rafaela_all.deb ...
    Unpacking caja-extensions-common (1.10.1-1+rafaela) over (1.10.0-1+rafaela) ...
    Selecting previously unselected package caja-share.
    Preparing to unpack .../caja-share_1.10.1-1+rafaela_amd64.deb ...
    Unpacking caja-share (1.10.1-1+rafaela) ...
    Processing triggers for libglib2.0-0:i386 (2.40.2-0ubuntu1) ...
    Processing triggers for libglib2.0-0:amd64 (2.40.2-0ubuntu1) ...
    Setting up caja-extensions-common (1.10.1-1+rafaela) ...
    Setting up caja-open-terminal (1.10.1-1+rafaela) ...
    Setting up caja-gksu (1.10.1-1+rafaela) ...
    Setting up caja-share (1.10.1-1+rafaela) ...
    Processing triggers for libc-bin (2.19-0ubuntu6.6) ...