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,在创建数据库时,最佳实践是: 创 ...
随机推荐
- Android 自定义View (四) 视频音量调控
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24529807 今天没事逛eoe,看见有人求助要做一个下面的效果,我看下面一哥们说 ...
- App发布AppStore【苹果开发者中心需要做的事】
请准许我的这句抱怨,也说明发布app到AppStore理清这些东西的重要性:起初打包出现各种 ApplicationVerificationFailed,不是这里没有搞对就是那个证书没有搞对,整个人签 ...
- git查看某个文件的修改历史
<转自 http://www.cnblogs.com/flyme/archive/2011/11/28/2265899.html> 有时候在比对代码时,看到某些改动,但不清楚这个改动的作者 ...
- 渲染器 Shader BitmapShader
渲染模式: tileX tileY:The tiling mode for x/y to draw the bitmap in. 在位图上 X/Y 方向 瓦工/花砖/瓷砖 模式 CLAMP :如 ...
- C#_DBHelper_SQL数据库操作类.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data; ...
- nyoj 37
//nyoj 37 代码有点乱,和最长公共子序列很像,只是多加了一个数组,之前调用函数, 一直超时,可是我看了下,为什么用一个整形数组存放倒置字符串 竟然可以AC,我测试了下数据,打印出来的是一串地 ...
- Entity Framework 的枚举类型
新增数据模型,新增“实体”之后,新增“枚举类型”,创建Enum值,将“实体”中的列和Enum关联,选中“实体”中的列属性改变类型为Enum名称,生成数据库…… 如下转自:http://item.con ...
- php学习之路
1.php拼接字符串+查询 $floor_id = M('house_floor_input')->where($map1)->field('id')->select(); $flo ...
- 动态脚本,在js里面又写js
不知道怎么回事 代码测试不过 var a=document.createElement("script"); a.type="text/javascript"; ...
- Oracle数据库之序列
Oracle数据库之序列(sequence) 序列是一个计数器,它并不会与特定的表关联.我们可以通过创建Oracle序列和触发器实现表的主键自增.序列的用途一般用来填充主键和计数. 一.创建序列 语法 ...