Shrinking linux disks in vmware workstation

Here is the theory behind what we are doing

1- Fill all empty space with zeros, you can do that by writing a gigantic file full of zeros to fille up all empty space then crash when no space is left to put the file

cat /dev/zero > zero.fill;sync;sleep 1;sync;

Delete the file we just made, zeros are left behind

rm -f zero.fill

Shut down the VM, and go to the windows host running the vmware workstation

Navigate to the directory where the .vmdk files are located.

Changing the root password in an LXC container

If you forget your LXC container’s password, you can reset it from within the LXC host

1- chroot into the containers filesystem
chroot /var/lib/lxc/vm51/rootfs

2- issue the passwd command and enter the new password for the container

3- type exit to get back to the LXC host prompt

 

Another way is to simply fire the container up, then run

lxc-attach -n vm51

then execute the passwd command like you normally do, then the exit command

It is very important to understand that if you don’t have something such as fail2ban on your server, it could be that someone had bruit-forced into your container and changed the root password, in that case, i would completely recommend deleting the whole container and re-creating it from scratch

The reason is that we don’t know what the attacker (if any) had installed inside the system

Tar error and how to overcome

For some reason, while i was extracting half a terrabyte of a tar.gz file with the following command

tar -xvf thisfile.tar.gz

i got the following errors

tar: Skipping to next header
tar: Error exit delayed from previous errors

So, it turns out that tar files terminate with a big bunch of zeros, to tell the tar files to not consifer that bunch of zeros a terminator, you would use the -i switch (before the F not after)

So the command would look like

tar -xvif thisfile.tar.gz

Seems it worked for me, it may or may not work for you, but this is one of the reasons you could get this error. because tar dopes not tell you what the exact error is.

Using axcel, quick example

Using axcel

axel -a -s 10240000 -n 5 URL

-a is the nicer one line view
-s is maximum speed, here it is 100Mb (10MB)
-n is the maximum number of connections

———————————–

To download a list of files
1- Put them in a text file (Make sure the line feeds are linux (\n))
2- Run a while loop from terminal

while read url; do axel -a -n3 $url; done < /root/download124.txt

Dynamic Round Robbin DNS (DDNS with round robin support)

We have just developed an application in-house for Dynamic DNS with round robin (for our own “validation through IP” purposes) that functions as a dynamic DNS with round robin features.

We could make this application public if it gets enough attention and is of use to many people.

The application is fully functional at the minute, but if it gets attention, we can improve the user interface, and make it public.

The Dynamic DNS with round robin support takes into account that connections that have not contacted for update should be removed from the round robin record.

* Username and password verification
* modifiable ttl in sync with frequency of IP checks
* Almost infinatly Scalable system.
* PHP client, easy to create any other client. PHP update script can run as cron job.
* remove frm list when no update requests is received for a user set amount of time, return to list once an update request is sent again
* Super fast
* For multi homed links, the password per hostname (not per zone) eliminates the risk of an update request through a different eithernet adapter that is the main link of another machine.
* Security through MD5 sums that change with the IP change (Your passwords are never transmitted during an update)
* if 2 machines are using the same IP address, the anti_duplicate_valuesarray will limit the round robin records to that value only once.
* the dead record currently only dissapear when a different IP changes, 2DO: change must reflect when another updates !

Disable Windows has detected a hard disk problem message in windows

The following are the steps to disable the error message associated with a bad hard drive, the message that windows will display after every login, we will disable it from within windows without disabling it in the BIOS.
error

The message above reads (On my computer, on yours, the disk model number and the names of the volumes will probably be different.

Windows has detected a hard disk problem.
Back up your files immediately to prevent information loss, and then contact the computer manufacturer to determine if you need to repair or replace the disk

Then, you are presented with the following two options

Start the backup process

Ask me again later
-- If the disk fails before the next warning, you could lose all of the programs and documents on the disk.

In the show details dialogue you should see 

Immediate steps
Because disk failure will cause you to loose all programs, files and documents on the disk, you should back up your important information immediately, try not to use your computer until you have repaired or replaced the hard disk.
Which disk is failing
The following hard disks are reporting failure.
Disk name: TOSHIBA MK3264GSXN ATA Device
Volume: C:, D:, E: 

My advice would be

Do not disable S.M.A.R.T. from BIOS, rather, ask windows not to display this message, this is because for a failing disk, you would want the S.M.A.R.T. data accessible from other programs or to keep an eye on it.

To disable this error message from within windows, do the following

click the start button and enter the word “task” in the search box, Task Scheduler should appear, right click it and chose run as administrator.
Once it is open, follow the tree to your left as follows
“Task Scheduler Library” => “Microsoft” => “Windows”. => “DiskDiagnostic”

As shown in the image, select the second entry, right click it, then click disable.

The following is the dialogue
diskdiag

close, and restart your computer to check if it worked.

MySQL – Can’t change ownership of the file Errcode: 1

When trying to repair tables (or optimise), there seems to be an error that is giving me a hard time.

The SQL statement REPAIR TABLE mytablename; returns the following

+---------------------+--------+----------+----------------------------------------------------------------------------------------------+
| Table               | Op     | Msg_type | Msg_text                                                                                     |
+---------------------+--------+----------+----------------------------------------------------------------------------------------------+
| mydbase.mytablename | repair | error    | 1 when fixing table                                                                          |
| mydbase.mytablename | repair | Error    | Can't change ownership of the file '/hds/wd1tb_2/mysql/mydbase/mytablename.MYD' (Errcode: 1) |
| mydbase.mytablename | repair | status   | Operation failed                                                                             |
+---------------------+--------+----------+----------------------------------------------------------------------------------------------+

So, the only solution up to now is to

chmod -R 700 /hds/wd1tb_2/mysql/
chown -R mysql:mysql /hds/wd1tb_2/mysql/

This error has already been reported as a big long time ago, but it seems to be still there, this is the only way around the situation, and it does not seem to have been resolved with MySQL 5.5.33-0+wheezy1

Extracting 7z files

On debian, i always recommend you install p7zip-full not p7zip

To extract with 7zip on linux, in order to maintain directory structure, use the x rather than the e, so the command to extract is

7za x file.7z

The file above would have been produced by a command such as

7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1

The above line adds all files from directory “dir1” to archive archive.7z using “ultra settings”

Quickly disable and enable autoplay and autorun

Disable auto run and auto play.

1- Download : the first to disables windows auto play (to protect your computer), the other enables it if you ever change your mind.
You will want to save the files not to view them, so in firefox you would right click then “save link as”, similar functions are available in other browsers.
Download Disable Auto Play
Download Enable Auto Play

2- Run the file you downloaded
3- Restart your computer

Why diable autorun / autoplay ?

i disable it because i don’t like auto run viruses that my antivirus don’t catches ! maybe you have your reasons, like you don’t like the thing that pops up when you insert a flash stick or a DVD.

What is the difference between autorun and autoplay ?

AutoPlay is the new AutoRun (Windows vista and above)

Auto Run : the original from windows 95, the system executes the program mentioned in autorun.inf when removable media is inserted.

Auto Play : Like auto run, but when and if there is no autorun.inf file, the OS will try to guess and give you choices.

All you need to disable it, is to download the following from above, and run the one named disable-autoplay.reg, if you want to re-enable it for some reason, run the file that says enable-autoplay.reg

What happens when i run the files above ?

Rather than asking you to use regedit to edit your registry and change values or add them, we made a reg file with the values for you to download and use, what you are downloading is a text file (and not a program) that will instruct your computer on the new registry values.

The values that are modified (or added if the key does not exist) are

HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer ENTRY NoDriveTypeAutoRun
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionpoliciesExplorer ENTRY NoDriveTypeAutoRun

The disable file will set the values above to 000000FF (Decimal 255) to disable auto play (autorun), and the enable file above will set auto play (autorun) to 00000001 (Decimal 1).

Windows provides a tool to do it too, you can do this using gpedit.msc.
Hit start, type gpedit.msc then when that appears in the list, hit enter.
Computer Configuration >> Administrative Templates >> Windows Components >> AutoPlay Policies

That will open a new window that will allow you to enable or disable autorun.

Or you could just click one of the files above and run it on your computer.