Score:0

How to keep synchronized in real time two Ubuntu installations?

in flag

I'm looking for the better tool /method / technique that can help me to keep synchronized in real time two Ubuntu installations. I want that every change I make to one of them will be immediately applied to the other one. Now I'm going to explain how is configured my setup. Let's start saying that my primary OS is FreeBSD and that I'm using bhyve to virtualize Ubuntu,using the following parameters :

bhyve -S -c sockets=1,cores=2,threads=2 -m 4G -w -H -A \
-s 0,hostbridge \
-s 1,ahci-hd,/mnt/da3p2/bhyve/nvme.img \
-s 2,passthru,1/0/0 \
-s 3:0,passthru,2/0/0 \
-s 3:1,passthru,2/0/1 \
-s 3:2,passthru,2/0/2 \
-s 3:3,passthru,2/0/3 \
-s 8,virtio-net,tap1 \
-s 9,virtio-9p,sharename=/mnt/nvd0p7 \
-s 30,xhci,tablet \
-s 31,lpc \
-s 29,fbuf,tcp=0.0.0.0:5901,w=1440,h=900 \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_BHF_CODE.fd \
-l com1,stdio \
vm1

Actually I have installed Ubuntu 21.10 physically on my nvme disk and it is partitioned like this :

marietto@marietto:/usr/home/marietto # gpart show :


root@marietto:/usr/home/marietto # gpart show
=>        34  1953525101  nvd0  GPT  (932G)
          34        2014        - free -  (1.0M)
        2048     1748992     1  efi  (854M)
     1751040  1113507840     2  ms-basic-data  (531G)
  1115258880   833185547     7  ms-basic-data  (397G)
  1948444427         245        - free -  (123K)
  1948444672     1318912     3  ms-recovery  (644M)
  1949763584        2048        - free -  (1.0M)
  1949765632     1310720     4  ms-recovery  (640M)
  1951076352        2048        - free -  (1.0M)
  1951078400     1265657     5  ms-basic-data  (618M)
  1952344057           7        - free -  (3.5K)
  1952344064     1179641     6  ms-basic-data  (576M)
  1953523705        1430        - free -  (715K)

Ubuntu 21.10 is installed on the slot /dev/nvd0p7. What I wanted to do at the beginning was to boot that Ubuntu physical installation directly on bhyve,pointing it to /dev/nvd0,but there is a bug and it does not work for the easiest way. So,I found a "workaround" ; I have cloned my nvme disk with dd and I've created an img / raw file called "nvme.img" and I've copied it to my 2 TB size disk. Now,when I want to boot and use Ubuntu 21.10,I can do it directly when I'm running FreeBSD and bhyve. The real Ubuntu installation and its img file are almost identical. Actually when I boot the nvme.img file with bhyve,I have also share the partition where I have mounted the physical installation of Ubuntu in FreeBSD,using this parameter :

-s 9,virtio-9p,sharename=/mnt/nvd0p7 \

So,the real partition where are all the files of the physical Ubuntu installation is available when I boot the Ubuntu image created with dd while I'm using FreeBSD and bhyve. Good. at this point you have all the elements to understand what I want to do. While I'm using the image of Ubuntu created with dd,some files of this installation will change. What I want to do is to keep them synchronized with the files stored on the physical installation of Ubuntu,mapped at /mnt/nvd0p7 ; doing this,when,in the future I will boot the physical installation of Ubuntu,I will have all the files updated correctly. If everything will work correctly there will be no need to boot Ubuntu physically,but it could happen. So,which kind of tool / method you suggest me to accomplish this task ? thanks.

PonJar avatar
in flag
You should investigate the rsync command. It’s ideal for synchronising directories and files
in flag
I was thinking to use the physical installation of Ubuntu using the chroot or the lxc containers. It's really a bad idea ?
PonJar avatar
in flag
I cannot say if it’s a bad idea or not because I don’t know how that would work. If your VM can see and mount the physical installation rsync should work well with only changes being transferred. With the right options set it will also delete anything deleted on the VM.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.