Chinaunix首页 | 论坛 | 博客
  • 博客访问: 753007
  • 博文数量: 130
  • 博客积分: 2951
  • 博客等级: 少校
  • 技术积分: 1875
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-04 18:32
文章分类

全部博文(130)

文章存档

2013年(1)

2012年(129)

分类: LINUX

2012-10-26 17:56:25

今天学到这样一个命令,主要是从之前的loop设备那里看到的
其实这个命令主要来自于处理虚拟机的磁盘镜像,当你想更改一个磁盘镜像里面某些文件的时候,直接挂载会方便很多。
比如我机器刚好有个windowsxp的虚拟机磁盘镜像

  1. [lizhuohua@lizhuohua-phy ~]$ sudo kpartx -av /var/lib/libvirt/images/winxp.img
  2. [sudo] password for lizhuohua:
  3. add map loop0p1 (253:3): 0 30700152 linear /dev/loop0 63
  4. [lizhuohua@lizhuohua-phy ~]$ cd /dev/mapper
  5. [lizhuohua@lizhuohua-phy mapper]$ ls
  6. control loop0p1 vg_lizhuohua-lv_home vg_lizhuohua-lv_root vg_lizhuohua-lv_swap
  7. [lizhuohua@lizhuohua-phy mapper]$ cd /mnt
  8. [lizhuohua@lizhuohua-phy mnt]$ sudo mkdir p
  9. [lizhuohua@lizhuohua-phy mnt]$ sudo mount /dev/mapper/loop0p1 /mnt/p
  10. The disk contains an unclean file system (0, 0).
  11. The file system wasn't safely closed on Windows. Fixing.
  12. [lizhuohua@lizhuohua-phy mnt]$ cd /mnt/p
  13. [lizhuohua@lizhuohua-phy p]$ ls
  14. AUTOEXEC.BAT boot.ini CONFIG.SYS Documents and Settings econfig epadm IO.SYS MSDOS.SYS NTDETECT.COM ntldr pagefile.sys Program Files System Volume Information WINDOWS
  15. [lizhuohua@lizhuohua-phy p]$ cd ~
  16. [lizhuohua@lizhuohua-phy ~]$ sudo umount /mnt/p
  17. [lizhuohua@lizhuohua-phy ~]$ sudo kpartx -d /var/lib/libvirt/images/winxp.img
  18. loop deleted : /dev/loop0
  19. [lizhuohua@lizhuohua-phy ~]$ cd /dev/mapper
  20. [lizhuohua@lizhuohua-phy mapper]$ ls
  21. control vg_lizhuohua-lv_home vg_lizhuohua-lv_root vg_lizhuohua-lv_swap
  22. [lizhuohua@lizhuohua-phy mapper]$


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