码迷,mamicode.com
首页 > 其他好文 > 详细

guestfish xfs

时间:2020-05-08 18:08:52      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:oop   pac   mamicode   err   sshd   not   grant   tar   access   

[root@localhost  ]# qemu-img convert  -f  qcow2 -O raw CentOS-8-8.1.1911.x86_64.qcow2 CentOS-8-8.1.1911.x86_64.raw
[root@localhost  ]# losetup /dev/loop12 CentOS-8-8.1.1911.x86_64.raw
[root@localhost  ]# kpartx -av /dev/loop12
add map loop12p1 (253:39): 0 16384000 linear /dev/loop12 2048
[root@localhost  ]# mount /dev/mapper/loop121 /mnt/uloop1
mount: special device /dev/mapper/loop121 does not exist
[root@localhost  ]# ls /dev/mapper/loop12*
/dev/mapper/loop12p1
[root@localhost  ]# mount  /dev/mapper/loop12p1  /mnt/uloop1
mount: wrong fs type, bad option, bad superblock on /dev/mapper/loop12p1,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
[root@localhost  ]# mount  /dev/mapper/loop12p1  /mnt/uloop1
mount: wrong fs type, bad option, bad superblock on /dev/mapper/loop12p1,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
[root@localhost  ]# dmesg | tail
[24217206.273962] audit: type=2407 audit(1588926575.500:363800): pid=12402 uid=0 auid=0 ses=40840 msg=op=start direction=from-client cipher=aes256-ctr ksize=256 mac=hmac-sha2-256 pfs=curve25519-sha256@libssh.org spid=12402 suid=0 rport=61949 laddr=10.10.16.81 lport=22  exe="/usr/sbin/sshd" hostname=? addr=192.168.117.59 terminal=? res=success
[24217206.784392] audit: type=2404 audit(1588926576.020:363801): pid=12402 uid=0 auid=0 ses=40840 msg=op=destroy kind=session fp=? direction=from-client spid=12402 suid=0 rport=61949 laddr=10.10.16.81 lport=22  exe="/usr/sbin/sshd" hostname=? addr=192.168.117.59 terminal=? res=success
[24217207.425489] audit: type=2404 audit(1588926576.660:363802): pid=12402 uid=0 auid=0 ses=40840 msg=op=destroy kind=session fp=? direction=from-server spid=12402 suid=0 rport=61949 laddr=10.10.16.81 lport=22  exe="/usr/sbin/sshd" hostname=? addr=192.168.117.59 terminal=? res=success
[24217231.959668] audit: type=1101 audit(1588926601.190:363803): pid=22452 uid=0 auid=4294967295 ses=4294967295 msg=op=PAM:accounting grantors=pam_access,pam_unix,pam_localuser acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success
[24217231.959806] audit: type=1103 audit(1588926601.190:363804): pid=22452 uid=0 auid=4294967295 ses=4294967295 msg=op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success
[24217231.959880] audit: type=1006 audit(1588926601.190:363805): pid=22452 uid=0 old-auid=4294967295 auid=0 tty=(none) old-ses=4294967295 ses=40848 res=1
[24217231.965559] audit: type=1105 audit(1588926601.200:363806): pid=22452 uid=0 auid=0 ses=40848 msg=op=PAM:session_open grantors=pam_loginuid,pam_keyinit,pam_limits,pam_systemd acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success
[24217231.966111] audit: type=1110 audit(1588926601.200:363807): pid=22452 uid=0 auid=0 ses=40848 msg=op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success
[24217231.994365] audit: type=1104 audit(1588926601.230:363808): pid=22452 uid=0 auid=0 ses=40848 msg=op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success
[24217231.995503] audit: type=1106 audit(1588926601.230:363809): pid=22452 uid=0 auid=0 ses=40848 msg=op=PAM:session_close grantors=pam_loginuid,pam_keyinit,pam_limits,pam_systemd acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success
[root@localhost ]#  guestfish --rw -a  CentOS-8-8.1.1911.x86_64.raw

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: ‘help’ for help on commands
      ‘man’ to read the manual
      ‘quit’ to quit the shell

><fs>list-filesystems
libguestfs: error: list_filesystems: call launch before using this function
(in guestfish, dont forget to use the run command)
><fs> run
$<2>? 75% ???????????????????????????????????????????????????????????????????????????═════════════════════════? 00$<2> 100% ????????????????????????????????????????????????????????????????????????????????????????????????????? 00:00
><fs> list-filesystems
/dev/sda1: xfs
><fs> 

 

><fs> list-filesystems
/dev/sda1: xfs
><fs> ls /
libguestfs: error: ls0: ls0_stub: you must call mount first to mount the root filesystem
><fs> mount /dev/sda1 /
><fs> ls /
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var
><fs> ls /etc/passwd
libguestfs: error: ls0: opendir: /etc/passwd: Not a directory
><fs> cat  /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
unbound:x:997:995:Unbound DNS resolver:/etc/unbound:/sbin/nologin
sssd:x:996:993:User for sssd:/:/sbin/nologin
setroubleshoot:x:995:992::/var/lib/setroubleshoot:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
cockpit-ws:x:994:991:User for cockpit-ws:/nonexisting:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:993:990::/var/lib/chrony:/sbin/nologin

 

[root@localhost  ]#  guestfish --rw -a  CentOS-8-8.1.1911.x86_64.raw   -i edit  /etc/passwd
sh: vi: command not found
vi /tmp/libguestfsTtqOOB: Success
 

 

><fs> vi /etc/passwd
sh: vi: command not found
vi /tmp/libguestfsqO29eG: Success
><fs> vim /etc/passwd
vim: unknown command
><fs> edit /etc/passwd
sh: vi: command not found
vi /tmp/libguestfsGvsWu8: Success
><fs> quit

guestfish --rw -a  CentOS-8-8.1.1911.x86_64.raw  -i sh  "sed -i ‘s/root:x:/root::/g‘  /etc/passwd"

https://docs.openstack.org/image-guide/modify-images.html

 

[root@localhost  ]# guestmount -a   CentOS-8-8.1.1911.x86_64.raw  -m /dev/sda1  --rw /mnt/uloop3
[root@localhost  ]# cd /mnt/uloop3/
[root@localhost uloop3]# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@localhost uloop3]# cd -
/data2/cloudimages/ neo
[root@localhost  ]# umount /mnt/uloop3
[root@localhost  ]# 

 

技术图片

 

 技术图片

 

guestfish xfs

标签:oop   pac   mamicode   err   sshd   not   grant   tar   access   

原文地址:https://www.cnblogs.com/dream397/p/12851822.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!