今天学到这样一个命令,主要是从之前的loop设备那里看到的
其实这个命令主要来自于处理虚拟机的磁盘镜像,当你想更改一个磁盘镜像里面某些文件的时候,直接挂载会方便很多。比如我机器刚好有个windowsxp的虚拟机磁盘镜像
- [lizhuohua@lizhuohua-phy ~]$ sudo kpartx -av /var/lib/libvirt/images/winxp.img
- [sudo] password for lizhuohua:
- add map loop0p1 (253:3): 0 30700152 linear /dev/loop0 63
- [lizhuohua@lizhuohua-phy ~]$ cd /dev/mapper
- [lizhuohua@lizhuohua-phy mapper]$ ls
- control loop0p1 vg_lizhuohua-lv_home vg_lizhuohua-lv_root vg_lizhuohua-lv_swap
- [lizhuohua@lizhuohua-phy mapper]$ cd /mnt
- [lizhuohua@lizhuohua-phy mnt]$ sudo mkdir p
- [lizhuohua@lizhuohua-phy mnt]$ sudo mount /dev/mapper/loop0p1 /mnt/p
- The disk contains an unclean file system (0, 0).
- The file system wasn't safely closed on Windows. Fixing.
- [lizhuohua@lizhuohua-phy mnt]$ cd /mnt/p
- [lizhuohua@lizhuohua-phy p]$ ls
- 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
- [lizhuohua@lizhuohua-phy p]$ cd ~
- [lizhuohua@lizhuohua-phy ~]$ sudo umount /mnt/p
- [lizhuohua@lizhuohua-phy ~]$ sudo kpartx -d /var/lib/libvirt/images/winxp.img
- loop deleted : /dev/loop0
- [lizhuohua@lizhuohua-phy ~]$ cd /dev/mapper
- [lizhuohua@lizhuohua-phy mapper]$ ls
- control vg_lizhuohua-lv_home vg_lizhuohua-lv_root vg_lizhuohua-lv_swap
- [lizhuohua@lizhuohua-phy mapper]$
阅读(15193) | 评论(0) | 转发(0) |