Hi, Andy Smith wrote: > I've got a disk image that sits on top of an LVM logical volume > that is on top of an mdadm RAID-1 that is on top of a pair of: > Device Model: Samsung SSD 870 EVO 4TB > Sector Size: 512 bytes logical/physical > so let';s say that is at /dev/foo/disk_image (where /dev/foo is the > name of the LVM VG and disk_image is the LV) > So > # fdisk -ul /dev/foo/disk_image > Disk /dev/foo/disk_image: 400 GiB, 429496729600 bytes, 838860800 sectors > Units: sectors of 1 * 512 = 512 bytes
fdisk thinks that this device has a logical block size of 512. This information is not stored in MBR partition table (or in GPT) but rather it is a property of the storage device. > Disklabel type: dos > So it's a 400G disk image with an MBR and a single partition, right? Yes. (But nitpicking: It has an MBR partition table with entries other than the protective entry which would indicate the presence of GPT. I.e. GPT contains an MBR too, but its partition table entries are stored outside of the MBR.) > Now, I dd that disk image across the network to another machine > which has a similar setup, except here the "foo" volume group is on > a pair of > Device Model: HGST HUS726T6TALN6L4 > Sector Size: 4096 bytes logical/physical So the logical volume was probably created with the logical block size of the involved physical disk devices. > fdisk > thinks it is 8 times bigger than it really is, and thinks it has 4K > sectors. fdisk asks the device (unless it is a regular file, i guess) for its logical size. Since the partition table gives no hint about its own idea of the bytes/block ratio, you end up with vastely inflated byte numbers. I wonder, though, why fdisk would misrepresent the total disk size, which i would expect to come from the storage device. Maybe fdisk is more confused than i expect. Can you show the whole output of fdisk from the new logical device ? Whatever: Not only the partition table might get misinterpreted like the partition table. Depending on the filesystem and its Linux driver the same wrong address computations can happen inside the filesystem. (ISO 9660 has a field to announce the intended logical block size. But the Linux driver "iso9660" ignores it and assumes 2048 bytes/block. It is nice enough to convert the LBA values of the filesystem to 512 bytes per logical block addresses if needed. I guess it does the same for disk devices with 4096 bytes per logical block, but never tested this.) > Is there any way to make this work? > Device Boot Start End Sectors Size Id Type > /dev/foo_disk_image 2048 838858751 838856704 400G 83 Linux The start address and the number of sectors is integer divisible by 8. You could change the partition start and size so that the block numbers address the correct bytes with the 8 fold larger logical block size. But given that this could still create an unusual situation in the filesystem driver, i would try to create a device with a logical block size of 512. (... or i would create and mount a new filesystem on the new device and copy the files over from the mounted image file.) Have a nice day :) Thomas