Upgrade a HDD running Windows 7, fix boot issues and resize NTFS

Written by - 0 comments

Published on - Listed in Hardware Windows Linux


After having already upgraded RAM and CPU of a Toshiba Satellite notebook, the final step was to upgrade the hard drive running Windows 7.
Besides a higher capacity than the original drive (250GB), the new drive should also be faster.

The original drive, a Toshiba MK2565GSXV, was running with 5400rpm. The replacement drive, a Seagate Momentus 7200.4 (9HV144-071), runs with 7200rpm. This should allow faster drive access and therefore speed up the OS.

Toshiba MK2565GSXV
Seagate Momentus 7200.4

Instead of just plugging the Seagate and install a new Windows 7 on it, I wanted to keep the current OS and all it's data. I decided to use my Linux server as "intermediate transfer server" by copying the data with dd.

For such purposes I bought a Sharkoon Quickport a while ago, which allows to plug IDE and ATA drives and serves as a USB bridge.

Sharkoon Quickport

Once connected to the Linux server, running Debian Wheezy, the Toshiba drive was detected as /dev/sdf:

[1393067.582761] scsi 11:0:0:0: Direct-Access     TOSHIBA  MK2565GSXV       GH01 PQ: 0 ANSI: 5
[1393067.585361] sd 11:0:0:0: Attached scsi generic sg6 type 0
[1393067.587194] sd 11:0:0:0: [sdf] 488397168 512-byte logical blocks: (250 GB/232 GiB)
[1393067.588118] sd 11:0:0:0: [sdf] Write Protect is off
[1393067.588130] sd 11:0:0:0: [sdf] Mode Sense: 23 00 00 00
[1393067.588944] sd 11:0:0:0: [sdf] No Caching mode page found
[1393067.593859] sd 11:0:0:0: [sdf] Assuming drive cache: write through
[1393067.603473] sd 11:0:0:0: [sdf] No Caching mode page found
[1393067.608377] sd 11:0:0:0: [sdf] Assuming drive cache: write through
[1393067.643997]  sdf: sdf1 sdf2
[1393067.647815] sd 11:0:0:0: [sdf] No Caching mode page found
[1393067.652651] sd 11:0:0:0: [sdf] Assuming drive cache: write through
[1393067.657481] sd 11:0:0:0: [sdf] Attached SCSI disk

A quick look with fdisk showed that there are two primary partitions on this drive:

fdisk -l /dev/sdf

Disk /dev/sdf: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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: 0xa8580373

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1   *        2048      821247      409600   27  Hidden NTFS WinRE
/dev/sdf2          821248   488392064   243785408+   7  HPFS/NTFS/exFAT

The first partition (sdf1) kind of surprised me - I was not aware that there was a hidden NTFS partition.
The second partition (sdf2) is of course the Windows installation with a single "Drive C:".

With dd both partitions are saved into a local file:

time dd if=/dev/sdf1 of=/srv/data/sdf1.dd
819200+0 records in
819200+0 records out
419430400 bytes (419 MB) copied, 14.6298 s, 28.7 MB/s

real    0m14.641s
user    0m0.436s
sys     0m5.912s

This was pretty quick - but the first partition is small...
The sdf2 partition however took more than 3 hours to be saved into a single file:

time dd if=/dev/sdf2 of=/srv/data/sdf2.dd
487570817+0 records in
487570817+0 records out
249636258304 bytes (250 GB) copied, 10871.4 s, 23.0 MB/s

real    181m11.517s
user    4m3.647s
sys     70m7.119s

The sizes of the files represent the sizes of the partitions:

root@nas:~# du -ksh /srv/data/sdf*
401M    /srv/data/sdf1.dd
233G    /srv/data/sdf2.dd

Now the Seagate was placed into the Sharkoon Quickport:

[1392189.351799] scsi 10:0:0:0: Direct-Access     ST950042 0AS              0003 PQ: 0 ANSI: 5
[1392189.354044] sd 10:0:0:0: Attached scsi generic sg6 type 0
[1392189.354981] sd 10:0:0:0: [sdf] 976773168 512-byte logical blocks: (500 GB/465 GiB)
[1392189.355852] sd 10:0:0:0: [sdf] Write Protect is off
[1392189.355863] sd 10:0:0:0: [sdf] Mode Sense: 23 00 00 00
[1392189.356986] sd 10:0:0:0: [sdf] No Caching mode page found
[1392189.362089] sd 10:0:0:0: [sdf] Assuming drive cache: write through
[1392189.371133] sd 10:0:0:0: [sdf] No Caching mode page found
[1392189.376169] sd 10:0:0:0: [sdf] Assuming drive cache: write through
[1392189.405668]  sdf: sdf1
[1392189.409504] sd 10:0:0:0: [sdf] No Caching mode page found
[1392189.414485] sd 10:0:0:0: [sdf] Assuming drive cache: write through
[1392189.420509] sd 10:0:0:0: [sdf] Attached SCSI disk

Before copying the data from the local files to the drive, the partitions must be created.
The first primary partition is created with the exact same sector size (from 2048 to 821247). The second primary partition, which will contain the OS and data, should use the rest of the drive's capacity.

fdisk /dev/sdf

Command (m for help): p

Disk /dev/sdf: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x3004c662

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-976773167, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-976773167, default 976773167): 821247

Then the partition is labeled with the same ID as the original drive:

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 27
Changed system type of partition 1 to 27 (Hidden NTFS WinRE)

Command (m for help): p

Disk /dev/sdf: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x3004c662

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048      821247      409600   27  Hidden NTFS WinRE

The same now for the second primary partition. Create partition with the rest of the capacity and label it:

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 2):
Using default value 2
First sector (821248-976773167, default 821248):
Using default value 821248
Last sector, +sectors or +size{K,M,G} (821248-976773167, default 976773167):
Using default value 976773167

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 7
Changed system type of partition 2 to 7 (HPFS/NTFS/exFAT)

Command (m for help): p

Disk /dev/sdf: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x3004c662

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048      821247      409600   27  Hidden NTFS WinRE
/dev/sdf2          821248   976773167   487975960    7  HPFS/NTFS/exFAT

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now that we have the same partition setup as the original drive (except the bigger partition for the OS and data), the dd command can be launched "in the other direction" . Meaning that now the input comes from the local files, the output is the partition:

time dd if=/srv/data/sdf1.dd of=/dev/sdf1
819200+0 records in
819200+0 records out
419430400 bytes (419 MB) copied, 101.098 s, 4.1 MB/s

real    1m41.101s
user    0m0.840s
sys     0m15.817s

time dd if=/srv/data/sdf2.dd of=/dev/sdf2
487570817+0 records in
487570817+0 records out
249636258304 bytes (250 GB) copied, 70965 s, 3.5 MB/s

real    1182m45.065s
user    8m9.971s
sys     158m23.770s

No, you don't see double numbers. Yes. You have seen it correctly. After an eternity of 1182 minutes (more than 19 hours), the dd finally completed. During the dd process I have seen a lot of Kernel log entries indicating a hardware error on the CPU. This might have been the cause for such a slow copy, otherwise it may also be the Sharkoon Quickport which allows to read fast but write slowly to drives (Note: The hardware/cpu errors mentioned were solved in a later article: Hardware Error: Parity error during data load. Or: Clean me!!!).

Anyhow, now that the dd is completed, let's boot it up. But... FAIL! The notebook didn't boot and went into PXE boot mode...
If you paid close attention to the fdisk commands above, you might have seen what I forgot. Any idea? Correct! I forgot to set the boot flag on the first primary partition. Drive out of the notebook again, back into Sharkoon, back to fdisk on Linux:

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sdf: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x3004c662

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1   *        2048      821247      409600   27  Hidden NTFS WinRE
/dev/sdf2          821248   976773167   487975960    7  HPFS/NTFS/exFAT

Command (m for help): w
The partition table has been altered!

Placed the HDD back into the laptop and booted. The change of the bootable partition seemed to work, because the laptop finally booted from the disk.
However Windows did not start, instead the following message was shown on the screen:


            Windows Boot Manager
Windows failed to start. A recent hardware or software change might be the cause. To fix the problem:

1. Insert your Windows installation disc and restart your computer.
2. Choose your language settings and then click Next.
3. Click "Repair your computer"

If you do not have this disc, contact your system administrator or computer manufacturer for assistance.

Status: 0xc000000e

Info: The boot selection failed because a required device is inaccessible.

Crap! Why? So yes, there was a "hardware change" but why would that fail to boot (on Linux it JUST WORKS)?
So I gave it a go and inserted the Windows 7 disc and clicked on "Repair your computer":

Windows 7 repair your computer

Once started, the "System Recovery Options" indeed found issues. By clicking on "view details" the more relevant information comes up:

Windows System Recovery Options
Windows Repair Details (changed UUID)

With the detailed error message it makes sense that the boot didn't work. The UUID (Unique Identifier of the HDD) was hardcoded in the bootmgr. Because this identifier cannot be found anymore (the drive was exchanged), the boot now fails.
Side note: I have seen similar boot issues also on some Linux installations where the UUID of the drive was used instead of a common name like /dev/sda.
After "Repair and restart", the identifier was updated in the bootmgr and Windows finally booted.

Once Windows started up, the new drive was detected and new drivers were automatically installed - followed by a message box to restart Windows:

Windows 7 new SATA Disk Device

I thought that's it, but when I was back in Windows, the C: drive was still the same size as before:

Windows C: still old drive space

Luckily I've known that "issue" from my early VMware days 10 years ago. Back then I also tried to increase the C: partitions of Windows 2003 Server VM's. Whenever I did that, it was not enough to just enlarge the partition, the filesystem must also be grown.
The same as I did 10 years ago, I booted up Knoppix and launched "ntfsresize" on the partition:

ntfsresize /dev/sda2

Knoppix ntfsresize

After the reboot, the Windows chkdsk started to do integrity checks of the drive (because the NTFS size changed):

Windows 7 chkdsk

This took a couple of minutes but then finally Windows booted and the new full size was detected:

Windows C: new drive size

Happy ending!


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Observability   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder