1

I'm trying to create disk image files all the drives of a remote linux machine that hosts our share drive using dd. When I run df -h --total it shows several partitions. I've got a couple questions:

  1. Are the blue files below additional partitions?
  2. What does the [file] -> [file] syntax mean?
  3. Is it possible to create a single disk image for all the partitions using dd? If so, how?

enter image description here

Here are the details about the dm-[] files:

enter image description here

Context: I'm trying to convert this CentOS machine to a hyper-v vm. I've successfully converted a single partition linux machine by converting the .img file created with the dd command to a .vmdk (using VBoxManage.exe) then to a .vhd (using VBoxManage.exe again). It booted up in Hyper-V no problem. Any insight on how to P2V linux machines to Hyper-V would also be appreciated.

0

1 Answer 1

0

I am currently using this for a 3 partition linux sd card image. I guess you can translate it to your own situation:

export VERSION=3.4.113
export ARMBIAN_BUILD=~/Armbian/build-$VERSION

dd if=/dev/zero of=sd.img bs=1M count=256

# Do the bootloader thing. Put the file from position 8192 bytes into the image
echo Copying bootloader
sudo dd if=ext/u-boot.bin of=sd.img bs=1k seek=8 conv=notrunc

(
echo n
echo p
echo 1
echo
echo +50M
echo n
echo p
echo 2
echo
echo +150M
echo n
echo p
echo
echo
echo
echo t
echo 1
echo b
echo t
echo 3
echo b
echo a
echo 1
echo w
) | fdisk sd.img > /dev/null

sleep 1

export start0=`echo p | sudo fdisk sd.img | grep sd.img1 | awk ' { print $3 } '`
export end0=`echo p | sudo fdisk sd.img | grep sd.img1 | awk ' { print $4 } '`
export start1=`echo p | sudo fdisk sd.img | grep sd.img2 | awk ' { print $2 } '`
export end1=`echo p | sudo fdisk sd.img | grep sd.img2 | awk ' { print $3 } '`
export start2=`echo p | sudo fdisk sd.img | grep sd.img3 | awk ' { print $2 } '`
export end2=`echo p | sudo fdisk sd.img | grep sd.img3 | awk ' { print $3 } '`

mkdir -p mnt
mkdir -p mnt/boot
mkdir -p mnt/rootfs
mkdir -p mnt/media

echo Creating boot partition from $start0 to $end0
export sectors0=`expr $end0 - $start0`
export size0=`expr $sectors0 \* 512`
export offset0=`expr $start0 \* 512`
sudo losetup -d /dev/loop0 > /dev/null 2>&1
sudo losetup /dev/loop0 sd.img -o $offset0 --sizelimit $size0
sudo mkfs.vfat /dev/loop0
sudo mount /dev/loop0 mnt/boot

echo Creating rootfs partition from $start0 to $end0
export sectors1=`expr $end1 - $start1`
export size1=`expr $sectors1 \* 512`
export offset1=`expr $start1 \* 512`
sudo losetup -d /dev/loop1 > /dev/null 2>&1
sudo losetup /dev/loop1 sd.img -o $offset1 --sizelimit $size1
sudo mkfs.ext2 /dev/loop1
sudo mount /dev/loop1 mnt/rootfs

echo Creating media partition from $start0 to $end0
sudo losetup -d /dev/loop2 > /dev/null 2>&1
export sectors2=`expr $end2 - $start2`
export size2=`expr $sectors2 \* 512`
export offset2=`expr $start2 \* 512`
sudo losetup /dev/loop2 sd.img -o $offset2 --sizelimit $size2
sudo mkfs.vfat /dev/loop2
sudo mount /dev/loop2 mnt/media

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.