I have read that my partition table is stored in the MBR. And write operations are performed sector-wise i.e, even if you want to change just a few bytes of a sector you need to overwrite entire contents of the sector. So when installing GRUB on MBR, why doesn't it destroy my partition table?
GRUB – Why Doesn’t Installing GRUB on MBR Destroy the Partition Table
grubhard drivembr
Related Solutions
Have you tried resetting the BIOS ? If altering partition table of hard drives didn't work then the problem may not be with hard drives. BIOS contains initial instructions for the system, so this might indicate that the laptop failed to initialize in the first place. here is a link. You can skip to step 3 because getting into BIOS is not available.
Your USB drive presents itself to the host computer with a logical sector size of 4096 bytes, and that's what enables it to be partitioned with an MBR partition table that can use more than 2 TB of the drive's space, even in Windows XP. MBR partition table entries are 32 bits and Windows XP uses 32-bit math to calculate sector addresses from the partition table, allowing only the first 2^32 sectors of a drive to be used. 2^32 sectors x 4096 bytes/sector = 16 TB. With 512 bytes/sector, only the first 2 TB of a drive could be used by an MBR partition table. (2^32 sectors x 512 bytes/sector = 2 TB)
However, your drive is not 4k native. There are two layers of translation:
- The USB enclosure contains a USB-to-SATA bridge that translates from 4096 bytes per logical sector at the USB interface with the host computer to 512 bytes per logical sector at the SATA interface with the drive inside.
- The drive inside internally translates from 512 bytes per logical sector on its SATA interface to 4096 bytes per physical sector. (That's 512 byte/sector emulation or "512e".)
A SMART query passed though the USB bridge to the SATA drive inside reveals the truth (run here on my own Western Digital My Book 3 TB external USB drive in Windows XP):
C:\Program Files\GSmartControl> smartctl -a -d sat pd11
smartctl 6.5 2016-05-07 r4318 [i686-w64-mingw32-xp-sp3] (sf-6.5-1)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Western Digital Green
Device Model: WDC WD30EZRX-00MMMB0
Serial Number: WD-WCAWZ12xxxxx
LU WWN Device Id: 5 0014ee 2063xxxxx
Firmware Version: 80.00A80
User Capacity: 3,000,592,982,016 bytes [3.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
The internal SATA drive reports 512 bytes per logical sector and 4096 bytes per physical sector: that's 512 byte/sector emulation, or "512e".
However the drive as seen by the host computer connected by USB has a logical sector size of 4096 bytes:
C:\> wmic DISKDRIVE get bytespersector, caption
BytesPerSector Caption
4096 WD My Book 1140 USB Device
and that's how Windows XP is able to use all 3 TB of the drive's space.
If you need more proof than that, you could remove the drive from its enclosure and connect it directly to a motherboard's SATA connector: you'd then find that the drive has a logical sector size of 512 bytes, and the drive's partitions would all appear as 1/8 their previous size and be unreadable due to incorrect partition table entries caused by the sector size mismatch. Plenty of people have done this and then had to fix the problem by rewriting the partition table.
I've checked several different external USB drives and they are all 512e internally despite being configured for Windows XP compatibility with 4096 bytes per logical sector at the USB interface: WD My Book 3 TB, WD Elements 3 TB, HGST Touro 4 TB, WD Easystore 8 TB, WD Easystore 12 TB, WD Easystore 14 TB.
Your drive came with an MBR partition table (or someone changed it to MBR at some point) to make it compatible with Windows XP. Newer drives come with GPT partition tables, which require Windows Vista or later.
The WD Quick Formatter tool can be used to change a Western Digital external USB drive between 512 bytes/sector with a GPT partition table (for Vista and later) and 4096 bytes/sector with an MBR partition table (for Windows XP compatibility).
Best Answer
The software reads the original sector; updates it in memory; then writes out the updated sector.
On Linux, this is actually done by the OS itself, so GRUB doesn't need to worry about sectors – it can just issue a 440-byte write, and the OS will read/modify/write the whole 512-byte sector accordingly. (The job of an OS is to abstract away the inconvenient hardware details.) But if the OS didn't do this, then GRUB could still do the same read/modify/write thing on its own.
This "read/modify/write" pattern is not limited to just the MBR – it's also how you're able to change individual bytes within a file, even though they're also stored in disk sectors. The OS will read the corresponding sector from disk, update it with your changes, then write the new sector back.