LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-19-2017, 06:59 PM   #1
venom_zx
Member
 
Registered: Sep 2003
Posts: 30

Rep: Reputation: 15
copied an NTFS partition to a new SSD with GParted, but md5sum doesn't match


hi guys,

i have a HDD with just 1 partition. an NTFS partition. i copied it to a new SSD using GParted.

i wanted to be sure that it was copied correctly so i ran:
sudo md5sum /dev/sda1
437f43e544484a5508416c6d0f23cae0 /dev/sda1
sudo md5sum /dev/sdc1
3e2fbfd84c4f5c2f6ca6ad692bf7482a /dev/sdc1


(where "/dev/sda1" new partition on the SSD in GParted "/dev/sdc1" is the original partition on the HDD)

the md5 hashes don't match. i checked twice, but the result was exactly the same 2 differing hashes. both partitions have their first sector at 2048.

- the data is supposed to be identical right?
- is there a way i can diff them and then patch the partition on the new SSD?
 
Old 08-19-2017, 07:35 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
gparted would have mkfs'd the new partition then copied the data. Which would have, at a minimum, defragmented files. The on-disk representation would no longer be the same, although the data should be.
Only way to be sure would be to hash each file individually I would reckon. If you had copied them yourself would you also do a hash check of the partitions ?. I never have.
 
Old 08-19-2017, 10:15 PM   #3
venom_zx
Member
 
Registered: Sep 2003
Posts: 30

Original Poster
Rep: Reputation: 15
oh. that makes sense. i didn't know it made an empty file system. i first tried it in virtualbox on the partition of a fresh installation of windows 7 where the hashes did match. i guess i will just do it for a select few files. i like to double check things.

thanks

Last edited by venom_zx; 08-19-2017 at 10:17 PM.
 
Old 08-19-2017, 11:03 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by syg00 View Post
gparted would have mkfs'd the new partition then copied the data.
No, it copies the entire filesystem structure, preserving all the metadata. Files in the copy will have the same inode numbers as in the source, and will be located in the same filesystem blocks. What gparted does not do is copy the free space, so unless the free space in the source has been zeroed and the destination partition has also been zeroed, the md5sums will not match.

Here's a sample mapping of a file in the source and destination filesystems. The two filesystems have different starting LBAs, but the offsets and fragmentation are identical.
Code:
root@sysresccd /root % hdparm --fibmap /mnt/tmp1/initramfs-2.6.32-696.1.1.el6.x86_64.img

/mnt/tmp1/initramfs-2.6.32-696.1.1.el6.x86_64.img:
 filesystem blocksize 4096, begins at LBA 2048; assuming 512 byte sectors.
 byte_offset  begin_LBA    end_LBA    sectors
           0     428032     444415      16384
     8388608     395264     411647      16384
    16777216     621112     632511      11400
root@sysresccd /root % hdparm --fibmap /mnt/tmp2/initramfs-2.6.32-696.1.1.el6.x86_64.img

/mnt/tmp2/initramfs-2.6.32-696.1.1.el6.x86_64.img:
 filesystem blocksize 4096, begins at LBA 1435648; assuming 512 byte sectors.
 byte_offset  begin_LBA    end_LBA    sectors
           0    1861632    1878015      16384
     8388608    1828864    1845247      16384
    16777216    2054712    2066111      11400
 
1 members found this post helpful.
Old 08-19-2017, 11:21 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
How about that. The things you learn watching the footy.
Thanks.
 
Old 08-19-2017, 11:37 PM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
i just dd'd a complete micro sdcard (not a partition!) to my computer, and later back on the card again.
it worked.
i guess the checksums would match (due to hardware restrictions i can't check now).
 
Old 08-22-2017, 12:44 PM   #7
venom_zx
Member
 
Registered: Sep 2003
Posts: 30

Original Poster
Rep: Reputation: 15
thanks for the fast response guys. although i'm not familiar with those commands, thanks for clearing that up rknichols
 
Old 08-22-2017, 01:22 PM   #8
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,140

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
should upgrade to sha256 or something. md5 has been broken for awhile and has collisions.
 
Old 08-22-2017, 02:28 PM   #9
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Code:
$ dcfldd
is a variant of the dd command written by the US government, that automatically verifies the MDsum periodically and when finished.
 
  


Reply

Tags
gparted



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] md5sum doesn't match LINUX-3.16.2 is there any problem in future building LFS Carl_cj Linux From Scratch 6 09-13-2014 12:13 AM
Accidentally deleted NTFS partition with GParted theblang Linux - Software 17 08-07-2009 04:48 PM
Error trying to resize NTFS partition with Gparted mistere29 Linux - Newbie 6 06-14-2009 05:20 PM
redimension a ntfs partition using gparted htamayo Linux - Software 1 04-12-2007 10:55 AM
Gparted refuses to resize NTFS (3G) partition, even if it has been unmounted. PureRumble Linux - Software 9 04-02-2007 07:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration