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,在创建数据库时,最佳实践是: 创 ...
随机推荐
- UITableView显示不全
先上图(不全图片): 正确图片: 原因例如以下: 1.在tableView的父视图的freme问题. 2.tableView本身的frame问题.大小依据自己的实际情况改过来就OK了 希望能够帮助到你 ...
- Java基础知识强化25:Java创建对象的四种方式
1. Java程序中对象的创建有四种方式: ● 调用new语句创建对象,最常见的一种 ● 运用反射手段创建对象,调用java.lang.Class 或者 java.lang.reflect.Const ...
- jquery跳出当前的each循环
break----用return false; continue --用return ture; jquery是对象链,所以$(..).each()返回的还是对象集合.each(function(){ ...
- CSS 命名规则
CSS书写顺序: 位置属性(position, top, right, z-index,display, float等) 大小(width, height, padding, margin) 文字系列 ...
- [ERROR] Unknown/unsupported storage engine: InnoDB
将CentOS上的mysql升级以后,出现无法启动服务的问题.运行mysqld_safe后查看log信息,看到标题所示的错误.搜索以后发现是配置不对,难道两个版本的配置不能互相兼容?那还叫升级?坑爹啊 ...
- 关于cocopads 不能正确安装的问题
通过几个网页 我搜到 看着几个网页就够了 绝对可以实现的 http://code4app.com/article/cocoapods-install-usage http://www.cnblogs. ...
- 自定义异常throw
简单自定义一个年龄小于等于0,或者大于120会出现的异常 首先继承父类Exception,调用父类的构造器,这样才可以报出自己想要的异常 public class AgeException exten ...
- tribonacci
Everybody knows Fibonacci numbers, now we are talking about the Tribonacci numbers: T[0] = T[1] = T[ ...
- 2016最新一元云购完整源码 云购CMS系统 带安卓和ios手机客户端 源码免费分享
原文转自:http://www.zccode.com/thread-724-1-1.html 该资源说明: 看起来不错的一套一元云购CMS源码,源码包里面带了安卓和ios手机客户端,手机客户端需要自己 ...
- WebSQL实例记录
<table id="content"> </table> <br> <input type="button" id= ...