momo zone

调核人的blog

挂载hdd镜像到目录

假如之前用dd把整块硬盘都做成了镜像文件,现在要把其中一个分区挂载该怎么做?

这里使用比较傻瓜的方法:

1. 将镜像映射到loop设备

losetup /dev/loop0 image.img

2. 将loop设备再分区映射到dm设备

kpartx -a /dev/loop0

将在/dev/mapper下产生对应分区的dm设备

3. 将这个分区dm挂载到指定目录

mount /dev/mapper/loop0p1 /mnt/

4. 使用完之后,先umount /mnt

5. 然后losetup -d /dev/mapper/loop0p1 取消映射

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: