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

时间: 2024-08-14 09:48:45

guestfish 修改 image file的相关文章

Openstack Queen版本之guestfish修改centos7云镜像解决ssh无法连接VM实例

原因 用VirtualBox 以及Queen版本搭建 openstack, 创建了实例,用ssh怎么搞都不能够免密登陆进入创建的虚拟机,虽然可以ping通,所以打算尝试一下直接修改镜像ssh密码. 1.安装guestfish apt-get install libguestfs-tools -y 2.打开镜像(前面一篇博客有提到下载和转换) guestfish --rw -a CentOS-7-x86_64-GenericCloud-1907.qcow2 3.执行修改 ><fs> run

guestfish修改镜像内容

1.安装guestfish yum install libguestfs-tools 注意,如果要修改windows镜像需要安装 yum install libguestfs-winsupport 2.修改配置文件:/etc/libvirt/qemu.conf user = "root" # The group for QEMU processes run by the system instance. It can be # specified in a similar way to

修改Database File

使用Alter Database 能够Add,Modify,Remove 数据库的Data File 和Log File. ALTER DATABASE database_name { <add_or_modify_files> } [;] <add_or_modify_files>::= { ADD FILE <filespec> [ ,...n ] [ TO FILEGROUP { filegroup_name } ] | ADD LOG FILE <file

如何修改input file样式

<input type="text" size="20" name="upfile" id="upfile" style="border: 1px dotted #ccc"> <input type="button" value="浏览" onclick="path.click()" style="border: 1px

linux修改open file参数

1.文件中添加如下:/etc/sysctl.conf fs.file-max = 202400 #file-max是内核可分配的最大文件数fs.nr_open = 102400 #nr_open是单个进程可分配的最大文件数 sysctl -p 立即生效 2.文件中添加如下:/etc/security/limits.conf soft nofile 102400 hard nofile 102400 ulimit -n 1024000 立即生效 注:具体值请根据系统性能决定 原文地址:https:

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

本文介绍以下内容: 1. 虚拟机镜像挂载及w2k8虚拟机启动自检慢问题解决办法 2. KVM虚拟化与guestfish套件 3. guestfish安装与注意事项 4. 使用guestfish查看虚拟机信息 5. 使用guestfish查看虚拟机分区及文件系统 6. 去掉磁盘空洞--KVM虚拟镜像的稀疏问题 7. 用guestfish操作虚拟机内部文件 8. guestfish修改镜像格式和大小 9. guestfish挂载.修改.运行救援方式 1. 虚拟机镜像挂载及w2k8虚拟机启动自检慢问题

Java-文件File简单实用

1.1java.io.File File用于表示文件系统中的一个文件或目录 通过File可以: 1:访问该文件或目录的属性信息(名字,大小,修改时间等) file.getName();获取文件名 file.length();获取文件长度 file.lastModified();获取文件最后一次修改时间 file.canWrite();是否可写 file.canRead();是否可读 file.isHidden();是否隐藏 2:操作文件或目录(创建,删除) 使用File创建一个新文件 File

CKeditor七牛云JS SDK前端上传插件修改

七牛云官方有放出JS SDK,没有我想使用的CKeditor前端上传插件,所以结合七牛官方的Javascript SDK对CKeditor做了一些修改使它能够直接上传到七牛云,又同时保留了上传到本地服务的接口. 优点和缺点1.在前端上传到七牛云,不消耗服务器带宽和流量.空间.2.保留了CKeditor上传到自己服务器的能力.3.支持拖拽和剪切板黏贴图片上传(因为是保存为png格式,建议只黏贴色彩单调的图片,要不然图片会很大,浪费流量).4.拖拽和剪切板黏贴图片.不支持4M以上的文件,因为没有分块

数据库的创建和文件的修改

在SQL Server中,使用Create Database创建数据库,使用Alter Database命令,能够修改数据库的数据文件和日志文件. 一,创建数据库 1,在创建数据库时,最佳实践是: 创建一个或多个文件组,并设置默认文件组 每个文件组中的数据文件和CPU的内核数据相同,将文件均匀分布在不同的物理硬盘上,使IO均匀分布在不同的物理磁盘上: 数据文件的初始大小,文件增长和最大大小保持一致,这样,能够使每个文件的IO次数相对均匀: 日志文件分配在性能最好的物理硬盘上,写日志的性能直接影响