星期一, 二月 15, 2010

在linux下挂载磁盘镜像指定分区

对于下载的u盘镜像(img格式)可以用下面的方式来挂载:
先用fdisk来查看一下该镜像的分区:
fdisk -l -u ./share/chromiumos-20091211-usb.img
然后会如下列表:
You must set cylinders.
You can do this from the extra functions menu.

Disk share/chromiumos-20091211-usb.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x00000000

                            Device Boot      Start         End      Blocks   Id                                                System
share/chromiumos-20091211-usb.img1               1       50000       25000   83                                                Linux
Partition 1 has different physical/logical endings:
     phys=(24, 26, 17) logical=(3, 28, 42)
Partition 1 does not end on cylinder boundary.
share/chromiumos-20091211-usb.img2           50001      100000       25000   82                                                Linux swap / Solaris
Partition 2 has different physical/logical beginnings (non-Linux?):
     phys=(24, 26, 18) logical=(3, 28, 43)
Partition 2 has different physical/logical endings:
     phys=(48, 53, 1) logical=(6, 57, 20)
Partition 2 does not end on cylinder boundary.
share/chromiumos-20091211-usb.img3   *      100001      960160      430080   83                                                Linux
Partition 3 has different physical/logical beginnings (non-Linux?):
     phys=(48, 53, 2) logical=(6, 57, 21)
Partition 3 has different physical/logical endings:
     phys=(468, 53, 1) logical=(59, 195, 41)
Partition 3 does not end on cylinder boundary.
 
上面的例子,是查看的chromiumos-20091211-usb.img,可以看到需要挂载的第三个分区起始位置为:100001,然后可以这样挂载该分区:
mount -o loop,offset=$((100001*512)) ./share/chromiumos-20091211-usb.img ./point
其中1000001*512是指起始扇区乘以字节数。
如此可以在windows下用colinux写入chromeos的文件到本地物理硬盘,然后由grub启动,方便很多,无需使用u盘。

--
http://yoyoliyang.blogspot.com

没有评论: