Tuesday, July 29, 2014

windows 10 - Screen freezes for a second every few seconds

I've been having problems with computer rebooting so I uninstalled my graphics drivers and reinstalled the latest ones (even though I already had the latest ones).


Since the reinstall my computer freezes for one second every few seconds if I move the mouse. This only happens when I move the mouse, if I just scroll or use my keyboard it doesn't freeze.


Also, this only happens if my TV is connected to HDMI and the TV is turned off. It doesn't happen if the TV is turned on.


Relevant details:
Windows 10 Pro x64 Version 1803
OS Build 17134.48
GPU: AMD RX 470
GPU Driver version: 18.5.1


Displays setup:
DVI 1: Monitor 1
DVI 2: Monitor 2 via digital DVI to VGA adapter
HDMI: TV (one suspect is the cable, it's a 5 meter cable, but why would it only have issues while the TV is off?)


I tried changing the refresh rates but that doesn't seem to have any effect.
My current workaround is to have the TV unplugged when I'm not using it, but that's very inconvenient since I use my PC remotely often.


I'm out of ideas.


The suggested duplicate seems to be a different issue. Also, I remember a few months ago I tried installing amd drivers on my mother's laptop and had the same issue. She has an AMD APU, and no external monitors.

linux - IPv6 only works after pinging the default gateway.



We now have 2013 and I thought it is long overdue to activate IPv6 on my server. But unfortunately, I ran in some problems. To be honest I only have litte experience with IPv6 So I hope you can help me with my "small" problem.



A small remark: The following addresses are obfuscated, it is not what I've used in my configs ;)



I am running a Debian squeeze (Debian 2.6.32-46) and I got a /64 IPv6 block from my provider: 2a01:4f8:a0:aaaa::/64




So I changed the /etc/network/interfaces file as follows (which is also the way my provider recommends it):



# Loopback device:
auto lo
iface lo inet loopback

# device: eth0
auto eth0
iface eth0 inet static
address 85.10.xxx.zz

broadcast 85.10.xxx.yy
netmask 255.255.255.224
gateway 85.10.xxx.1


iface eth0 inet6 static
# Main IPv6 Address of the server
address 2a01:4f8:a0:aaaa::2
netmask 64
gateway fe80::1



auto eth0:1
iface eth0:1 inet static
address 85.10.xxxx.uu
netmask 255.255.255.224

# default route to access subnet
up route add -net 85.10.xxx.0 netmask 255.255.255.224 gw 85.10.xxx.1 eth0



After a reboot (I am lazy and don't wanted to add everyhthing using route or ip) my eth0 interface looks like this:



eth0      < first line removed >  
inet addr:85.10.xxx.zz Bcast:85.10.xxx.yy Mask:255.255.255.224
inet6 addr: 2a01:4f8:a0:aaaa::2/64 Scope:Global
inet6 addr: fe80::bbbb:cccc:dddd:eeee/64 Scope:Link <--- from MAC address
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:24133 errors:0 dropped:0 overruns:0 frame:0
TX packets:21712 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000
RX bytes:3464246 (3.3 MiB) TX bytes:5776451 (5.5 MiB)
Interrupt:25 Base address:0x2000


and the routes ip -6 route look like this:



2a01:4f8:a0:aaaa::/64 dev eth0  metric 1024  mtu 1500 advmss 1440 hoplimit 4294967295
fe80::/64 dev eth0 proto kernel metric 256 mtu 1500 advmss 1440 hoplimit 4294967295
fe80::/64 dev vboxnet0 proto kernel metric 256 mtu 1500 advmss 1440 hoplimit 4294967295

default via fe80::1 dev eth0 metric 1024 mtu 1500 advmss 1440 hoplimit 4294967295


Now, my problem is that my IPv6 isn't working properly. If I try to ping an IPv6 address e.g. ping6 ipv6.google.com. I get: "Destination unreachable: Address unreachable"



Which looks like this in tcpdump -i eth0 ip6:



00:29:05.386500 IP6 2a01:4f8:a0:aaaa::2 > ff02::1:ff00:1: ICMP6, neighbor solicitation, who has fe80::1, length 32
00:29:05.390869 IP6 2a01:4f8:a0:bbbb::1 > 2a01:4f8:a0:aaaa::2: ICMP6, neighbor advertisement, tgt is fe80::1, length 32



2a01:4f8:a0:bbbb::1 is btw. listed as my gateway (at my provider's online admin console).



I think, the reason for all this is the missing NDP entry / the missing MAC address of fe80::1. Because ip -6 neigh gives me:



fe80::1 dev eth0  router FAILED 


I think so because if I do: ping6 -I eth0 fe80::1 I get a proper echo reply and the desired mac address for my fe80::1 address as well as a perfectly working IPv6 stack:




$ip -6 neigh
fe80::1 dev eth0 lladdr ll:mm:nn:oo:pp:qq router REACHABLE


Here is also again the dump from tcpdump -i eth0 ip6:



00:30:37.555702 IP6 fe80::bbbb:cccc:dddd:eeee > fe80::1: ICMP6, echo request, seq 1, length 64
00:30:37.560219 IP6 fe80::1 > fe80::bbbb:cccc:dddd:eeee: ICMP6, echo reply, seq 1, length 64



(again: fe80::bbbb:cccc:dddd:eeee is my link-local address, derived from the MAC address)



From this point on, I can use IPv6: I can ping6 websites, I can connect to services using IPv6 or even connect to my server via ssh using IPv6.



So, what am I doing wrong here? I've spend a lot of time trying to find out how to "fix" this. I bet it can be solved using two commands. This is by the way the first time I am dealing with IPv6 on a server. So please forgive me for my inexperience. Btw. I also tried to alter some sysctl net.ipv6.* flags, but without success. If it is necessary for the solution, I can also post my configuration here.



Every hint is more than welcome!



Thank you very much in advance!


Answer




I gave the whole problem another try today, a couple of weeks later. And what can I say, I fixed it. Can someone please explain me why adding a ipv6 loopback fixed my problem? Here is what I've added to my /etc/network/interfaces file:



iface lo inet6 loopback


I have no ideas why I've forgot to add it in the first place!^^ Thank you all for your responses!


linux - Apply full vim colorization for bash scripts that have no shebang line


So in my project there are many bash script files that are sourced, but never run directly, so they get no shebang line and no execute bit set. Vim colors them a little bit, but doesn't use the full colorization. How do I tweak vim to give me all the normal bash colors for these files?


EDIT:


Without shebang:


Without shebang


With shebang:


With shebang


EDIT 2:


There is an answer that works for file-by-file changes below, and I'll go with that if that's all I can get, but what I'd really like is to modify a config file or something else in my vim installation so that I always get the full "with shebang" colors even when there is no shebang. There must be a file somewhere that defines the incomplete colorization, which I can just replace with the file defining the complete colorization.


EDIT 3:


The vim global variables set are not substantially different, as seen in these images (output of :let g:):


Environments


Diffed


I'm sort of at a loss here.


EDIT 4:


I dumped the entire environment from a properly-colored window (left) and an improperly-colored window (right), and diffed them, finding this:


60 b:current_syntax       bash   |   61 b:current_syntax       conf

So, for some reason it thinks my shebangless source files are conf files. So I need to figure out how to match them to bash instead.


Answer



Run :setf sh


You may want to place this at the top of the files (if you want no shebang):


# vim:ft=sh

Monday, July 28, 2014

linux - Move unallocated space into extended partition to expand logical volume


I have a dual boot setup with Fedora and Windows. For personal reasons, I have uninstalled Windows and would like to use the freed-up space to expand my Fedora partition (which is on a logical partition inside an extended partition).


I am using GParted on Fedora to manage my partitions.disk partitions


The 66.90GiB unallocated space is where Windows used to be. I am trying to move that space into the extended partition (/dev/sda4) and eventually merge it with /dev/sda6, but GParted does not allow me move/resize the extended partition to make use of the free space. I read that



In Disk Management, unpartitioned space in primary partition area is called unallocated space, while unpartitioned space in extended partition area is named free space; unallocated can’t be used to extend to or create logical partition, and free space can’t be used to enlarge to or create primary partition.
(Source: https://www.partitionwizard.com/convertpartition/primary-partition-vs-logical-drive.html)



I'm not sure how true the above statement is, because people seem to have done it or somehow worked around the issue. I have looked at several questions on StackExchange including:


but I'm not sure if they're completely applicable here.


So my question is: how do I move the unallocated space into the extended partition to merge it with the fedora logical partition?


Any help would be appreciated!


Extra Info:



  • My computer uses MBR and not GPT, so I am only allowed 4 primary partitions, if that's relevant.

  • I can freely move/resize /dev/sda5 and /dev/sda6 around inside the extended partition, but I cannot move/resize the extended partition iteslf.


lsblk output


lsblk output


parted -l output


parted -l output


fdisk -l output
fdisk -l output


Answer



I just solved it, and I'll post the answer here in case someone else faces a similar problem.


I was unable to resize the partition because my swap space was still in use, so I found out I could disable it using swapoff -a.


After doing this, GParted allowed me to merge the unallocated space with the fedora logical partition. I then right clicked on the logical partition and selected the Check option.


Finally, I used the following to actually allocate the free space to the root and home partitions:


lvextend -L +20G /dev/fedora/home
lvextend -L +20G /dev/fedora/root
resize2fs /dev/fedora/home
resize2fs /dev/fedora/root

windows 10 - In the "High Performance" power plan, why does the CPU always shows 100% usage?

I've got a Dell Inspiron 11, model 3147, with a Pentium N3540 2.16GHz processor.



I've noticed that when I chose the "high performance" power plan (at Control Panel\All Control Panel Items\Power Options), the CPU will immediately go to 100% usage in task manager, and 125% usage in resource monitor. If I change it to "balanced," it will immediately go back down to below 50%. This happens when I have nothing running except task manager and resource monitor.



When at 100% CPU usage, the processes consuming max CPU don't seem to make any sense. For instance, task manager itself will sometimes show as consuming over 50% CPU.




I have run a scan with Windows Defender and didn't find any malware.



The computer seems responsive despite showing 100% CPU usage.



Is it expected that a Pentium N3450 will run at 100% CPU when in "high performance" mode? Or is there a problem with my laptop?



Below is a screengrab of task manager showing 100% CPU usage.



Task manager showing 100% CPU usage

Apache 2.4 using default DocumentRoot instead of VirtualHost DocumentRoot



Long time listener, first time caller...



I've been running Apache for years, and have set up multiple servers. This one is giving me a hard time and I just can't spot the issue. I've seen a number of threads here and elsewhere with VirtualHost problems and the wrong DocumentRoot being served, but none of those threads have helped me out.



Server is running Centos 7.5, SELinux enabled, Apache 2.4.33.



I'm wanting to run two VirtualHosts. For some reason, the secondary VH isn't serving the right files. Changing the order of the VH didn't matter. Last thing I tried was hard coding a default DocumentRoot (/var/www/html) and then putting each VH in its own separate directory (/var/www/VirtualHost).




Here is my current virtualhost.conf file:



#Set a default DocumentRoot
DocumentRoot /var/www/html


ServerAdmin webmaster@example1.com
DocumentRoot /var/www/example2.com
ServerName example2.com
ServerAlias www.example2.com




Options -Indexes +FollowSymLinks +MultiViews
Order allow,deny
Allow from all



ServerAdmin webmaster@example1.com

DocumentRoot /var/www/example1.com
ServerName example1.com
ServerAlias www.example1.com



Options -Indexes +FollowSymLinks +MultiViews
Order allow,deny
Allow from all




What I'm seeing in my logs is that all requests are trying to be served from /var/www/html, the default.



I have temporarily changed the log format used so that I can see the ServerName used, and the exact filename being referenced to verify the path.



LogFormat "%v %f %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined


On the local server, I issue the following two commands to test:




wget http://example1.com/index.html
wget http://example2.com/images/logo.jpg


My access log shows this:



example1.com /var/www/html/index.html 192.168.1.2 - - [18/Jul/2018:11:48:08 -0500] "GET /index.html HTTP/1.1" 404 208 "-" "Wget/1.14 (linux-gnu)"
example2.com /var/www/html/images 192.168.1.2 - - [18/Jul/2018:11:48:12 -0500] "GET /images/logo.jpg HTTP/1.1" 404 213 "-" "Wget/1.14 (linux-gnu)"



From the log, I can see that the correct domain is showing, but the file path is clearly wrong, Apache is trying to pull the requested files from the default DocumentRoot, and not the DocumentRoot defined for the VirtualHosts, which would have been /var/www/example(x).com.



Output of the httpd -S command as follows:



[wright@web2 conf.d]$ httpd -S
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using web2.local. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 is a NameVirtualHost
default server example2.com (/etc/httpd/conf.d/vhosts.conf:4)

port 80 namevhost example2.com (/etc/httpd/conf.d/vhosts.conf:4)
alias www.example2.com
port 80 namevhost example1.com (/etc/httpd/conf.d/vhosts.conf:17)
alias www.example1.com
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults

Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults

Mutex cache-socache: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48 not_used
Group: name="apache" id=48 not_used
[wright@web2 conf.d]$


Any help is appreciated!



Answer



I've managed to resolve my issue, and naturally it had nothing to do with anything I posted above. Hopefully this will help someone else down the road.



The root cause of my issue turned out to be my installation of PHP 7, specifically with the setup of php-fpm. The guide I followed suggested creating an fpm.conf file with the following:



# PHP scripts setup 
ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html

Alias / /var/www/html/



Thanks to this config, my DocumentRoot was getting rewritten for all of my VirtualHosts to the above path. It wasn't until I dumped all of my config files searching for '/var/www' that I came across this file.



Further googling on how to incorporate PHP-FPM with VirtualHosts led me to a page that had this code block within each VirtualHost block:




# 2.4.10+ can proxy to unix socket
# SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"

# Else we can just use a tcp socket:

SetHandler "proxy:fcgi://127.0.0.1:9000"



Adding this block to both of my VirtualHosts, and removing the old fpm.conf file and restarting Apache resolved my issue, the correct DocumentRoot was now being used for each VHost. It still remains to be determined if my PHP files are going to be served up correctly, but at least now I'm on the right path.


How can I put the Windows XP firewall into an "allow all" port configuration and only block certain ports?


Without going into too much detail on why I need to do this, I'm trying to put the Windows XP Firewall into an allow all ports configuration, and only deny certain ports I have in a list.


I've scripted this via batch commandline with netsh firewall add portopening commands. From what I've read, if activated the firewall denies all traffic and only allows ports with exceptions, so via batch scripting I've opened all 65,000+ ports on both TCP and UDP, essentially having the firewall turned on but in an "allow all" configuration. I then deny the 100 or so ports from my list that I want blocked after they are all open.


This strategy appears to work, but the problem I anticipated and am now seeing is that svchost.exe is taking 50% of my CPU time, having to continuously process these firewall rules.


From what I've seen on Windows XP, there's no way to have the firewall ON and in an "allow all" configuration" because the XP firewall cannot have port ranges defined, they must be defined one by one. Looks like Windows Vista or 7 would be much easier since the firewall got an advanced capabilities re-vamp.


Does anyone have a suggestion on how to achieve this "allow all", deny certain" strategy? I realize this is a strange use of the Windows firewall but assuming I had to do this, is it possible?


Answer



Totally agree with afrazier comment...


As far as I know, there's no application or service requiering to open 65536 ports inbound!


To be clear, an open port is a port on which a service is running and ln listening state in order to answer to an external connection sollicitation. E.G. the port 80 HTTP for a web server with Apache (for example).


The incomming connection sollicitation is a TCP packet with the flag SYN and no data to the the required port: port 80 for a HTTP connection, 119 NNTP, 21 FTP and so on.


If the service is ready to allow a connection to this port, the server sent a TCP packet with the flags ACK, SYN to the client and the client confirm the connection sollicitation by a TCP packet with the flag ACK... and the connection enter in the established state. This is the normal handshake.


If the service on the listening port is'nt able to accept a connection it sent a TCP packet with the flags ACK, RST: this is a closed port...


Hmmm... to make a long story short:



  • 1- You need a Third party firewal. May be Look'n Stop which is a
    ruled based firewall.


  • 2- Configure the application requiring to open these large number of
    ports and set the rule ONLY for this application


  • 3- Put the this rule before the rule blocking all other TCP incomming
    connections sollicitations (with the flag SYN) and so on...



Hope this help. Let us know. :)


linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...