Recover Unallocated Partition of Hard disk

Testdisklogo clear 100.pngToday was a hectic day for me. Today suddenly while accessing my External hard disk in latest Windows 10 May 2019 update the disk was not initialising. While trying to initialise disk with GPT/MBR from the "Disk Management" suddenly my hard disk started displaying as "Unallocated".

It was such a frustrating situation for me as I was worried about loosing my data. I have tried many solutions to fix it out but unfortunately it was increasing my frustration. At last, I found a freeware named as "TestDisk" which saved me. Initially while running this command line utility, I was unable to understand the processing even if it had pretty easy instructions but later I was able to fix my hard disk access.

In the world of data recovery it happens that your Operating System stops detecting your external hard disk. I have tried to use Ubunut Live CD to access the hard disk but it also shows me the same issue as on Windows.

In my case it was corrupted/damaged partition table, which is the reason the Operating system stopped detecting the External hard disk partition properly. To make it easier in working with TestDisk command line utility, following are the steps to recover the data, hope this helps you guys:

Testdisk https://www.cgsecurity.org/wiki/TestDisk


  • In order to recover a damaged partition table, kindly follow the following steps: 



  1. Start testdisk_win.exe
  2. Create a new log file.
  3. Scroll down to drive which contains the damaged partition table > Proceed
  4. Intel/EFI GPT (Select the partition table type - usually the default value is the correct one as TestDisk auto-detects the partition table type.) > Analyse > Quick Search
  5. Should TestDisk search for partition created under Vista ? > Y
  6. If the lost partition was a primary partition, move arrows to change * to P and press Enter.[P may already be there, if it is, still go to the next step to 'Write partition table'.]
  7. Move arrows to Write and press Enter.
  8. Write partition table, confirm ? (Y/N) > Y
  9. You will have to reboot for the change to take effect.


  • To recover individual files / individual directories from a hard drive which cannot display them in Windows because of a damaged partition table: 



  1. Copy Testdisk to hard drive with enough space to recover the lost files/directories then start testdisk_win.exe
  2. Create a new log file
  3. Scroll down to drive which contains the files/directories to recover > Proceed
  4. Intel/EFI GPT (Select the partition table type - usually the default value is the correct one as TestDisk auto-detects the partition table type.) > Analyse > Quick Search
  5. Should TestDisk search for partition created under Vista ? > Y
  6. Instead of moving arrows to get to the letter P, physically press key P on your keyboard.This lists the files and directories 
  7. Now use arrows to move down to select any file or directory and press C on keyboard to copy selected file or directory. 
or
To copy all files and directories, move the arrow to the top marked with one dot: .Then press C on keyboard and all files and directories will be copied to the location where you ran TestDisk from.


  • Use instructions above to recover files/directories from a hard drive with a damaged partition table. If partitions already exist, it may be recovered to an image file. To create an image of the entire partition:



  1. Copy Testdisk to hard drive with enough space to store the image of the partition 
  2. Create a new folder inside which you want to save the image.dd file then start testdisk_win.exe
  3. Create a new log file
  4. Scroll down to drive which contains the partition to copy > Proceed
  5. Intel/EFI GPT (Select the partition table type - usually the default value is the correct one as TestDisk auto-detects the partition table type.) > Advanced > Scroll down to partition to recover 
  6. Use right arrow to get to Image Creation > Enter 
  7. Select where to store the image.dd file > Press Enter then press the Y key on keyboard.
  8. File image.dd will contain the recovered partition.

You can use freeware such as OSFMount to mount image.dd files to access files inside them directly.

MySQL and PostgreSQL identical commands

Both MySQL and PostgreSQL are databases which are used. There are many similar commands and functionalities used in both with some differences. Users working with both are always confused with the equivalent commands that are used in both SQL’s. The following is a cheat sheet which will help users:
MySQL (mysql)
Postgres (psql)
Extra Notes
\e 
\e 
Edit the buffer with external editor. Postgres also allows \e filename which will become the new buffer
\g 
\g 
Send current query to the server
\h 
\h
Gives help — general or specific
\n
\pset pager off
Turns the pager off. For PGSQL, the pager is only used when needed based on number of rows; to force it on, use \pset pager always
\d string 
No equivalent
Changes the delimiter
\c
\r 
Clears the buffer
\p 
\p 
Print the current buffer
\q or Quit or exit or [ctrl-c]
\q
Quit the client mysql> or psql>
\r [dbname] [dbhost]
\c [dbname] [dbuser]
Reconnect to server
\s 
No equivalent
Status of server. Some of the same info is available from the pg_settings table
\u dbname or  Use [db_name]
\c dbname
Connect to a database or use a different database.
\w
No equivalent
Do not show warnings. Postgres always shows warnings by default
\C charset Change the charset
\encoding encoding Change the encoding
Run \encoding with no argument to view the current one
\t Stop teeing output to file
No equivalent
However, \o (without any argument) will stop writing to a previously opened outfile
\G 
\x
Display results vertically (one column per line). Note that \G is a one-time effect, while \x is a toggle from one mode to another. To get the exact same effect as \G in Postgres, use \x\g\x
\R string
\set PROMPT1 string
To Change the prompt. Note that the Postgres prompt cannot be reset by omitting an argument. A good prompt to use is:\set PROMPT1 '%n@%`hostname`:%>%R%#%x%x%x '
\P pagername
Environment variable PAGER or PSQL_PAGER
Change the current pager program
\. filename 
\i filename
Include a file as if it were typed in.
\T filename
No direct equivalent
Sets the tee output file. Postgres can output to a pipe, so you can do: \o | tee filename
\W 
No equivalent
To Show warnings. Postgres always show warnings by default
\?
\?
Help for Internal Commands.
\# 
No equivalent
To rebuild tab-completion hash. Not needed in Postgres, as tab-completion in Postgres is always done dynamically
\! command 
\! command 
To execute a shell command. If no command is given with Postgres, the user is dropped to a new shell (exit to return to psql)
Timing is always on
\timing Toggles timing on and off

No equivalent
\t Toggles “tuple only” mode
This shows the data from select queries, with no headers or footers
show tables; List all tables
\dt or /dt+
Many also use just \d, which lists tables, views, and sequences
desc tablename; 
\d tablename
Display information about the given table.
show index from tablename; 
\d tablename
Display indexes on the given table. The bottom of the \d tablename output always shows indexes, as well as triggers, rules, and constraints
show triggers from tablename; 
\d tablename
Display triggers on the given table. The bottom of the \d tablename output always shows indexes, as well as triggers, rules, and constraints
show databases; 
\l 
List all databases
No equivalent
\dn
To List all schemas. MySQL does not have the concept of schemas, but uses databases as a similar concept
select version(); 
select version(); 
Show backend server version
select now(); 
select now(); 
Show current time. Postgres will give fractional seconds in the output
select current_user;
select current_user;
Show the current user.
select database(); 
select current_database();
Show the current database.
show create table tablename; 
No equivalent
Output a CREATE TABLE statement for the given table. The closest you can get with Postgres is to use
pg_dump --schema-only -t tablename
show engines; 
No equivalent
To List all server engines. Postgres does not use separate engines
CREATE object ... Create an object: database, table, etc.
CREATE object ... Mostly the same
Most CREATE commands are similar or identical. Lookup specific help on commands (for example: \h CREATE TABLE)
SHOW INDEX FROM some_table;
Show indices of some_table (in case of MySQL)
\di
Show all indices of database (PostgreSQL)
Display Indices.
mysqldump
pg_dumpall
pg_dumpall is designed to dump all the databases and invokes pg_dump to do it. It can also be used to dump global values like roles and tablespaces.
Example with mysql:
mysqldump –all-databases > /path/to/file.sql
Example with postgres:
pg_dumpall > /path/to/file.sql
mysqldump
pg_dump
pg_dump is used for dumping individual databases.
Example with mysql:
mysqldump mydatabase > /path/to/file.sql
Example with postgres:
pg_dump mydatabase > /path/to/file.sql
innodb_top
pg_top
innodb_top does not ship with mysql and is a third-party executable. It shows you things like inserts per second, updates per second, transactions per second and gives a good overview as to what is going on with the server pg_top shows similar things but is laid out more similarly to the native linux “top” program.
mysql
psql
These commands allow to access the CLI utility.
Passing query with mysql (-e for execute):
mysql -e “select * from table_name;”
Passing query with postgres (-c for command):
psql -c “select * from table_name;”
Passing sql into the utility.
show databases;
\l or \list
This lists the databases on the server instance you are connected to or that you have access to.
select * from mysql.user;
select * from pg_user; or\du
Shows all users and their global permissions. Postgres lists the permissions as a comma separated string under a filed called attributes. Mysql shows a boolean value for each of the possible permissions.
show full processlist;
select * from pg_stat_activity;
This will show all the queries that are currently running and how long they have been running for.
show variables;
show all;
This will show all the current values for the variables. Postgres even offers a brief description of what each variable is.
show engine innodb status\G
SELECT * FROM pg_stat_activity;
SELECT * FROM pg_stat_database;
SELECT * FROM pg_stat_user_tables;
SELECT * FROM pg_stat_user_indexes;
SELECT * FROM pg_locks;
There is no central place in postgres to get all the information obtained by running show engine innodb status in mysql. There are several queries you can run to get roughly equivalent data though.
show slave status\G
select * from pg_stat_replication;
select now() – pg_last_xact_replay_timestamp() AS replication_delay;
Shows replication information. On idle write masters you can errantly see replication report as behind or lagging. This is showing you the current timestamp minus the timestamp of the last item applied on the slave. If the master hasn’t written anything, the slave has not applied anything and can show you that it is behind. It is recommended to use a written timestamp from cron every minute to gauge replication. This achieves 2 things, it will guarantee regular writes to the master which will replicate to the slave, and monitoring can look to the timestamp in a location to know if the server is behind.
stop slave;
start slave;
select pg_xlog_replay_pause();
select pg_xlog_replay_resume();
Pause/resume/stop/start replication on the slave node
SHOW FULL TABLES IN database_name WHERE TABLE_TYPE LIKE 'VIEW';
\dv
\dv schema_name.*
List views
SHOW [EXTENDED] [FULL] {COLUMNS | FIELDS}
    {FROM | IN} tbl_name
    [{FROM | IN} db_name]
    [LIKE 'pattern' | WHERE expr]
\dt+
\dv+
\d+ table_name
Get extended information (add + to any command)
In MySQL, The optional EXTENDED keyword causes the output to include information about hidden columns that MySQL uses internally and are not accessible by users.The optional FULL keyword causes the output to include the column collation and comments, as well as the privileges you have for each column.

Feel free to add in a comment if some commands are not listed. I have not listed the other queries like SELECT, ALTER, DELETE and etc as most of the syntax are similar just follow the documentations mentioned in Postgresql and Mysql websites

MIUI 10 Second batch Stable upgrade Rolling Out


It is a good news for MIUI users with 4 year old Models as Xiaomi MIUI updates will be available for them according to the reports.

The MIUI 10 update is now available for 39 smartphones including the 4-year old Xiaomi Mi 4 handset. The MIUI 10 is the enhanced version of the MIUI 9 that brings support for gestures and full experience, AI enhancements for photography, improved UI and more. This upgrade adds a new natural sound system, starting with a variety of notification sounds, helping healthy millet white noise and anthropomorphic dynamic wake-up bells to create a new sound experience.

May 31: Xiaomi Officially released the MIUI 10 system.
June 9: Xiaomi officially launched the development version of the batch upgrade.
September 10 : Xiaomi officially launched the MIUI10 stable version upgrade.

The MIUI 10 upgrade is being provided by Xiaomi in batches.
  1. First batch: In September this batch received the MIUI 10 upgrade and the phones supported were as following:
    • Mi series
Mi 8, Mi 8 Explorer Edition, Mi 8 SE, Mi 8 Lite, Mi MIX 2S, Mi MIX 2, Mi MIX, Mi Max 3, Mi 6, Mi 6X, Mi Note 2 and Mi 5.
    • Redmi and Redmi Note series
Xiaomi Redmi 6 Pro, Redmi 6 and Redmi 6A, Redmi S2, Redmi 5, and Redmi Note 5.
  1. Second Batch: The second batch which is being released this month includes the following phones, which are expected to receive the MIUI 10 upgrade:
    • Mi Series:
Mi 4, Mi 4C, Mi 4S, Mi 5s, Mi 5s Plus, Mi Max, Mi Max Prime, Mi Max 2
    • Redmi and Redmi Note Series:
Redmi 4, Redmi 4 Prime, Redmi 4A, Redmi 4X, Redmi 5A, Redmi 5 Plus, Redmi Pro, Redmi Note 3, Redmi Note 4, Redmi Note 4X, Redmi Note 4X MediaTek variant, Redmi Note 4X Qualcomm variant, Redmi Note 5A, Redmi Note 5A Prime

According to Chinese media the second batch phones would start receiving the Stable Rom yesterday onwards. It looks like the update may only be available in China for the time being. For the global phones we need to wait a bit more longer.

Note: Please use this for information purpose only. While the Information is considered to be true and correct at the date of publication, changes in circumstances after the time of publication may impact on the accuracy of the Information. Linwintech.blogspot.com is not in any way liable for the accuracy of any information here and printed and stored or in any way interpreted and used by a user.
The Information contained in this site includes information derived from various third parties just for the sake of sharing information.