Using a chroot directly as a virtual/emulated machine
by ljones0 from LinuxQuestions.org on (#5SEHP)
Hello all!
Here's what I'm trying to do. I'm trying to create a chroot to create a custom debian live cd image and then to test or modify it via chroot directly either as a virtual or emulated machine.
I have been using these instructions and they work fine without any issue.
But here's the problem -- let's say I wanted to make a change to the chroot from within the chroot. I understand I can simply use the chroot comamnd as root to do this, eg
Code:$ chroot /home/test/LIVE_BOOT/chrootThis works without issue (for example installing extra packages). But here's the problem - this isn't going to work for GUI (X) based programs and desktops since I'm already running a GUI so GUI based programs can't really be run in that way.
One way I thought might work might be to use qemu. But unfortunatly it does not. For example;
Code:$ qemu-system-i386 -boot c -hda /home/test/LIVE_BOOT/chrootHowever this cannot work because qemu can't deal with "just files in a directory" it has to be an image file or device.
One way to do this might be to create an empty file with dd and then prepare it and copy the files to it. But this means having to have a copy of all the files - and a large image file to do this.
I can see there is a way to mount an image file to a directory,eg.
Code:$ mount /home/test/myimage.img /tmp/0 -o loopThis works to be able to see the files from within an image file by using a loopback but there dosen't seem to be anything going in the opposite direction - to make a directory holding lots of files directly into a virtual image or device. Sort of - if you will - and here is an imaginary example;
Code:$ mount /home/test/LIVE_BOOT/chroot myimage.img -o virtual_imageDoes anyone know of a way either of getting qemu to be able to use a chroot or be able to temporarily turn a directory with files inside into a (presumably virtual) device or image?
ljones
Here's what I'm trying to do. I'm trying to create a chroot to create a custom debian live cd image and then to test or modify it via chroot directly either as a virtual or emulated machine.
I have been using these instructions and they work fine without any issue.
But here's the problem -- let's say I wanted to make a change to the chroot from within the chroot. I understand I can simply use the chroot comamnd as root to do this, eg
Code:$ chroot /home/test/LIVE_BOOT/chrootThis works without issue (for example installing extra packages). But here's the problem - this isn't going to work for GUI (X) based programs and desktops since I'm already running a GUI so GUI based programs can't really be run in that way.
One way I thought might work might be to use qemu. But unfortunatly it does not. For example;
Code:$ qemu-system-i386 -boot c -hda /home/test/LIVE_BOOT/chrootHowever this cannot work because qemu can't deal with "just files in a directory" it has to be an image file or device.
One way to do this might be to create an empty file with dd and then prepare it and copy the files to it. But this means having to have a copy of all the files - and a large image file to do this.
I can see there is a way to mount an image file to a directory,eg.
Code:$ mount /home/test/myimage.img /tmp/0 -o loopThis works to be able to see the files from within an image file by using a loopback but there dosen't seem to be anything going in the opposite direction - to make a directory holding lots of files directly into a virtual image or device. Sort of - if you will - and here is an imaginary example;
Code:$ mount /home/test/LIVE_BOOT/chroot myimage.img -o virtual_imageDoes anyone know of a way either of getting qemu to be able to use a chroot or be able to temporarily turn a directory with files inside into a (presumably virtual) device or image?
ljones