Can i mount a disk image created with dd , ddrescue , or dd_rescue on Windows ?

The lowdown: Yes you can, try the free OSFMount.

How i found out about it ? a friend sent me his laptop to un-dlete files for him, i didn’t have time to see how i can un-delete under windows, so (with his permission) i mounted his laptop hard drive on my computer (Linux), then DDd the whole drive to a 250GB image file, put the hard drive back where it was (in the laptop), and sent it back to him so that he can continue using it, once i found the time, i simply copied the image to a Windows computer, mounted it with OSFMount, then un-deleted everything with Recuva (the best un-delete software in my opinion), put his files on an external hard drive and sent it his way.

Images created with dd , ddrescue , or dd_rescue are not formatted, they are the direct copy of a whole disk, including boot records, partition tables, and file system, so mounting such images should not be hard at all, and indeed, turns out there is a program that can mount them under windows (i would not be surprised if it turns out there are hundreds that do that), but for now, this seems to be a champ, and it seems to be free.

Yet, this program seems to be more than a mounting tool for direct disk images, it also mounts CD images (i guess the one i currently use (virtual clone drive) is obsolete, creation of RAM disks, and can open a big bunch of other image formats (nrg, SDI, AFF, AFM, AFD, VMDK, E01, S01).

So there you are, all you need for your disk mounting needs in 1 program 😀

Cheers

DD_RESCUE ( GDDRESCUE’s ddrescue ) for disks with Advanced Format ( AF ) 4KiB sectors 4096 byte

1- Before using dd, ddrescue, or dd_rescue, you need to know which disk is which, you can do that by simply using the command “fdisk -l” in my case, the old disk turned out to be /dev/sdb and the new un-partitioned disk is /dev/sdc.

So, i have been cloning a 2TB hard drive ( WD20EARS ) to a WD20EARX, same disk, but with a few differences

WD20EARS is sata 2 and the other is sata 3, another difference is that using “hdparm -I /dev/sdb” the older WD20EARS reports (And should not be true)

WD20EARS

Logical/Physical Sector size:           512 bytes

wile with “hdparm -I /dev/sdc” the newer WD20EARX reports

        Logical  Sector size:                   512 bytes
        Physical Sector size:                  4096 bytes
        Logical Sector-0 offset:                  0 bytes

The first clone did not work for a reason unknown to me, i cloned my NTFS disk with ddrescue (gddrescue) on a linux (because i don’t know how to clone on windows) and then plugged it into windows, where it simply did not work, and in disk management reported the disk as un-partitioned space, so now i want to do the thing again, but i don’t want that slow performance, so i increased block size to 4KiB. (UPDATE: THE NEW COPY WITH 4KiB DID WORK BUT I DONT KNOW IF THE 4KiB SIZE IS RELEVANT, MAYBE YOU SHOULD TAKE A LOOK AT THE SECOND DIFFERENCE BETWEEN THE DISKS UP AT THE BEGINNING OF THE POST)

For now, i will try the cloning with the command (Only change the block level for advanced format hard drives)

Note, block size no longer works, and it is called sector-size, but the short letter for it -b is still the same, so we will change this to the line below it
ddrescue --block-size=4KiB /dev/sdb /dev/sdc rescue2.log
ddrescue -b=4KiB /dev/sdb /dev/sdc rescue2.log

And if all of your data is important, you can ask ddrescue to retry every bad block 3 times (or as many times as you wish) with the -r command

ddrescue --block-size=4KiB -r3 /dev/sdb /dev/sdc rescue2.log
ddrescue -b=4KiB -r3 /dev/sdb /dev/sdc rescue2.log

And what do you know, the disk now works on my WINDOWS machine 😀 no errors and no nothing, great, so now to some details about the copy

The result up to now is that i am reading at a maximum of 129MB while the average (in the first 60 GBs is 93018 kB/s), if this continues, i will be done in less than 6 hours.

The part that does not make any sense to me is that western digital states clearly in the specs that the maximum (Host to/from drive (sustained)) is 110 MB/s for both drives, it must be that i need to wait a bit more and see what that actually means.

rescued:         0 B,  errsize:       0 B,  errors:       0
Current status
rescued:    74787 MB,  errsize:       0 B,  current rate:     119 MB/s
   ipos:    74787 MB,   errors:       0,    average rate:   93018 kB/s
   opos:    74787 MB,     time from last successful read:       0 s
Copying non-tried blocks...

Now, once done, you can have the OS reload the partition table without having to restart, you can simply use the command partprobe

partprobe
or
partprobe /dev/sdc

To use partprobe, you need to install parted

apt-get install parted

If it were a linux drive, an advanced format drive would not have it’s first sector on sector 63 but rather on sector 2048, which is at exactly 2KiB, it could (but usually does not) start at any other value divisible by 8.

Windows probably does something similar for our AF Disk, so asking parted about our ntfs disk, this is what parted says

Model: ATA WDC WD20EARS-00M (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  2000GB  2000GB  primary  ntfs

1049kB is 1074176 bytes, Which when divided by 8 is 134272 (divisible by 8).

NOTES:
-There is a tool specifically for cloning ntfs volumes called ntfsclone, i am not sure what extra features it provides that are specific to ntfs, i have never used it before, with my disk that has bad blocks, i can only rely on gddrescue.
-A block is 512 on regular drives, and 4096 on newer ones, if you want to backup the hard drive’s geometry, you can do one of the following
Backup the first 63 blocks (MBR + Bootloader). on a “non advanced format” drive

dd if=/dev/sda of=/mnt/storage/sda.vbr bs=512 count=63

On an advanced format drive, we can try

dd if=/dev/sda of=/mnt/storage/sda.vbr bs=4096 count=63

Which, will make us read 258048 bytes rather than the traditional 32256 bytes (around 250K rather than 32K)

Undeleting files from windows partitions

So, i will be doing this under linux for a good reason

My friend gave me his computer so that i can recover everything for him, he deleted all the photos and so many other things, photos of his family are most important to him.

So, becuase i have been holding his computer hostage for a week now, i decided to copy the entier hard drive so i can give him his computer back, and extract everything at my convinience, so after mountingf the disk i want to undelete from… i executed the command.

ddrescue /dev/sdb /hds/3tb/200gb.img /root/resumelog.log

So i had the image file that i can use for recovery after mounting

Now if as in the article here http://www.buildingcubes.com/2012/07/27/rescuing-a-failed-hard-drive/ i mounted the drive, i can use a nice linux command (ntfsundelete) to undelete the files from the mounted partition.

1- create a list of files to take a look at, put all deleted JPGs in a text file
ntfsundelete /hds/img -m ‘*.jpg’ -p 80 -t 8m > deletedmp3.txt
ntfsundelete /dev/loop0 -m ‘*.zip’ -p 50 -t 8m > deletedjpg.txt

2- change to the directory where you want to recover files to
cd /hds/wd1tb/newdir

3- recover all PNG files then all jpg files
ntfsundelete /dev/sda1 –u –m *.png
ntfsundelete /dev/sda1 –u –m *.jpg

or if i want to move them to a directory other than the active directory
ntfsundelete /dev/sda1 -u -m ‘*.jpg’ -p 90 -t 8m -d /hds/wd1tb/newdir

-p 90 means only recover files with at least 90% recoverable content
-t 5m means only files deleted in the past 8 months

Seriously retarded P698 gets an update, the LG optimus net duos

Before i tell you that there has been a software update for this phone, let me remind you of my review of the phone

The lowdown: right after the update, i tested the P698 dual sim android, and i can say that the phone which was a disaster before the update is perfectly usable now, i would still prefer the samsung galaxy Y duos (GT-S6102)

I have only used this phone as a 3G modem up to now, when i tried to use it as a phone, it was a disaster, the phone battery does not last for a day, and this is nothing compared to the very faulty software, ending a phone call is very hard to do (you need to wait 10 seconds before you can be sure the other party can no longer hear you) that is, if this magical phone does not get into stupid mode and make ending the phone call mission impossible, in short, the phone is a disaster.

Worth mentioning is that the phone hardware is pretty OK, in some regards better than the Samsung Y duos, it is the software that is a disaster, the only thing that i consider essential and is missing from the hardware is the proximity sensor (the one that disables the touch screen when the phone is close to your face). CORRECTION: THE LG P698 does have a proximity sensor, and with the new update it works just fine.

So, today i decided to check whether the phone got a new software update, and indeed it has (the second), this update is named (and dated) v10g-jul-06-2012, where the update right before this one was v10f-mar-07-2012, so what did LG do in those 3 months, any news of fixing the bugs that were killing me ?

I will now install both my lines into this phone (from my very usable and useful Samsung Y duos), i will try the phone for a couple of days and let everyone know of the results, i am not optimistic

I will be back in a couple of days to tell you all if the phone is better now.

The update:
The new update improves the software so that this phone is now usable compared to a phone i bought and could not use, the samsung galaxy Y duos is still better than this phone (and has the swype application that is very nice), so i am still favoring the Samsung Galaxy Y duos, but the LG P698 is not so bad now, it works as a phone just fine

Windows dissapeared from Grub boot menu with debian

There seems to be a certain bug with Debian, when installing it on the same hard drive with Windows, on the next boot, windows is not one of the options, so what you can do is this

update-grub

You will see results such as

update-grub
Generating grub.cfg ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-2.6.32-5-686
Found initrd image: /boot/initrd.img-2.6.32-5-686
Found Windows 7 (loader) on /dev/sda1
done

Grub should now find you missing windows and add it to the boot menu !

I wrote this for my own reference, because every time i install i spend so much time trying to find the magic words online again

Relaying mail with PHP

Relaying mail with PHP

Sending mail through a mail server that requires authentication (A username and password).

This article is when you do NOT want to use your server’s MTA with PHP, and you want to send through an MTA that requieres authentication (A remote mail server)

When sending email from your own MTA with sendmail, PHP can use the mail() function to send such mail by smply passing the mail function some arguments, Even when the MTA is on a different computer that allows you to send mail (By validating your IP), changes can be made to PHP.INI to make the mail function work as needed.

But when you want to automate sending emails from something like a GMAIL account or a Godaddy Mail Server, things are different, You will need to connect to the SMTP server and ask it to relay your mail, for that the server will ask you for Authentication credentials, this tutorial will show you how to send email from a different email provider.

So, to begin with, you will need to download this script that i originally obtained from the open source GPL Coppermine Project, they in turn took the code from the GPL PHPMailer, a small change is required to make this file work.

Click here to download the mail slass scripts

What this script is about to do is exactly what your Outlook or Thunderbird do when you manually send a message from them, this is not a magic solution, the Gmail sending limits still apply, and all other big providers have limits even when you are a paying customer. mail providers need to protect there servers from being labled as spammers, some rules need to be in place.

Also, before you start, you should look carefully at the limits, not only is there a send limit, a large number of bounces will also lock your account in the case of Gmail and others.

In this tutorial we will use the functions in the PHPMailer class “http://phpmailer.sourceforge.net/”, it is free GPL software.

but rather than downloading it from PHPMailer’s website, we will take it from within the Coppermine Gallery Software, the file we need is include/mailer.inc.php

a few modifications need to be done, First seach for the string “connect to the smtp server” and add the following lines above it

$host = “ssl://smtp.gmail.com”;
$port = 465;

then search for “function ServerVar”, and right after the opening “function ServerVar {” and before “$superCage = Inspekt::makeSuperCage();” add

return ”;

Now, our mailer script should be ready !

Now, create a new PHP file (sendmymail.php), and within that paste the following code, Fix all names, credentials and email addresses.

require 'mailer.inc.php';
$mail = new cpg_PHPMailer();//this is the name of the class in coppermine
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "username@gmail.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$webmaster_email = "username@doamin.com"; //Reply to this email ID
$email="username@domain.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // If you want to add attachments !
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // If you want to add attachments
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body.
if(!$mail->Send())
{
	print "Mailer Error: " . $mail->ErrorInfo;
}
else
{
	print "Message has been sent";
}

?>

Adding SPF records

Adding SPF records

Note: Microsoft Sender ID is in many ways similar to SPF, and in most cases, SPF and SenderID are compaible, so by making an SPF record, you are also creating a Microsoft SenderID record, that sometimes causes trouble when the envelop sender is not the same as the From address !

Here, i will start by showing you a list of SPF records, and what they mean to mail servers, You can use those SPF records or compose your own, as the syntax is very simple really.

If you do not want to take chances, you can use the SPF generator at openspf.org

For example, the most common SPF record is

"v=spf1 a mx ~all"

–Explaining the line above, v=spf1 means that this is an SPF TXT record, it is common to all SPF records,
–followed by an a that means “any computers in the A record fields of the domain’s DNS are allwed to send email, or more simply put, to allow your web server (where you may run PHP scripts that send email for example) to send emails on the domain’s behalf
— Followed by an mx which means all servers mentioned in DNS as mail servers for this domain, are also allowed to send email on this domains behalf.
— ~all means that this loosly describes all servers that can send email on this domain’s behalf (softfail), while a -all would mean that this strictly describes all servers that send mail on our domain’s behalf (fail), and a ?all means that this describes some of the domains allowed to send email on our domain’s behalf, notice that ~ is not – from 1 and 2, ~ is loosly, – is strictly.

But for our examples sake, let us look at a longer, expanded SPF record and see what the extra fields mean

"v=spf1 a mx a:xxx.xxx.xxx.xxx mx:mailsrv2.example.net ip4:yyy.yyy.yyy.yyy/24 ip4:xxx.xxx.xxx.xxx include:mailsenders.com ~all"

In the example above, the section that reads mx:mailsrv2.example.NET is a mail server that is also allowed to send email on example.COM’s behalf

a:xxx.xxx.xxx.xxx where the masked charracters are an IP address means that the server or mail sender with the IP address mentioned can also send email, you can add as many such sections separated by a space as you wish to allow many computers to send mail on the domain name’s behalf

Google mail (gmail) sending limits

google mail has the following sending limits

GMAIL accounts…

google apps account limits

The links above come down to…

1- GMAIL accounts

500 Emails per day, 500 on the receiving end, or simply, 500 recipients of 500 messages

2- Google apps accounts

500 recipients.. 100 a time when using SMTP

But, what is not stated is that a large number of bounced messages, or email messages that look like spam will also get your account disabled, i found that out on a forum on the internet,

In general, you can send email with PHP through Gmail’s servers for notification and the like, but it is best if you triple check the data before it goes to your account !

Click here to see how to send email from PHP through your Google mail “Gmail” account.