Extremely lightweight virtualization of FreeBSD

pratham

New Member


Messages: 3

Having used macOS, I know "ping -A" will make a beep every time a host is unreachable. It came in handy at times when my internet would act up. I want to do the same, but virtualization of the whole OS is kinda unnecessary. I tried grabbing FreeBSD source code, and individually compiling "ping" on my linux box, but to a surprise to no one, I couldn't get it working. That being said, I know nothing about porting, that was just an effort I made hoping I would succeed. I was hoping I would find a FreeBSD docker container just like there are Ubuntu and CentOS docker containers. I just need "ping" to beep but I just can't think of anything else that will work without virtualization of the whole OS.

I'm here to ask if someone else has a better solution?
 

covacat

New Member

Reaction score: 2
Messages: 9

just hack the linux ping (source code is best but if you are lazy...)
patch the binary with your favorite hex/editor and change "no answer yet" to "no^Ganswer yet" where ^G is ASCII bell "\a"
then use use ping -O destination


cmp -b /bin/ping bing


/bin/ping bing differ: byte 33802, line 132 is 40 7 ^G
~# ./bing -V
ping utility, iputils-s20121221
 

ralphbsz

Son of Beastie

Reaction score: 1,983
Messages: 2,942

I don't understand.

You want to run ping -A. Great idea. Go ahead and do it. Depending on how you use FreeBSD (GUI or not, remote or not), you can do it in a dedicated window, on another console, or in a background process.

What does that have to do with virtualization or with Docker?

Please explain what you want to do with more detail.
 
OP
P

pratham

New Member


Messages: 3

Yeah, what I mean by that is I don't want to run every single service running in FreeBSD. I don't want to dedicate my CPU cycles to things that I don't need. Everything except for sound (for beeps), occasional SSH (to check if the VM froze or not) and the network stack for ping, is not necessary (well except for the essential services to boot the OS obviously). So something like a docker container. If you understand, I just want ping to work; and nothing else.

I can virtualize FreeBSD on my Raspberry Pi, with UEFI firmware + ESXi but I do not want to go that route to virtualize a full operating system just to use one utility it offers.
 

Zirias

Daemon

Reaction score: 1,095
Messages: 1,977

ralphbsz he doesn't want FreeBSD but Linux and wonders why FreeBSD's ping source doesn't compile on Linux…

And just saying, covacat has the sensible answer. And of course, this whole topic is off-topic here, because it's asking about Linux, not about FreeBSD. Might be related to:
I was hoping I would find a FreeBSD docker container just like there are Ubuntu and CentOS docker containers.
this "interesting" misconception, that FreeBSD was a "Linux distro".
 

ondra_knezour

Aspiring Daemon

Reaction score: 221
Messages: 791

Something like this may work ping -c 1 -t 1 -Q 10.0.0.1 || printf "\a". I didn't bother to check for Linux command line parameters, but on the FreeBSD, previous code means ping -c (count) 1 -t (timeout) 1 -Q (somewhat quiet output) address 10.0.0.1 || (OR, which mean if return code is positive integer, which means error) printf "\a" (print audible character in terminal).

That would make one test with one packet. You can insert it in any for/while loop with sleeps in between as you see fit.
 

Zirias

Daemon

Reaction score: 1,095
Messages: 1,977

pratham what docker basically does is userspace virtualization. FreeBSD jails use the same basic idea (and are, side-note, much older). Anyways, this means the kernel is shared between the host and everything virtualized that way. This can ONLY work if everything is the same OS. (And yes, different Linux distributions are still all the same OS)

Then again, FreeBSD is not Linux. You can run Linux jails on FreeBSD, because FreeBSD kernels implement some Linux compatibility syscalls. It's impossible the other way around.

So, your question comes down to having a ping on Linux that beeps, and this is indeed off-topic here.
 
OP
P

pratham

New Member


Messages: 3

I had an overview of BSD jails but never tried it as I am not even a few months in learning FreeBSD (as I want to get a ZFS box for myself and what better than FreeBSD with ZoL 2.0 (but that will be in 13.X-RELEASE)). Also, I didn't knew that docker shared the same kernel, that is the reason why the FreeBSD docker container doesn't run on Linux. Thanks for that.

I also realized from the discussion that a script is a better way to achieve what I want to do and will do just that. Maybe publish a python package in future for this very thing.

This was my first post here and I genuinely thank you all for the help.
 

Zirias

Daemon

Reaction score: 1,095
Messages: 1,977

I had an overview of BSD jails but never tried it as I am not even a few months in learning FreeBSD (as I want to get a ZFS box for myself and what better than FreeBSD with ZoL 2.0 (but that will be in 13.X-RELEASE)). Also, I didn't knew that docker shared the same kernel, that is the reason why the FreeBSD docker container doesn't run on Linux. Thanks for that.
Docker seems to have some optional feature to use "real" virtualization; that way, you can run Linux containers on Windows and vice versa, but that boils down to what you don't want then. Still, might be possible to run FreeBSD that way. I don't see the usecase though ;)

On a FreeBSD host, forget about Docker. On a very basic level, jails do the same thing anyways. There were some attempts to build "Docker-like" infrastructure on top of jails; of course not compatible with Docker.

I also realized from the discussion that a script is a better way to achieve what I want to do and will do just that.
Not sure about that. If I wanted that functionality in ping, I'd indeed just hack its source. A "beep" is very simple to accomplish, just write ^G (ctrl+g, code 0x07) to stdout, same effect as hitting ctrl+g in the terminal yourself.
 
Top