Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1514270
  • 博文数量: 290
  • 博客积分: 3468
  • 博客等级: 中校
  • 技术积分: 3461
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-28 22:21
文章分类

全部博文(290)

文章存档

2016年(13)

2015年(3)

2014年(42)

2013年(67)

2012年(90)

2011年(75)

分类: LINUX

2011-05-25 10:43:09

系统环境:龙芯2F + debian5

archlinux-live-usb.img 是一个USB-LIVE 映像,由于U盘坏了,所以就想用硬盘安装
archlinux for loongson的网站:

# gunzip archlinux-live-usb.img.gz
# file arch-live-usb.img

arch-live-usb.img: x86 boot sector; partition 1: ID=0x83, starthead 32, startsector 2048, 591872 sectors, extended partition table (last)\011, code offset 0x0

从文件类型(file 查看的)的信息可以看出这个.img 文件不是一个分割区影像,而是一个整个磁盘,这意味着他们开始的有引导程序和分区表,所以必须找出该分区的偏移并挂载从偏移的地方开始挂载

# fdisk -lu arch-live-usb.img

You must set cylinders.
You can do this from the extra functions menu.
Disk arch-live-usb.img: 0 MB, 0 bytes
248 heads, 19 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xff978785

            Device Boot      Start         End      Blocks   Id  System
arch-live-usb.img1            2048      593919      295936   83  Linux
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(0, 32, 33) logical=(0, 107, 16)
Partition 1 has different physical/logical endings:
     phys=(36, 247, 19) logical=(126, 10, 18)

通过上面的信息我们知道了块大小(512b)和启动分区的块(2048),所以我们的偏移量为(2048*512)

# mount -t auto -o loop,offset=$((2048*512)) arch-live-usb.img /mnt/

由于不知道数据为何种类型的格式(上面显示的是 ID=83 System:linux) 所以用 -t auto 这个参数,

或者:
# losetup -fo 1048576 arch-live-usb.img  // 这里的 -fo 104857=(2048*512)
是指定第一个分区在整个磁盘镜像文件中的偏移量
# losetup -a  // 得到 loop 设备文件路径,如 /dev/loop0
# mount /dev/loop0 /mnt

或者:
$ losetup /dev/loop0 arch-live-usb.img
$ sudo kpartx -av /dev/loop
0
add map loop0p1 (252:0): 0 591872 linear /dev/loop0 2048
$ sudo mount /dev/mapper/loop0p1 /mnt

如果第一步提示 loop0 忙的话,尝试用 loop1 等等,第二步如果提示没有 kpartx 就安装一个

挂载好了,现在就是把里面的数据复制到一个 800M 左右的空分区(ext3 格式)了

# mkfs.ext3 /dev/sda3
# mount /dev/sda3 /media
# cp /mnt/* -a /media
# vim /media/boot.cfg
把 kernel 后的参数改成相应的硬盘分区即可(我这里是/dev/sda3)

                                                                                                     2011-05-25

阅读(2376) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~