您的位置:首页 > 运维架构 > Linux

使用linux访问hd.img文件

2010-05-08 10:57 736 查看
#!/bin/bash

#Key Words:linux0.11 bochs harddisk bash

#mount hdimg name:hdimage-devel

#mount point:/mnt/initrd

hdimg=hdimage-devel

mpoint=/mnt/initrd

if [ "$1" == "mount" ]

then

#mount hdimg

echo "$1 START"

sudo losetup /dev/loop1 "$hdimg" && /

sudo fdisk /dev/loop1 && /

sudo losetup -d /dev/loop1 && /

#Command (m for help): x

#Expert command (m for help): p

#Disk /dev/loop1: 16 heads, 38 sectors, 410 cylinders

#Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID

# 1 00 0 3 0 15 38 203 2 124030 81

# 2 00 0 1 204 15 38 407 124032 124032 81

# 3 00 0 0 0 0 0 0 0 0 00

# 4 00 0 0 0 0 0 0 0 0 00

#2*512

sudo losetup -o 1024 /dev/loop1

$hdimg

&& /

sudo mount -t minix /dev/loop1 "$mpoint"

echo "$1 END"

elif [ "$1" == "umount" ]

then

#umount hdimg

echo "$1 START"

sudo umount /dev/loop1 && /

sudo losetup -d /dev/loop1

echo "$1 END"

else

echo "Usage ./hd.sh [mount|umount]"

fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: