Example guestfish session
Sometimes, you must modify a virtual machine image to remove any traces of the MAC address
that was assigned to the virtual network interface card when the image was first created,
because the MAC address will be different when it boots the next time. This example
shows how to use guestfish to remove references to the old MAC address by deleting the /
etc/udev/rules.d/70-persistent-net.rules file and removing the HWADDR line
from the /etc/sysconfig/network-scripts/ifcfg-eth0 file.
Assume that you have a CentOS qcow2 image called centos63_desktop.img. Mount
the image in read-write mode as root, as follows:
# guestfish --rw -a centos63_desktop.img
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
VM Image Guide July 12, 2015 current
18
><fs>
This starts a guestfish session. Note that the guestfish prompt looks like a fish: > <fs>.
We must first use the run command at the guestfish prompt before we can do anything
else. This will launch a virtual machine, which will be used to perform all of the file manipulations.
><fs> run
We can now view the file systems in the image using the list-filesystems command:
><fs> list-filesystems
/dev/vda1: ext4
/dev/vg_centosbase/lv_root: ext4
/dev/vg_centosbase/lv_swap: swap
We need to mount the logical volume that contains the root partition:
><fs> mount /dev/vg_centosbase/lv_root /
Next, we want to delete a file. We can use the rm guestfish command, which works the
same way it does in a traditional shell.
><fs> rm /etc/udev/rules.d/70-persistent-net.rules
We want to edit the ifcfg-eth0 file to remove the HWADDR line. The edit command will
copy the file to the host, invoke your editor, and then copy the file back.
><fs> edit /etc/sysconfig/network-scripts/ifcfg-eth0
If you want to modify this image to load the 8021q kernel at boot time, you must create an
executable script in the /etc/sysconfig/modules/ directory. You can use the touch
guestfish command to create an empty file, the edit command to edit it, and the chmod
command to make it executable.
><fs> touch /etc/sysconfig/modules/8021q.modules
><fs> edit /etc/sysconfig/modules/8021q.modules
We add the following line to the file and save it:
modprobe 8021q
Then we set to executable:
><fs> chmod 0755 /etc/sysconfig/modules/8021q.modules
We're done, so we can exit using the exit command:
><fs> exit

guestfish 修改 image file的更多相关文章

  1. 10g ASM下修改control file的位置

    1.查看位置以及name是否正确 SQL> sho parameter name NAME TYPE VALUE ------------------------------------ --- ...

  2. 【linux】linux修改open file 大小

    使用下面命令可以查看openfile数量 ulimit -a linux修改open file 大小,修改步骤如下: 1>修改file-max 修改文件: vi /etc/sysctl.conf ...

  3. guestfish修改镜像内容

    1.安装guestfish yum install libguestfs-tools 注意,如果要修改windows镜像需要安装 yum install libguestfs-winsupport 2 ...

  4. 修改input file 文件上传的样式

    Web页面中,在需要上传文件时基本都会用到<input type="file">元素,它的默认样式: chrome下: IE下: 不管是上面哪种,样式都比较简单,和很多 ...

  5. Bootstrap修改input file默认样式

    html部分 <div class="form-group"> <label class="col-sm-3 control-label"&g ...

  6. 修改input:file样式

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  7. 使用Java中File类批量创建文件和批量修改文件名

    批量创建文件 int cont = 1; String s = "E:\\学习资料\\Java笔记-"; while(cont<100){ File f = new File ...

  8. KVM镜像管理利器-guestfish使用详解

    原文  http://xiaoli110.blog.51cto.com/1724/1568307   KVM镜像管理利器-guestfish使用详解 本文介绍以下内容: 1. 虚拟机镜像挂载及w2k8 ...

  9. DB1:数据库的创建和文件的修改

    在SQL Server中,使用Create Database创建数据库,使用Alter Database命令,能够修改数据库的数据文件和日志文件. 一,创建数据库 1,在创建数据库时,最佳实践是: 创 ...

随机推荐

  1. rk3288 ov8858 camera移植

    平台:瑞芯的rk3288 SDK:4.4/5.0/5.1 作者:fulinux *****本文同意转载.只是请注明出处:http://blog.csdn.net/fulinus**** rk3288的 ...

  2. 5 Java学习之 泛型

    1. 基本概念          泛型是Java SE 1.5的新特性,泛型的本质是 参数化类型 ,也就是说所操作的 数据类型 被指定为一个参数.这种参数类型可以用在类.接口和方法的创建中,分别称为 ...

  3. jdbc连接数据库和jdbc-odbc桥接方式连接数据库

    //这种方式为jdbc直接连接,需要添加jar文件 1 package com.howe2; import java.sql.*; public class test2 { public static ...

  4. JNI 详细使用步骤 上手示例

    1.定义本地native方法 定义本地方法,通常情况下,应单独定义一个类来封装所有native方法 /** 存放native方法的类 */ public class MyNativeMethods { ...

  5. java: cannot execute binary file

    转自:http://jxwpx.blog.51cto.com/15242/222572 java: cannot execute binary file 如果遇到这个错,一般是操作系统位数出问题了. ...

  6. DELL R410升级网卡驱动

    官方链接http://zh-cn.broadcom.com/support/ethernet_nic/netxtremeii.php(官方驱动的名字偶尔会改)   注意确保服务器的kernel-dev ...

  7. 如何打开Windows Server 2003 内存寻址扩展

    本文介绍了如何在系统内存大于4G的情况下,让windows2003 Advanced Server支持大内存的方法: 由于Windows2003 32bit是32位操作系统,当服务器配备内存高达4G时 ...

  8. 【转】C#注册快捷键

    转自:http://blog.csdn.net/xiahn1a/article/details/42561015 这里需要引用到“user32.dll”.对于Win32的API,调用起来还是需要dll ...

  9. Centos 中 vim 的配置

    工欲善其事,必先利其器,我们要用好 vim 就先来把它配置的顺手一点,这样可以大大提高我们的工作学习效率 1.跳转指令 Ctags1 从下面地址下载ctags,将其中的ctags.exe复制到vim目 ...

  10. hadoop实现共同出现的单词(Word co-occurrence)

    共同出现的单词(Word co-occurrence)是指在一个句子中相邻的两个单词.每一个相邻的单词就是一个Co-Occurrence对. Sample Input: a b cc, c d d c ...