如何将数据从块大小为 512 的磁盘传输到块大小为 4096 的更大磁盘

如何将数据从块大小为 512 的磁盘传输到块大小为 4096 的更大磁盘

尝试将 1.9 TB 的数据从原始磁盘复制到更大的 2.6 TB 磁盘,然后在某个时候,由于目标磁盘空间不足,事务停止。对此进行了研究,发现这与源 (512) 和目标 (4096) 磁盘的块大小差异有关。然后我寻找解决方案来创建块大小为 512 的磁盘,但没有成功。有人能指出去哪里寻找吗?

任何帮助都将不胜感激!

更新

(我之前遗漏了一些细节,可能会有帮助)

有一个名为 data.dd 的文件,我使用循环安装将其安装。

root@server:# fdisk -l data.dd
Disk data.dd: 1.8 TiB, 2000398934016 bytes, 3907029168 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
Disklabel type: dos
Disk identifier: 0x00000000

Device                 Boot Start        End    Sectors  Size Id Type
data.dd1          1 3907024064 3907024064  1.8T fd Linux raid autodetect

root@server:# losetup /dev/loop1 data.dd -o $((1 * 512))
root@server:# lsblk
NAME                           MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop1                            7:1    0   1.8T  0 loop
└─shark-storage                252:25   0   1.7T  0 lvm

root@server:# mount /dev/shark/storage /storage/mnt/

root@server:# df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/shark-storage      1.7T  1.5T  193G  89% /storage/mnt

最后,我使用 cp 或 rsync 将其数据复制到另一个磁盘。它们都没有完成。

答案1

好的,现在可以正常工作了。我没有从磁盘映像复制内容,而是直接将其克隆到目标位置。也许一开始就应该这样做。

这可能不是确切的答案,但值得分享。

这是我所做的:

  1. 创建了一个磁盘(假设它的名字是虚拟数据库) 以确保有足够的空间。
  2. 使用 dd 成功恢复图像
root@server:~# dd if=./data.dd of=/dev/vdb bs=4096 conv=notrunc,noerror

root@server:~# lsblk
vdb                 253:16   0   2.6T  0 disk
└─vdb1              253:17   0   1.8T  0 part
  1. 骑上去后发现是突袭队成员
root@server:~# mdadm --assemble --run /dev/md127 /dev/vdb1
mdadm: /dev/vdb1 is busy - skipping
root@server:~# mdadm --assemble --run --force /dev/md127 /dev/vdb1
mdadm: /dev/vdb1 is busy - skipping
root@server:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md127 : inactive vdb1[0](S)
      1953511936 blocks

unused devices: <none>
root@server:~# mount /dev/md127 /mydata/
mount: /dev/md127: can't read superblock
root@server:~# mdadm --examine /dev/vdb1
/dev/vdb1:
          Magic : a92b4efc
        Version : 0.90.00
           UUID : 0a0f4cab:13da9f8f:32773d18:de90fe8d (local to host server)
  Creation Time : Mon Jun 20 14:38:59 2011
     Raid Level : raid1
  Used Dev Size : 1953511936 (1863.01 GiB 2000.40 GB)
     Array Size : 1953511936 (1863.01 GiB 2000.40 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 4

    Update Time : Tue May 31 06:45:38 2016
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
       Checksum : f2035ced - correct
         Events : 1354346


      Number   Major   Minor   RaidDevice State
this     0       8       17        0      active sync

   0     0       8       17        0      active sync
   1     1       8       49        1      active sync

root@server:~# mdadm -A -R /dev/md127 /dev/vdb1
mdadm: /dev/vdb1 is busy - skipping

root@server:~# mdadm -S /dev/md127
mdadm: stopped /dev/md127

root@server:~# mdadm -A -R /dev/md127 /dev/vdb1
mdadm: /dev/md127 has been started with 1 drive (out of 2).

root@server:~# mount /dev/md127 /mydata/
mount: unknown filesystem type 'LVM2_member'

root@server:~# fdisk -l /dev/md127
Disk /dev/md127: 1.8 TiB, 2000396222464 bytes, 3907023872 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

root@server:~# lvmdiskscan
  /dev/vgname/lvname  [       1.66 TiB]
  /dev/md127          [       1.82 TiB] LVM physical volume

root@server:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vgname/lvname
  LV Name                lvname
  VG Name                vgname
  LV UUID                W4abfE-wnuM-Q2Z1-item-mdo9-daHx-K10yQB
  LV Write Access        read/write
  LV Creation host, time ,
  LV Status              available
  # open                 0
  LV Size                1.66 TiB
  Current LE             435456
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:2

root@server:~# vgdisplay
  --- Volume group ---
  VG Name               vgname
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.82 TiB
  PE Size               4.00 MiB
  Total PE              476931
  Alloc PE / Size       435456 / 1.66 TiB
  Free  PE / Size       41475 / 162.01 GiB
  VG UUID               tNqlCk-SSzi-1eFO-ZPyX-fAee-3cIi-Tdu2gR

root@server:~# lsblk
NAME                MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
vdb                 253:16   0   2.6T  0 disk
└─vdb1              253:17   0   1.8T  0 part
  └─md127             9:127  0   1.8T  0 raid1
    └─vgname-lvname 252:2    0   1.7T  0 lvm

root@server:~# mount /dev/vgname/lvname /mydata/
root@server:~# lsblk
NAME                MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
vdb                 253:16   0   2.6T  0 disk
└─vdb1              253:17   0   1.8T  0 part
  └─md127             9:127  0   1.8T  0 raid1
    └─vgname-lvname 252:2    0   1.7T  0 lvm   /mydata

root@server:~# cd /mydata/
root@server:/mydata# ll
... lots of files and folders ....

帮助我找到处理案件方法的资源:

相关内容