LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 11-28-2021, 11:54 AM   #1
ljones0
Member
 
Registered: Dec 2007
Posts: 100

Rep: Reputation: 17
Using a chroot directly as a virtual/emulated machine


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/chroot
This 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/chroot
However 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 loop
This 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_image
Does 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

Last edited by ljones0; 11-28-2021 at 12:01 PM.
 
Old 11-28-2021, 12:55 PM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
I think you can do something like that and copy the directory into a raw image using virt-make-fs which might be found in the libguestfs-tools package:

Code:
sudo virt-make-fs --format=raw --label=qemu.chroot \
        /home/ljones0/LIVE_BOOT/chroot/ \
        /home/ljones0/chroot.raw

sudo chown ljones0:ljones0 /home/ljones0/chroot.raw
Then in qemu add in a line with -drive format=raw,file=/home/ljones0/chroot.raw or something like that.

However any changes will be within the copied chroot and you'll have to shut down Qemu and then mount the raw image as a loopback device before copying back to the chroot.

Code:
sudo mount -o loop /home/ljones0/chroot.raw /mnt/
sudo rsync -aH /mnt/ /home/ljones0/LIVE_BOOT/chroot/
If you want the changes live, then you'll have to make the chroot its own partition and mount that directly using Qemu.

Either way, you can use Qemu to build the system and then quit the VM and continue onward with the instructions you've linked to and finish making the ISO image.
 
Old 12-04-2021, 05:12 AM   #3
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Quote:
Originally Posted by ljones0 View Post
I have been using these instructions and they work fine without any issue.
I've built a couple Custom Debian Live, the first one took me an entire winter as I rebuilt it a thousand times or so till it had full hardware support for any PC on the shelf at any store. I had personal root and user password in that one but Debian Live changed and I was not able to get that on the Custom Buster Live, first one might of been Jessie or Stretch, didn't have systemd neither.

These instructions appear to have you do manually what the Debian Live package (and dependencies) do.
Debian Live manual
Using Debian Live, you build a generic Debian Live if you want first, then start customizing, most of the packages have been downloaded and cached already. Just keep churning out the ISOs and fire them up with qemu virtualbox etc. to see what you created and what you want to try next, what failed etc.

The instructions you posted do not provide a custom Debian Live, it provides someones incarnation, which is "custom" to them. I don't see anything spectacular here.

When your Debian Live boots with the wallpaper you want, theme and colors etc. that you want, Firefox has your favorite plugins/extensions installed, bookmarks, homepage set to what you want etc., then you have a custom Debian Live. Simply installing the apps of your choice may also qualify as custom, but it looks like your willing to do some leg work so might as well just install the live app and build a 100 or so Debian Live till your pooped or happy.

What exactly is the advantage to doing this in a chroot?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How To Enable Virtual Emulated Desktop On Proton Steam On Ubuntu Linux! LXer Syndicated Linux News 0 10-13-2021 01:31 PM
Is base memory of virtual machine used when virtual machine is not running? ravisingh1 Linux - Virtualization and Cloud 3 04-09-2013 03:41 AM
Can KVM access a Hyper-V virtual machine directly Nick_C Linux - Virtualization and Cloud 4 03-05-2012 10:12 AM
Running virtual pc files in a virtual machine in linux ... preferably virtual box biharibong Linux - Software 4 01-21-2009 01:04 PM
Problem using CD to install (Scsi Emulated IDE Device) chmodchown Slackware - Installation 4 11-08-2006 10:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 04:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration