Open t-iwano opened 9 years ago
grub install するときに対象のdiskが見つからない。
[root@ct68 dummy.1box]# kpartx -va 1box-dummy.netfilter.x86_64.raw
add map loop0p1 (253:0): 0 41940930 linear /dev/loop0 63
[root@ct68 dummy.1box]# mount /dev/mapper/loop0p1 /tmp/tmp1445414732
[root@ct68 dummy.1box]# mount --bind /proc /tmp/tmp1445414732/proc
[root@ct68 dummy.1box]# mount --bind /dev /tmp/tmp1445414732/dev
[root@ct68 dummy.1box]# mount --bind /sys /tmp/tmp1445414732/sys
[root@ct68 dummy.1box]# ls -la /tmp/tmp1445414732/tmp/vmbuilder-grub/device.map
-rw-r--r-- 1 root root 58 Oct 21 17:06 /tmp/tmp1445414732/tmp/vmbuilder-grub/device.map
[root@ct68 dummy.1box]# cat /tmp/tmp1445414732/tmp/vmbuilder-grub/device.map
(hd0) /tmp/vmbuilder-grub/1box-dummy.netfilter.x86_64.raw
[root@ct68 dummy.1box]# ls -la /tmp/tmp1445414732/boot/grub/
total 408
drwxr-xr-x 2 root root 4096 Oct 21 17:07 .
dr-xr-xr-x 4 root root 4096 Oct 21 17:06 ..
-rw-r--r-- 1 root root 13380 Feb 22 2013 e2fs_stage1_5
-rw-r--r-- 1 root root 12620 Feb 22 2013 fat_stage1_5
-rw-r--r-- 1 root root 11748 Feb 22 2013 ffs_stage1_5
-rw-r--r-- 1 root root 408 Oct 21 17:07 grub.conf
-rw-r--r-- 1 root root 11756 Feb 22 2013 iso9660_stage1_5
-rw-r--r-- 1 root root 13268 Feb 22 2013 jfs_stage1_5
lrwxrwxrwx 1 root root 9 Oct 21 17:07 menu.lst -> grub.conf
-rw-r--r-- 1 root root 11956 Feb 22 2013 minix_stage1_5
-rw-r--r-- 1 root root 14412 Feb 22 2013 reiserfs_stage1_5
-rw-r--r-- 1 root root 1341 Nov 15 2010 splash.xpm.gz
-rw-r--r-- 1 root root 512 Feb 22 2013 stage1
-rw-r--r-- 1 root root 125992 Feb 22 2013 stage2
-rw-r--r-- 1 root root 125992 Feb 22 2013 stage2_eltorito
-rw-r--r-- 1 root root 12024 Feb 22 2013 ufs2_stage1_5
-rw-r--r-- 1 root root 11364 Feb 22 2013 vstafs_stage1_5
-rw-r--r-- 1 root root 13964 Feb 22 2013 xfs_stage1_5
[root@ct68 dummy.1box]# ls -la /tmp/tmp1445414732/usr/share/grub/x86_64-redhat/
total 400
drwxr-xr-x 2 root root 4096 Aug 22 20:38 .
drwxr-xr-x 3 root root 4096 Aug 22 20:38 ..
-rw-r--r-- 1 root root 13380 Feb 22 2013 e2fs_stage1_5
-rw-r--r-- 1 root root 12620 Feb 22 2013 fat_stage1_5
-rw-r--r-- 1 root root 11748 Feb 22 2013 ffs_stage1_5
-rw-r--r-- 1 root root 11756 Feb 22 2013 iso9660_stage1_5
-rw-r--r-- 1 root root 13268 Feb 22 2013 jfs_stage1_5
-rw-r--r-- 1 root root 11956 Feb 22 2013 minix_stage1_5
-rw-r--r-- 1 root root 14412 Feb 22 2013 reiserfs_stage1_5
-rw-r--r-- 1 root root 512 Feb 22 2013 stage1
-rw-r--r-- 1 root root 125992 Feb 22 2013 stage2
-rw-r--r-- 1 root root 125992 Feb 22 2013 stage2_eltorito
-rw-r--r-- 1 root root 12024 Feb 22 2013 ufs2_stage1_5
-rw-r--r-- 1 root root 11364 Feb 22 2013 vstafs_stage1_5
-rw-r--r-- 1 root root 13964 Feb 22 2013 xfs_stage1_5
[root@ct68 dummy.1box]# mount --bind 1box-dummy.netfilter.x86_64.raw /tmp/tmp1445414732/tmp/vmbuilder-grub/1box-dummy.netfilter.x86_64.raw
[root@ct68 dummy.1box]# chroot /tmp/tmp1445414732 bash -e -c grub --batch --device-map=/tmp/tmp1445414732/tmp/vmbuilder-grub/device.map
Probing devices to guess BIOS drives. This may take a long time.
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]
grub> root (hd0,0)
root (hd0,0)
Error 21▒: Selected disk does not exist
grub>
1box-dummy.netfilter.x86_64.rawのbind mountがうまくいってないように見える。
ここにある関数をrefacterする必要がある? https://github.com/axsh/vmbuilder/blob/master/kvm/rhel/6/functions/distro.sh#L1047-L1129
This line is not working, but returns no error: https://github.com/axsh/vmbuilder/blob/master/kvm/rhel/6/functions/distro.sh#L1061
mount --bind ${disk_filename} ${chroot_dir}/${new_filename}
[root@ct68 dummy.1box]# ls -l /var/lib/jenkins/workspace/dummy.1box/1box-dummy.netfilter.x86_64.raw /tmp/tmp1447664384//tmp/vmbuilder-grub/1box-dummy.netfilter.x86_64.raw
-rw-r--r-- 1 root root 0 Nov 16 18:00 /tmp/tmp1447664384//tmp/vmbuilder-grub/1box-dummy.netfilter.x86_64.raw
-rw-r--r-- 1 root root 21474836480 Nov 16 18:01 /var/lib/jenkins/workspace/dummy.1box/1box-dummy.netfilter.x86_64.raw
[root@ct68 dummy.1box]# mount --bind /var/lib/jenkins/workspace/dummy.1box/1box-dummy.netfilter.x86_64.raw /tmp/tmp1447664384//tmp/vmbuilder-grub/1box-dummy.netfilter.x86_64.raw
[root@ct68 dummy.1box]# echo $?
0
[root@ct68 dummy.1box]# ls -l /var/lib/jenkins/workspace/dummy.1box/1box-dummy.netfilter.x86_64.raw /tmp/tmp1447664384//tmp/vmbuilder-grub/1box-dummy.netfilter.x86_64.raw
-rw-r--r-- 1 root root 0 Nov 16 18:00 /tmp/tmp1447664384//tmp/vmbuilder-grub/1box-dummy.netfilter.x86_64.raw
-rw-r--r-- 1 root root 21474836480 Nov 16 18:01 /var/lib/jenkins/workspace/dummy.1box/1box-dummy.netfilter.x86_64.raw
[root@ct68 dummy.1box]#
It is possible for mount --bind to work inside LXC:
/ssh:lxc32: #$ cd testbindmount/
/ssh:lxc32: #$ date >ddd
/ssh:lxc32: #$ touch ddcopy
/ssh:lxc32: #$ ls -l
total 4
-rw-rw-r-- 1 sysope sysope 0 Nov 17 04:06 ddcopy
-rw-rw-r-- 1 sysope sysope 29 Nov 17 04:06 ddd
/ssh:lxc32: #$ sudo mount --bind ddd ddcopy
/ssh:lxc32: #$ ls -l
total 8
-rw-rw-r-- 1 sysope sysope 29 Nov 17 04:06 ddcopy
-rw-rw-r-- 1 sysope sysope 29 Nov 17 04:06 ddd
/ssh:lxc32: #$ cat /etc/centos-release
CentOS release 6.7 (Final)
So why is it not working on 2.68?
"mount --bind" works in a new container created with https://github.com/wakameci/wakame-ci-cluster/blob/master/lxc-hosts/bootstrap-fedora-22.sh
But if the container is restarted with https://github.com/wakameci/wakame-ci-cluster/blob/master/lxc-hosts/lxc-stop.sh and https://github.com/wakameci/wakame-ci-cluster/blob/master/lxc-hosts/lxc-start.sh then, "mount --bind" stops working.
What is different between the two states? So far the most interesting thing is that polkitd is only running before stop/start. It is related to authorizations, so this difference could potentially be related. Still investigating....
Should have thought of this....mount does not return an error because it does work. The problem is that something is immediately unmount-ing the "--bind": (!)
/ssh:p26j: #$ mount --bind f80 mp ; echo $? ; ls -l mp ; sleep 1 ; ls -l mp
0
-rw-r--r-- 1 root root 29 Nov 18 15:17 mp
-rw-r--r-- 1 root root 0 Nov 18 19:35 mp
/ssh:p26j: #$
Starting polkitd had no effect, BTW.
Overview of debugging path and clues: (I may fill in more detail later)
For example:
stat("/run", {st_mode=S_IFDIR|0755, st_size=560, ...}) = 0
stat("/run/mount/utab", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
stat("/dev/sda1", 0x7fff3be10fc0) = -1 ENOENT (No such file or directory)
stat("/dev/sda1", 0x7fff3be10fc0) = -1 ENOENT (No such file or directory)
open("/etc/systemd/system/home-triggers-mp.mount", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/run/systemd/system/home-triggers-mp.mount", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = -1 ENOENT (No such file or directory)
Current patch:
diff --git a/lxc-hosts/lxc-device.sh b/lxc-hosts/lxc-device.sh
index c23afbf..3a2822e 100755
--- a/lxc-hosts/lxc-device.sh
+++ b/lxc-hosts/lxc-device.sh
@@ -50,6 +50,14 @@ lxc-attach -n ${ctid} -- bash -ex <<-EOS
[[ -c /dev/ptmx ]] || mknod -m 666 /dev/ptmx c 5 2
EOS
+# ASSUMES THAT /DEV/SDA IS THE CORRECT DEVICE (true for 192.168.2.26)
+lxc-attach -n ${ctid} -- bash -ex <<-EOS
+ [[ -b /dev/sda ]] || mknod /dev/sda -m 660 b 8 0
+ [[ -b /dev/sda1 ]] || mknod /dev/sda1 -m 660 b 8 1
+ [[ -b /dev/sdd ]] || mknod /dev/sdd -m 660 b 8 48
+ [[ -b /dev/sde ]] || mknod /dev/sde -m 660 b 8 64
+EOS
+
# /dev/loopX and /dev/dm-X
for i in {0..127}; do
lxc-attach -n ${ctid} -- bash -ex <<-EOS
Next step is to push this to github.com/wakameci/wakame-ci-cluster/.
Also want to do a little sanity checking to make sure this makes sense. For example, there really is not any /dev/sda1 inside the container.
Also would be good to understand why a fresh build worked, even though /dev/sda1 did not exist. Maybe systemd was started with a different configuration the first time? Not sure.