Backup or move an LXC container

You can not just copy an LXC container, wat you need to do is among the lines of

cd /var/lib/lxc
tar --numeric-owner -cf container_125_fs.tar vm125

The magic is mainly about maintaining the numeric owner of files, which is lost when you copy the files using the host machine 😉

you can untar it the same way you untar any other tar file.

for example, to untar it to a different location, you can use the command

tar -xf container_125_fs.tar -C /target/directory

This whole thing is very useful in moving a container to a different directory, then modifying the config file to point to that directory, as well as moving it to a different machine, the reason you can’t just move it is that moving will cause some issues as the move command does not take the ownership differences between host and guest into account.

Searching for text within file contents

Searching for text within file contents in Linux

When you want to do this, odds are, you know what kind of file you are looking for, My first guess would be you would not be looking in zip, mp4, flv, etc… those are huge files, where in the unlikely event they do contain your string, it’s still not the file you are looking for…

So, you would probably want to look at the problem as, search the contents of text files for a certain text string

the best way to acheive that is to start by allowing the find command to find text files that may contain that string, then passing the “candidate for searching” files to the grep command

So if I am looking for a config file that contains a config named living-room, I would use a search such as this one

find /hds -name '*.conf' -exec grep -i 'living-room' {} \; -print

What is nice about this is that you can also look at both separately, so the find command has plenty of documentation online, and so does grep

Now, there are other ways to do this, the most popular of which is using grep on it’s own, here are some examples

The directives are as follows

i stands for ignore case (Slows things down, but sometimes necessary).
R stands for recursive. (Look inside inner folders depth first)
l stands for "show the file name, not the result itself".
e look for things matching a patern
--include Include files that match this pattern
--exclude Exclude files that match this pattern
--exclude-dir exclude directories listed
Examples
grep -Ril "text-to-find-here" /
grep --include=*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
grep --exclude=.o -rnw '/path/to/somewhere/' -e "pattern" grep --exclude-dir={dir1,dir2,.dst} -rnw '/path/to/somewhere/' -e "pattern"




Hope this helps, good luck

3.3V Power supply – Linear Voltage Regulator

As usual i will start with the main points / the lowdown

1- Car voltage can (Depending on car) can go up to 15.3 when bulk charging the battery, the maximum voltage for the LD1117AV33 is 15V, so it is a no go.

2- My DoIt esp12F devkit came fitted with the AMS1117.

The regulator that shipped with my DoIT esp12F devkit is the AMS1117, which seems to be an excellent choice providing up to 1A of current, and accepting input voltages of up to 18V ! Yet, the voltage regulator is not fitted with a heat sink, hence, it will provide nowhere close to 1A reliably

the three liniar regulators I will be comparing in this post are

 

 ld1117v33  lf33abv  TC1262
Maximum Input Voltage 15V 16V 6V
Minimum input voltage (Based on dropout voltage) 4.3V 4.3V 4.3V
Can we change the input voltage while application is switched on  Yes   Yes   Yes
Maximum current draw (Is it enough for my application)
Higher is better
800 500 500
Quiescent current
Current drawn with no load (Not too relevant to cars)
Lower is better
5.5 mA  0.5 mA  0.070 mA

 

Even though i have always used the LD1117AV33 Linear Voltage Regulator in IOT projects, simply because it can provide up to 800 MA of current at 3.3V, I had to look at other voltage regulators for this particular project because it involves a vehice, Now, you may want to skip to the comparison table if your IOT project is not for a car, but

 

As usual, I post my research in this blog for my own use and so that others can benefit from it, so sometimes it looks as though it is not well written, but it could spare you a long time of research

First thing you need to know, is that not all cars have the same voltage, the  12V car battery voltage is nominal, a car battery is usually full and in good health when it’s voltage is around 12.8 or even 12.9 (while the car is off), and because the charging circuit differs from car to car,  A car alternator might step up the voltage to up to 15.3 when it is bulk charging the battery, and float charge a car battery at 14.2 or 14.3 when it considers it full, so bottom line, a linear voltage regulator needs to tolerate at least 15.5V

 

Even though i have always been using the LD1117AV33 step down, and indeed it is a reliable thing, I can not find any document that states that going above the maximum input voltage of 15V is okay, hence, the regulator is disqualified from the word go

 

 

 

Godaddy / Wild west domains, reseller examples

Godaddy / Wild west domains, reseller examples (List is work in progress)

fxdomains.com
polodomains.com
hostingdude.com
cheap-domainnames.com

Super resellers (Sells reseller accounts)
DomainResellerDirect.com

 

The main purpose of this list is for my own reference, as I try to make my own reseller account work for me, as i investigate how they are making it happen, i will probably learn a bit from them.

Finding duplicate files on NAS storage

I have this bad habit of copying things so many times when modifying them, when that is a large database, we talking many gigas, so here is a script to find those duplicate files among many hard drives and telling you which ones are duplicates, moving and deleting and symbolic linking is done manually after.

1- this script is PHP-CLI, so make sure that is installed on your computer
2- this script runs the find command, make sure it can execute that program
3- you run the script with the path parameter, but will need to edit the script to change the 1GB size i have hard coded

What this script does is

1- find files with size greater than 1GB (find /hds -size +1G)
2- Store the files in database with size
3- retrieve the files ordered by size
4- if 2 files have exactly the same size, calculates MD5sum for the first MB of the file
5- If the MD5 of the first MB of the files are the same, calculate the whole MD5
6- If they turn out to be duplicates, they are printed to the command line

(SOLVED) Failing to install debian stretch (9) on an asus p9x79 motherboard

At first, i checked the MD5 of the DVD which was as follows
b894f1e8ebf3065a488b6c01a742cf4e = debian-9.0.0-amd64-DVD-1.iso

The lowdown: Bottom line before you waste your time, the trick is disabling secure boot in the bios, if that does not work, read the article, it is faster if you see my trial and error than doing it yourself.

Following that, i DD the DVD onto a flash stick, Trying to install with network mirror, during the “Select and install software” stage, i get the following error on a beautiful red screen

Installation step failed
An installation step failed. You can try to run the failing item again from the menu, or skip it and choose something else. The failing step is: Select and install software

And a continue button that takes me to the list of steps/stages

In any case, the next time, i tried without a network mirror, and that stage completed successfully, but what do you know, a new error popped up, this time concerning the inability to install grub on the partition.

trying the above with a USB DVD gave the same exact errors, and thinking it might be a USB issue, i installed an internal SATA hard drive, but still same error.

So the only way to continue at this stage (Where both grub and LILO would not install is to continue without installing a boot loader.

So, considering the circumstance, i had 2 options, fix it manually, or try to figure the problem out, figuring out the problem would seem wiser, since We don’t want to have this problem every time we come across an installation scenario

Note: Disabling hardware turned out to be irrelevant, its all about the secure boot.
So i entered into UEFI (Delete at post), and disabled everything that may be causing the problem, for example, i disabled the azilla audio, I disabled the USB 3 Controller (Asmedia), and so forth, then i noticed that there is a secure boot option that had 2 options within, the first would be Windows and the other would be non windows.

So i switched that to non-windows (Even though the windows option worked fine on Jessie, and then went back to the USB flash stick, booted the system.

So this time, the installer is telling me that (SCREENSHOT)

So the answer to whether or not i should force the UEFI installer or not was YES, force it

As for whether or not to use a network mirror, for the sake of this article, i decided to experiment with installing with network mirror yet, then if that does not work, run the installer without a network mirror, the reason is that the secure boot option, if it were to fix anything, is most likely going to fix the failing to write boot manager, so to have this complete, we will need to start with the one more likely to fail

So running the installer with network mirror came back with the same error as anticipated, So i ran the installer again, but with no network mirror, and now the error is “Unable to install GRUB in dummy, executing “grub-install dummy failed”

So, now that all those options have failed, I am up for one last thing to try, I will boot from a linux stick, then issue the following command

wipefs -a /dev/sda

Now let us try again !

Now, a new error, the installer claims that a 40GB SSD is too small to be partitioned (Maybe because 64GB of ram will make a swap file larger than the disk) , so i rebooted again to the debian USB stick, but this time, to delete any existing partitions on the disk (Even though wipefs should have handled that)

So, because parted was not available, i used fdisk, followed by “o” followed by create a new partition on the whole disk

Next step, i took the 40GB SSD, reduced the ram on an HP 8300 USFF PC to 4GB, installed the disk and installed debian stretch (Using network mirror !), all went perfectly, now we would like to examine if it would boot the other computer, it did not,

Solution:
so i installed the OS on a very old core2 duo laptop, then it worked on the asusp9x79 after i enabled legacy mode rather than UEFI in the bios, I also made sure the boot disk was on the first sata port (SDA), and thats that.

I anticipate that this problem will also apply if you try to upgrade Jessie to Stretch, so BEFORE YOU UPGRADE, switch that UEFI secure boot option to non windows (Or disabled) depending on your motherboard.

I7 930 VS I7 980, 180% faster, at least theoretically !

I upgrading my I7 930 to an I7 980 worth it ?

The answer is YES, the I7 980 at the time of writing cost me $135 used on ebay.

there are 2 extra cores in the CPU, so it is like having an extra dual core computer to share the RAM and any other resources, even without wasting more electrical power.

It is also the newer Gulftown architecture (32nm Lithography), compared to the older Bloomfield (45nm Lithography)

So how much computing power did i gain for this database server

i7 930: 3GHz * 8 = 24 total at turbo speed
i7 980: 3.6GHz * 12 = 43.2 total at turbo speed

That is 180% of the original
almost double the computing power for 100 dollars !

To make this more interesting, many are reporting the with the new bios update, the GA-X58A-UD3R will allow for 48GB of ram, not 24, I will be trying that soon.

going back to original firmware on tp-link

Let me start with the warning, DO NOT FLASH THE ORIGINAL TPLINK FIRMWARE BACK BEFORE FINDING OUT IF YOU NEED TO STRIP THE FIRST NUMBER OF BYTES OUT, YOU WILL BRICK YOUR ROUTER, IF YOU SEE

Failed to erase block

IF YOU DO, YOU NEED TO MAKE SURE YOU GET IT right after that, or you will start to get.

segmentation fault

on every and any command you run, at this stage, when you see this error after the failed to erase block error, your router is bricked, reboot it and it will not boot back up. if this happens, you might (depending on the model you have) have to connect your router to a com port and debrick it.

Now that you know, let’s see how to deal with this

If your firmware download file name has the word boot in it’s file name, you will need to strip out the first 0x20200 bytes (131584 bytes), if you fail to do this, meaning you fail to either identify if you need to do this, or fail to trim them, you will brick your router in the next step, to make matters both, TP-LINK is no longer including the word boot in firmwares with boot.

so to trim

dd if=orig.bin of=tplink.bin skip=257 bs=512

this command means read the file into another, skipping the first 257×512 = 131584 bytes (Which is the number you find above)

Now, you can flash it with the following command

mtd -r write /tmp/tplink.bin firmware

And if it says all is ok, you can now reboot your router into the new firmware

 

 

Converting DVD to MP4 (H264) on windows (With the free ffmpeg tool)

Converting DVD files to MP4

Video files on a DVD are usually in the video_ts directory and have the extension VOB.

On Windows, the easiest way to do this is by copying the files in the video directory on the DVD to a folder in your hard drive, then running the commands below, then deleting the source VOB files,

NOTE to ignore: surely, you can do it by adding absolute paths, but that would force me to explain much more here. with find the directory and copy the path then append it here then copy the names and append them to the path and all that good stuff, so why not just make it simple with copy then delete the source.

Assuming you have ffmpeg installed and in your path, you would execute the command like so, concatenating all the video files in the DVD

cd c:\directory_where_you_put_the_vob_files
ffmpeg -i "concat:VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB|VTS_01_4.VOB|VTS_01_5.VOB" outfile.mp4
Another note to ignore, On a linux box (The above works on both linux and windows), you can concatinate the VOB files then pipe them into ffmpeg like so
cat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB VTS_01_4.VOB VTS_01_5.VOB | ffmpeg -i - outfile.mp4