domenica 8 novembre 2015

Windows 7 10 disk recovery with commnd prompt

Command prompt > type diskpart.
Type list disk, find the one that is your SD card, by matching the capacity, and remove all other flash disks to keep confusion minimal.
It isn't likely that your hard drive matches your SD card size, I hope. Anyway, it will have a Disk # next to it.
Now type "select disk #" where number is the SD card. Now type "clean". Then go into Disk Management by typing "compmgmt.msc" in the Run window and selecting Disk management on the left pane. You should get a message saying that a disk must be initialized. If not, then look through the list of disks for the SD card, and it should say "Not Initialized".
Right click, initalize, select MBR and follow the rest of the info. This was the method I used on my flash drive to clear out linux mbr bootloaders.

For SD cards try:

[GUIDE] Using chkdsk to fix a corrupted SD card-admin.jpg

[GUIDE] Using chkdsk to fix a corrupted SD card-untitled.png

lunedì 7 settembre 2015

Disk Recovery with Linux and testDisk tool.

Make an image before doing ANYTHING, then make a copy of the image, and do your work on that. Then you can always revert back to a pristine image of the card in case something messes up the image.

dd if=/dev/sde1 of=sdcard.img bs=1M
fdisk -l /root/sdcard.img will give you all the info about the img file created 
Then you can setup a loop device with that image and work with that:

# losetup -f gives a list of loop devices available
# losetup /dev/loop0 disk.img
# file -s /dev/loop0
/dev/loop0: Linux rev 1.0 ext3 filesystem data
# mount -o loop /dev/loop0 /mnt
# umount /mnt
# losetup -d /dev/loop0
then use testdisk on the mounted file system.
(to install testdisk apt-get install testdisk) more here: 

(Your loop device will be /dev/loop0 or similar, find out with losetup -a)

The problem is that the .img files are not images of a partition, but of a whole disk. That means they start with a bootloader and a partition table. You have to find out the offset of the partition and mount it with the offset option of mount.
If you do a
fdisk -l /path/to/image
it will show you the block-size and the start-block of the partition. You can use that to calculate the offset.
For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004bfaa

    Device Boot      Start         End      Blocks   Id  System
Stick.img1   *         128     8015999     4007936    b  W95 FAT32
So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536.
So the mount command would be
mount -o loop,offset=65536 Stick.img /mnt/tmp
 then do testdisk on image directly.

testdisk ./image.imge

lunedì 27 luglio 2015

Migrating a live system from ext3 to ext4 filesystem

This article is meant to serve as a guide for migrating a live system from ext3 to an ext4 filesystem, including migration of files to use extents, a major feature in ext4. It describes the entire migration procedure, including common pitfalls involving a migration of a live system, as opposed to doing a fresh install.

Reasons for conversion

The explanation of advantages and disadvantages of ext4 is beyond the scope of this article. If you are not affected by the limitations of ext3, and not willing to take risks, it may not be worth it. On the other hand, on successful completion of the migration procedure your system may perform faster, experience shortened file system checks, and have increased reliability with no ill effects.

Trying ext4 without conversion

An interesting property worth noting is that you can mount ext3 filesystems as ext4 without doing the conversion first. All you need to do is to modify your /etc/fstab to say "ext4" instead of "ext3" for all your filesystems, and reboot. This way you will be able to go back to ext3 at any time.
This may be a nice test before attempting full conversion, but this will only enable ext4 features that are compatible with ext3. And that means that no major feature of ext4, like extents, will be enabled.

Migrating to ext4

Word of warning

Do a backup before attempting this procedure. It may render your system unbootable, and may destroy your data.
Your filesystems will become incompatible with ext3, so you need to make sure that you have a complete toolkit available with ext4 support before doing a conversion. This includes a bootloader, e2fsprogs, mount, and a recent kernel.


  • e2fsprogs 1.41.6
  • mount 2.16
  • linux-image 2.6.30
  • grub 1.96+20090808
All of these packages are available in Debian unstable or experimental. Lower versions may work, except for e2fsprogs - this is indeed the lowest version.

Converting a non-root filesystem to ext4

As long as you are converting a filesystem that can be unmounted, it is fairly simple procedure. In this example we will be converting a /dev/sdc1 partition mounted as /home directory.
First, unmount the partition.
umount /dev/sdc1
Next, run a filesystem check on it to make sure it is in sane condition. We are still on ext3.
fsck.ext3 -pf /dev/sdc1
Enable new features of ext4 on the filesystem.
tune2fs -O extents,uninit_bg,dir_index /dev/sdc1
Option "extents" enables the filesystem to use extents instead of bitmap mapping for files, "uninit_bg" reduces file system check times by only checking used portions of the disk, and "dir_index" allows storing the contents of large directories in a htree for faster access. Option "dir_index" is also supported by ext3, so you may already be using it, but it makes no harm to specify it here.
Run a filesystem check. It will find errors. It is normal. Let it fix them. You may want to run the check twice to make sure that the filesystem is now clean.
fsck.ext4 -yfD /dev/sdc1
The "-D" parameter will actually enable the "dir_index" option by rebuilding directory index. It can be rebuilt (optimized) at any later time by running the check with the parameter.
Now edit your /etc/fstab file to say "ext4" instead of "ext3" for /home. Other options may differ for your system.
/dev/sdc1 /home ext4 defaults 0 2
Try to mount your new ext4 filesystem.
mount /home
If it succeeds, congratulations. If not, do not panic. You have not lost your data. And you have a backup after all, right? Make sure you have all the latest tools listed in prerequisites. Get them form Debian unstable or experimental if needed. Upgrade and try again.

The /boot partition

If your /boot is a separate partition, all is good and great. Just leave it as ext3. Latest development grub versions do have support for ext4, but it still may and will fail for some given snapshot of grub.
As ext3 can be mounted ext4 without conversion, you can just edit your /etc/fstab to say "ext4" instead of "ext3" for boot partition.
/dev/sdb1 /boot ext4 defaults 0 1
Most features of ext4 will not be used, but that makes little difference for /boot, as it is only used early at boot time. And since this is essentially still an ext3 partition, grub will have no problem booting it.
If, on the other hand, you do not have a separate /boot partition, you should consider creating one. Otherwise you must be really careful, and not enable features not supported by grub, or make sure that you are using a version of grub that supports all of them.

Converting a root filesystem to ext4

Converting a root filesystem is a bit more tricky because you cannot unmount it, as your system is running on it. Nevertheless it is still possible to do it without using an external bootable media. You should do this in a single-user mode.
First step is to modify your /etc/fstab file to say "ext4" instead of "ext3" for root partition. This is important because you will be operating on a read-only filesystem later, and will not be able to make the change, and this would result in your system unable to mount a root filesystem on next boot.
Let us assume that root partition is /dev/sda1, so your /etc/fstab should look something like this.
/dev/sda1 / ext4 defaults 0 1
Now remount the root filesystem read-only.
mount -o remount,ro /
Then run a filesystem check on the root filesystem.
fsck.ext3 -pf /dev/sda1
It will tell you to reboot the system. That may be a good idea, so simply boot into single-user mode and remount it read-only again. It is fine even though we have already modified /etc/fstab, because ext3 can be mounted as ext4 without conversion.
Next, enable all the ext4 features on the root filesystem.
tune2fs -O extents,uninit_bg,dir_index /dev/sda1
And run run a filesystem check on the root filesystem again. It will find and fix errors. This is normal.
fsck.ext4 -yfD /dev/sda1
You can now reboot to your new ext4 system, and enjoy faster filesystem check times, better performance, and all the improvements of ext4. Well, almost; read the next section.

Migrating files to extents

It may seem that the migration from ext3 to ext4 is now complete, and it is almost true. Except that any old files created before the conversion will continue using the bitmap mapping of ext3 instead of extents of ext4.
Files will eventually migrate to the new format as they are updated during normal system operation, because on next write they will be saved using extents. Unfortunately many frequently used files (like application binaries) are often read and rarely written to. The outcome is that the files will remain using the old format for a long time, and you will not be able to experience full potential of ext4.
A utility called e4defrag, which would be able to migrate files, is being developed. But unfortunately it is far complete, and is not suitable for use on real data as of time of writing.
Fortunately it is possible to migrate separate files to extents by using chattr utility, which comes with e2fsprogs package. It allows you to set an attribute on a file which causes the kernel to rewrite the file using extents. It even possible to do this on a mounted and working file system. In fact, that is the only way to do it.
Please not that this feature is still experimental and has not been tested thoroughly. Performing such operation may be dangerous. It may also flood your system log with warnings and errors. You should first test this on small number of insignificant files.
You can check if a file (or a directory) is using extents with lsattr.
lsattr /home/user/foo/bar
If it not using extents, the output will be something like this.
------------------- /home/user/foo/bar
The dashed line here is simply a placeholder for various attributes a file can have. This means that it has no attributes.
Now set the attribute to use extents on the file.
chattr +e /home/user/foo/bar
Now list the attributes again, and you will notice that the output looks like this.
-----------------e- /home/user/foo/bar
Note the "e", which means that it is now using extents.
Check your system log and look for scary things. Not finding any is a good sign. That means you can continue.
Modifying attributes with chattr can be done on multiple files. Although digging trough the entire directory system is not really feasible, so you can use some of the shell magic to accomplish the task.
find /home -xdev -type f -print0 | xargs -0 chattr +e
find /home -xdev -type d -print0 | xargs -0 chattr +e
The first command will run "chattr +e" on all files in /home, and the second will do the same for directories.
It is possible to run this on the root directory and convert everything at once. But running this on one file system at a time with "-xdev" parameter will prevent it from diving into file systems that do not support extents. It may also be useful to run filesystem check on a partition after conversion.
It may make sense to perform this in single-user mode to minimize the chances of something interfering with a task. You may also want to shutdown syslog, as it may generate a lot of warnings.

martedì 28 aprile 2015

How to Enable / Disable Multiple RDP Sessions in Windows 2012

How to Enable/Disable Multiple RDP Sessions in Windows 2012By default, Windows 2012 servers allow a single Remote Desktop session. If only one session is available and you take over another person's live session, you may choose to enable multiple RDP sessions. This article describes the process for enabling and disabling multiple sessions.

Enable Multiple RDP Sessions
  1. Log into the server using Remote Desktop.
  2. Open the start screen (press the Windows key) and type gpedit.msc and open it
  3. Go to Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Connections.
  4. Set Restrict Remote Desktop Services user to a single Remote Desktop Services session to Disabled.
  5. Double click Limit number of connections and set the RD Maximum Connections allowed to 999999.
Disable Multiple RDP Sessions
  1. Log into the server using Remote Desktop.
  2. Open the start menu and type 'gpedit.msc' and open it
  3. Go to Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Connections.
  4. Set Restrict Remote Desktop Services user to a single Remote Desktop Services session to Enabled.

Add new user account from command line (CMD)

mercoledì 1 aprile 2015

CentOS Bugzilla install

I just went through installing Bugzilla on CentOS at work. I had to follow several guides online in order to get it installed and configured correctly. I thought I combine all of my findings into one simple guide.
I will be installing the latest Bugzilla at the moment which is 4.5.2 on a fresh install of CentOS 6.5 64-Bit.
Ok, Lets get started. Launch Terminal and switch to root:
In order to get Bugzilla up and running, we need to install Apache, MySql, and also gcc for compiling the Bugzilla packages.
Installing Apache
yum install httpd mod_ssl
Install MySql in Bugzilla
After the install is done, open port 80 in the Firewall
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
Save the changes to the firewall
service iptables save
Start the Apache service
service httpd start
Lets make sure that Apache will restart every time you restart the machine:
/sbin/chkconfig httpd on
Apache on Bugzilla
Lets test our Apache server by opening a browser windows and type our localhost IP,
Apache on CentOS
Install MySql
yum install mysql-server mysql php-mysql
MySql on CentOS
Lets make sure MySql starts at boot
chkconfig mysqld on
Auto start MySql on CentOS
Start MySql
service mysqld start 
Start MySql in CentOS
Set up MySql for root access
mysql -u root
Set the root user password
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('some_new_password');
Once done, exit MySql
Install gcc and prep packages
yum install gcc perl* mod_perl-devel
Install gcc in CentOS
Install Bugzilla
Now that we have all the prep work done and ready, lets go ahead and download the latest Bugzilla
Download latest Bugzilla for CentOS
unpack the download to the apache directory
tar zxvf bugzilla-4.5.2.tar.gz -C /var/www/html/
browse to the directory we just unpacked the file to and rename it to bugzilla
cd /var/www/html/
mv -v bugzilla-4.4 bugzilla
Login to MySql as root with the root password we set up earlier and create a new Database for Bugzilla
mysql -uroot -p
create database bugzilla_DB;
Grant all privileges to the database we just created to a newly created database user that we will be calling bugz and password bugz
grant all on bugzilla_DB.* to bugz@localhost identified by 'bugz';
Exit MySql
We should be in the bugzilla directory still. Lets check for all required bugzilla modules before the install:
After the check is done, we will see some missing modules that needs to be installed:
Bugzilla install on CentOS
Type the command below to install all missing modules automatically:
/usr/bin/perl --all
Lets do a check again to make sure all the modules did install
If all is good, we will get a message to edit the localconfig file for installation.
Bugzilla install on CentOS
Edit the localconfig file with your favorite text editor. Since I have GUI, I used gedit for a simple quick edit
gedit ./localconfig
Make sure you input the correct database name, user, and password we created earlier in the localconfig file
Bugzilla install in CentOS
Run ./ again
If all is well, should now successfully configure Bugzilla.
Bugzilla install on CentOS
Now we need to add Bugzilla to our Apache config file. Open httpd.conf with a text editor
gedit /etc/httpd/conf/httpd.conf
Add the following to the end of httpd.conf file
2     DocumentRoot /var/www/html/bugzilla/
6     AddHandler cgi-script .cgi
7     Options +Indexes +ExecCGI
8     DirectoryIndex index.cgi
9     AllowOverride Limit FileInfo Indexes
Bugzilla install on CentOS
Lastly, we need to edit .htaccess file and comment out “Options -Indexes” line at the top by adding “#”
Bugzilla install on CentOS
Lets restart our apache server and test our installation
service httpd restart
Bugzilla 4.5.2 on CentOS 6.5
If all goes well, we should see our successfully installed Bugzilla when we browse to localhost :)
Hope this helps. Let me know if you have any questions.

Reset MySQL password

The Server root user is the server's main user. The MySQL root user has complete control over MySQL only. The two 'root' users are not connected in any way.

Stop MySQL

The first thing to do is stop MySQL. If you are using Ubuntu or Debian the command is as follows:
sudo /etc/init.d/mysql stop
For CentOS, Fedora, and RHEL the command is:
sudo /etc/init.d/mysqld stop

Safe mode

Next we need to start MySQL in safe mode - that is to say, we will start MySQL but skip the user privileges table. Again, note that you will need to have sudo access for these commands so you don't need to worry about any user being able to reset the MySQL root password:
sudo mysqld_safe --skip-grant-tables &
Note: The ampersand (&) at the end of the command is required.


All we need to do now is to log into MySQL and set the password.
mysql -u root
Note: No password is required at this stage as when we started MySQL we skipped the user privileges table.
Next, instruct MySQL which database to use:
use mysql;

Reset Password

Enter the new password for the root user as follows:
update user set password=PASSWORD("mynewpassword") where User='root';

and finally, flush the privileges:
flush privileges;


Now the password has been reset, we need to restart MySQL by logging out:
and simply stopping and starting MySQL.

On Ubuntu and Debian:

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

On CentOS and Fedora and RHEL:

sudo /etc/init.d/mysqld stop
sudo /etc/init.d/mysql start


Test the new password by logging in:
mysql -u root -p
You will be prompted for your new password.

Redhat CentOS Fedora Yum Management

 yum clean all
 yum check
 yum erase apf
yum update

giovedì 19 febbraio 2015

Cisco UCS Defining CIMC Network Static Settings Using a Script File an usb key

Use this procedure to define static network settings for multiple servers by automating the configuration process with a script file.
Step 1   Use a text editor to create a file named network.cfg.
Step 2   Create the contents of network.cfg in the following format by using only the tags that you want to set:

For example, to disable DHCP, set the IP address, subnet mask, gateway, and user password, use the following sample values:
dhcp-enabled: 0
password: nonpasswd

Step 3   Use a text editor to create a file named startup.nsh with the following contents:

Step 4   Copy your network.cfg file and your startup.nsh file to a USB thumb drive.
Step 5   Insert the USB thumb drive into a USB port on the server.
Step 6   Press and release the Power button to boot the server.
Step 7   Observe the booting process and press F6 when prompted to enter the BIOS Boot Manager.
Step 8   Select EFI as the boot device and then press Enter. The server power cycles and launches the configuration utility, which runs the startup.nsh file. Any errors are displayed on the screen and on an errors.txt file.
Step 9   Remove the USB thumb drive, alter the network.cfg file with your next IP address, and then insert the USB thumb drive into the next server that you want to configure.
Step 10   After the server has been assigned an IP address, you can use that address to access the service processor's GUI or CLI management system.

martedì 17 febbraio 2015

How do I fix the GPG error “NO_PUBKEY” for atp-get GUI method

By far the simplest way to handle this now is with Y-PPA-Manager (which now integrates the launchpad-getkeys script with a graphical interface).
  1. To install it, first add the webupd8 repository for this program:
    sudo add-apt-repository ppa:webupd8team/y-ppa-manager
  2. Update your software list and install Y-PPA-Manager:
    sudo apt-get update
    sudo apt-get install y-ppa-manager
  3. Run y-ppa-manager (i.e. type y-ppa-manager then press enter key).
  4. When the main y-ppa-manager window appears, click on "Advanced."
  5. From the list of advanced tasks, select "Try to import all missing GPG keys" and click OK.
    You're done! As the warning dialog says when you start the operation, it may take quite a while (about 2 minutes for me) depending on how many PPA's you have and the speed of your connection.

giovedì 12 febbraio 2015

Cisco Nexus 5000 enable FEX

switch# configure terminal
switch(config)# feature fex
 This example shows how to associate the Fabric Extender to an Ethernet interface:

switch# configure terminal
switch(config)# interface ethernet 1/40
switch(config-if)# switchport mode fex-fabric
switch(config-if)# fex associate 101

This example shows how to associate the Fabric Extender to an EtherChannel interface:
switch# configure terminal
switch(config)# interface port-channel 4
switch(config-if)# switchport mode fex-fabric
switch(config-if)# fex associate 101

Reclaim Terminal on Cisco Terminal Server

Connect to the cisco terminal server via telnet or ssh.
enter pass and ena pass.

show line

A list of all the lines is shown thee ones with a * (star) next to them are in use.

To reclaim the line launch:
clear line 9

now connect via telnet to the IP:PORT.

Reset Terminal license on Windows 2008, 2008 R2 and 2012

While Windows installed with Terminal Server role it does work without License for 120 Days on trail license, where within 120 days if the License server is not Connected the server will stop accepting connection with below error and event ID

error no licence

EventID: 1128
Source: TerminalServices-RemoteConnectionManager

The RD Licensing grace period has expired and the service has not registered with a license server with installed licenses. A RD Licensing server is required for continuous operation. A Remote Desktop Session Host server can operate without a license server for 120 days after initial start up.


The official solution is to Activate the RDS/TS CAL License server and point the Server to License server with User/Device License and will be resolve the problem

But if you want to reset the timer and again avail 120 days grace time  here is the solution

The solution was to delete the REG_BINARY in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod
Only leaving the default.

Note: you must take ownership and give admin users full control to be able to delete this key.

After a reboot the server should be working again for another 120 Days.
REMEMBER: regedit must be RUn in administrator mode.
REMEMBER2: you would need to take the ownership of the GracePeriod folder and inherit the permission to the child folders and content. Post which you would be able to delete the key

lunedì 19 gennaio 2015

Cloning Redhat Centos fedora Virtual machine on Vmware

1) First you clone a VM.
2) In vCenter selec the VM right click and clicl on clone. Follow instructions.
3) Once done go to the cloned VM and write down the MAC address of the VM's nic/nics.
5) Login to the cloned VM as root.
6) delete file /etc/udev/rules.d/70-persistent-net.rule
7) Go to /etc/sysconfig/network-scrips/ifcfg-ethX (X is the interface index number). Example file content:

NAME="System eth0"

Now change the HWADDR to the real MAC address that you noted aìin point 3.
8) If you have multiple interfaces do the same for all.
9) If you have to set some static routes edit the /etc/sysconfig/network-scrips/route-ethX file.
EX: via dev eth1

10) restart network service with: service network restart
11) reboot.