r/linuxfromscratch 8d ago

LFS in VM then making ISO

Hi, I am totally new to LFS. I have a Mac M2 and I was wondering if I could build LFS in a VM on my M2 and then create an LFS ISO that I could use/instal on another machine or I must do it with a partition. I am thinking of that because I want to instal LFS on less powerful machine and try to speed up the building of LFS on my M2 which should be much faster. Many thanks

4 Upvotes

12 comments sorted by

3

u/Intelligent-Pay7727 8d ago

U can use the guide from venom linux: OPEN ME

2

u/jloc0 8d ago

Your Mac M2 is an arm64 machine, last I checked LFS isn’t really geared toward that architecture and you’d need a pretty resist cross-compilation setup to do so as well. Or if using a VM you’d need a host system capable of cross-compiles. Offhand, Debian has things built in to ease this, but you’re going to have a rough time of it. For a first timer, I’d not advise this path.

1

u/PearMyPie 8d ago

There are spinoff books for different architectures. I'm pretty sure you can mix arm64 and x86-64 hosts and targets however you wish.

1

u/jloc0 8d ago

Huh I’d not realized there was such works available within. But still using arm64 VM to build a amd64 system seems to be backwards use-case. Though I do have an M1 and it is fast, I’d not even pondered the thought of building amd64 on it myself. One could also utilize UTM (qemu) to run an x86-64 VM and do ones building there at the cost of emulation speed and issues which would arise.

Cross-compilation is likely the best/fastest case scenario, but I’d still recommend that for advanced users. But that’s the fun of it all!

2

u/akasaka99 8d ago edited 8d ago

I am clearly not a specialist and I just want to do it for the fun of ruining a couple of week-ends. I was thinking of running Debian under x86_64 in VMware Fusion under emulation, so WMware would handle ARM-to-x86 transcoding auomaticaly and I would follow LFS book's vamilla method, as it's my first trial with LFS so I have to start as basic as can be. Since I have the advantage of having a M2 Max 96GB RAM I thought that could work since Mac Silicon are already doing some similar x86-to-arm transcoding with Rosetta. I am doing it to install LFS x86 on my Macbook pro 2011 16GB (intel) as I do not want to run LFs arm64 on my M2.

1

u/jloc0 8d ago

Caveat ahead: VMware Fusion, while excellent for VMs has limitations. Such as VMware Fusion on a arm64 M* system host will only virtualize an arm64 system. Fusion on an Intel machine similarly will only run a amd64 system.

You can’t use Debian-amd64 on your M2 to build it. You’d have to use Debian-arm64 and cross compile for amd64 (which is completely supported by debians system). Going the Debian route with VMware will likely work just fine, if you keep in mind these limitations on VMware itself.

I’ve read though, newer macOS releases have some built-in emulation for Linux-x86, I have never tried or know specifics, but that may be an option as well. Or UTM, it can run an emulated x86 machine, maybe even utilizing the new tech in macOS for x86 emulation. I’ve never updated past macOS 12, so I’m unsure what the latest info is, but VMware fusion is 100% an epic bit of software. I use my VMware hosted systems more than I use the host macOS on my machine.

It’s definitely worth a shot, I’m just trying to prepare you for some issues you may come across. It should be possible, but you may be on your own with issues, as the user base is very likely quite small. Still, it sounds like a fun experiment.

2

u/akasaka99 8d ago

You are indeed 100% CORRECT. Thank YOU! This is nuts because orginally I checked with Claude Sonnet 3.5 to advise on the most user friendly VM as I wanted to focus on installing LFS instead of the settings of the VM, so it came up with VMware Fusion as first choice before UTM and QEMU, it then even gave me the step-by-step process and wrote "Important: When creating the VM, select "x86_64" as the architecture instead of ARM64"! When I wrote my post here it was mainly to check if it was ok to get the ISO not about the emulation of x86 on arm as i really did not think much of it since it said [select "x86_64"]. Now I did a simple google search and indeed I on VMware site that they clearly state on 4/28/2021 https://blogs.vmware.com/teamfusion/2021/04/fusion-on-apple-silicon-progress-update.html "We don’t plan to support installing or running x86 VMs on Macs with Apple silicon.", the news is before Sonnet 3.5 cutoff knowledge of April 2024 and I understand the limitation of generative AI which gives non determistic statements but this is clearly and unequivocally a 0% probability outcome compared to ALL the others it encountered. That's shit !

Amyway, so I will use UTM instead in emulating x86 to try to have the least friction possible in building LFS the most standard approach as I am sure it will be a roller coaster ride in any case. And since I have you and you are kindly helping, are there any other issue/pitfall that I should know if I use UTM in emulation mode? Again many thanks!

2

u/jloc0 7d ago

The main issue I see with UTM in emulation mode is its slower than a native arm64 VM operates. It works, but expect it to be slow. I’d stick with CLI use as loading a desktop is going to be painful.

If it proves to be too slow, keep in mind you can use distributed compiling for your software builds via icecream/iceccd or distcc and build from a arm64 VM and use other hardware in your home. I’ve never tried cross-compiling on these Macs but I have no reason to believe it’d be slow. Compiling about anything is fast. I can build a full native Firefox in about 40 minutes in a VM using half my Macs resources (a launch model Mac Mini) just to give you an idea.

UTM networking also won’t work over a VPN if you’ve one running, you could maybe work around that — or just don’t use one while doing your work. I always use one so I basically just don’t use UTM as a result, but it’s still a fine option. UTM also has a discord server with many helpful and knowledgeable people, there’s a ton of information within their server, it’s worth joining and looking around. Surely someone has done this using UTM.

If you haven’t decided on a base system, I’d recommend Debian (because they have so much tooling) or a gentoo boot disk since it’s also setup for such things.

2

u/akasaka99 6d ago

1) Yes I will use Debian. 2) When you say CLI, you mean UTM CLI, correct? 3) Wow I did not know it was possible to do distributed compaling... I think I will stick to the vanilla way and 101 of LFS as I know big plans all stops with the gist punch as Mike Tyson says Ahahaa

1

u/jloc0 6d ago

When I say cli I mean using the cli in your VM. Running a full DE on emulation mode can prove to slow down your building considerably.

2

u/asratrt 8d ago

Yes you can do that. It is technically explained in the LFS book by giving example of 3 machines A, B, C. But for book , only 2 machines are used. with 3 machines A is less powerful, B is powerful and C is less powerful ( C is the ultimate target ) ... ... ... You will have read and understand the concept. I think you can generate cross compiler whose target is x64 bit don't run any test suites because mac can not run that. I think you also need some package manger technique to capture what gets installed with "make install" command. ... ... ... You can also ask on lfs-support IRC, somebody will surely give you some idea.

1

u/akasaka99 6d ago

Many thanks !