chroot on OSX as a different OS

4

1

I was wondering if anyone has been able to use chroot on OSX to run another OS (ubuntu, centos). I know that they are very different, but almost everything I want to use this for wouldn't care about anything at the level of the kernel, so was hoping there would be a way to do this without using a VM.

Based off my google searches, I see this question is asked, but no real answer other than "try a VM". Would really like to do this without a VM though.

ekaqu

Posted 2013-10-27T02:20:31.083

Reputation: 143

Answers

8

Unfortunately, most programs do care about the kernel, both directly and not.

Different operating systems have significant differences in even the most common features (epoll vs inotify vs kqueue, clone vs vfork vs rfork...).

Even if the program sticks to minimal features that look the same to userspace (e.g. stdio, basic file access), it (or rather, the libc) still needs to know how to call those functions in the kernel, which is completely different between Linux (plain old syscalls) and OS X (a mix of syscalls and Mach IPC).

And that's assuming you can get the kernel to start executing the program in the first place – the OS X kernel does not understand the ELF format, only Mach-O (plus all sorts of legacy Mac OS stuff).

Various emulators exist – for example, FreeBSD has Linux emulation, and Wine runs Windows programs on Unixes, and there seems to be an OS X emulator for Linux – but I couldn't find any that would run Linux programs on OS X.

Here's a description of how basic Linux functions are emulated on FreeBSD.

user1686

Posted 2013-10-27T02:20:31.083

Reputation: 283 655

I am sad that this 'answer' does not actually give an answer to the question. Assuming I dont care that nothing will work, I would still like to know the steps I would need to take to load e.g. my Ubuntu ISO in a chroot on macOS. Been Google'ing for quite some time and can't find a clear answer. – user5359531 – 2018-06-14T03:58:02.033

I don't understand what you expect to gain from "loading in a chroot" given that nothing will work. ("Nothing" is absolute: it's not just that you can't run apps; you also can't run any commands or even shells. The chroot tool has exactly two choices: fail and undo, or leave you stare at a black window with no actions possible.) So what's the goal? – user1686 – 2018-06-14T04:14:37.133

5

chroot changes the root directory; it doesn't change the executable file format, application binary interface, etc, all of which are different between OS X and linux. Running another OS takes way more than chroot; it takes a VM.

Gordon Davisson

Posted 2013-10-27T02:20:31.083

Reputation: 28 538