guestfish 修改 image file
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的更多相关文章
- 10g ASM下修改control file的位置
1.查看位置以及name是否正确 SQL> sho parameter name NAME TYPE VALUE ------------------------------------ --- ...
- 【linux】linux修改open file 大小
使用下面命令可以查看openfile数量 ulimit -a linux修改open file 大小,修改步骤如下: 1>修改file-max 修改文件: vi /etc/sysctl.conf ...
- guestfish修改镜像内容
1.安装guestfish yum install libguestfs-tools 注意,如果要修改windows镜像需要安装 yum install libguestfs-winsupport 2 ...
- 修改input file 文件上传的样式
Web页面中,在需要上传文件时基本都会用到<input type="file">元素,它的默认样式: chrome下: IE下: 不管是上面哪种,样式都比较简单,和很多 ...
- Bootstrap修改input file默认样式
html部分 <div class="form-group"> <label class="col-sm-3 control-label"&g ...
- 修改input:file样式
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 使用Java中File类批量创建文件和批量修改文件名
批量创建文件 int cont = 1; String s = "E:\\学习资料\\Java笔记-"; while(cont<100){ File f = new File ...
- KVM镜像管理利器-guestfish使用详解
原文 http://xiaoli110.blog.51cto.com/1724/1568307 KVM镜像管理利器-guestfish使用详解 本文介绍以下内容: 1. 虚拟机镜像挂载及w2k8 ...
- DB1:数据库的创建和文件的修改
在SQL Server中,使用Create Database创建数据库,使用Alter Database命令,能够修改数据库的数据文件和日志文件. 一,创建数据库 1,在创建数据库时,最佳实践是: 创 ...
随机推荐
- ViewPager 详解(二)---详解四大函数
前言:上篇中我们讲解了如何快速实现了一个滑动页面,但问题在于,PageAdapter必须要重写的四个函数,它们都各有什么意义,在上节的函数内部为什么要这么实现,下面我们就结合Android的API说明 ...
- how to get file from classpath using jboss7.x.1 --reference
question: I want to convert smooks xml-java, so that i need to load source file from mobeeadmin.war/ ...
- Java基础知识强化31:String类之String的面试题
1.先看一个图: 2.String面试题: (1)题1: package cn.itcast_02; /* * 看程序写结果 */ public class StringDemo3 { public ...
- SQLServer 工具技巧
SQLServerProfiler 的使用 http://www.jikexueyuan.com/course/1712.html
- c#将Excel数据导入到数据库的实现代码(转载)
假如Excel中的数据如下: 数据库建表如下: 其中Id为自增字段: 代码如下: using System; using System.Collections.Generic ...
- Windows Native API
http://en.wikipedia.org/wiki/Native_API Windows 的原生 API 函数通常在系统启动时(这里其他 Windows 组件还不可用).kernel32.dll ...
- 《CSS网站布局实录》学习笔记(六)
第六章 CSS高级应用与技巧 6.1 id与class 6.1.1 什么是id id是XHTML元素的一个属性,用于标识对象名称.无论是class还是id,都是XHTML所支持的公共属性,并且也是其核 ...
- JAVA List与数组间相互转换
1.list转数组 例如: List<String> list = new ArrayList<String>(); list.add("aa"); li ...
- 保障MySQL安全的14个最佳方法
MySQL数据库一贯以高性能.高可性和易用性著称,它已经成为世界上最流行的开源数据库.大量的个人.WEB开发者.大型公司等都在其网站.关键系统.软件包中广泛使用MySQL数据库. 通常, ...
- 启发式算法、寻路算法A*算法
原文链接: http://blog.csdn.net/b2b160/article/details/4057781