让我解释一下,更详细一些(尽管这个诡辩适用于更多情况):我有一个 512GB mSATA 磁盘的克隆映像,实际上,它实际上无法达到操作系统使用的 10GB(其余的是作为可用空间)。另一方面,我想将此映像复制到 256GB 磁盘,也是 mSATA。
有没有办法指示 dd 仅复制磁盘上有内容的部分?
我用来克隆和复制的命令是:
dd bs=512K if=/dev/sdx | gzip -c > /image.img.gz
zcat /image.img.gz | cp --sparse=always /dev/stdin mini.img
我已经安装并进行了修改mini.img
,然后:
dd bs=512K if=mini.img of=/dev/sdy
如果我在类似大小的磁盘上做,当然没有问题。但是,如果我在底部磁盘上执行此操作,它不会抛出错误,而是终止。
但是当我尝试启动操作系统时,遇到了这个问题:
[...]
Begin: Running /scripts/iniy-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... Volume group "ubuntu-vg" not found
Cannot process volume group ubuntu-vg
done.
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: error opening /dev/md?*: No such file or directory
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
done.
Gave up waiting for root file system device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enought?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/mapper/ubuntu--vg-ubuntu--lv does not exist. Dropping to a shell!
BusyBox v1.30.1 (Ubuntu 1:1.30.1-7ubuntu3) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs)
如果感兴趣的话,在本地磁盘挂载时,因为它是带有LVM2的Ubuntu,所以我做了以下命令:
kpartx -a -v mini.img
vgscan
vgchange -ay
lvdisplay
mount /dev/ubuntu-vg/ubuntu-lv /mnt/ubuntu