WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Simulate system with less resources??  (Read 3742 times)

Offline mb0

  • Jr. Member
  • **
  • Posts: 86
Simulate system with less resources??
« on: March 14, 2012, 11:22:03 AM »
Is there a way to properly simulate having less resources than are actually available to the linux system?? IE. lower CPU power and RAM.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Simulate system with less resources??
« Reply #1 on: March 14, 2012, 11:39:50 AM »
Hi mb0
You can limit memory with:
Code: [Select]
max_addr=nn[KMG]    [KNL,BOOT,ia64] All physical memory greater
                    than or equal to this physical address is ignored.


Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Simulate system with less resources??
« Reply #2 on: March 14, 2012, 02:09:40 PM »
I would use an emulator (e.g. QEMU or Bochs, both available as extensions in the 4.x repository). For each VM you can easily limit the RAM. With regards to the CPU you should have some options to chose a lower spec model, but I would not rely on the emulator to get it always 100% right.

Offline mb0

  • Jr. Member
  • **
  • Posts: 86
Re: Simulate system with less resources??
« Reply #3 on: March 15, 2012, 09:00:04 AM »
I think my system crashed when during my attempt to install qemu, and when i try to install again it says 'mount: mounting /dev/loop179 on /tmp/tcloop/SDL failed: Invalid argument'

Would qemu allow me to get a rough idea of how my software would run on arm/mips systems without changing the (x86) software? Or would i just be able to scale to a slower x86 processor, unless i recompiled?? (ie, not quite sure how qemu works)

As for max_addr=nn ..i am meant to put this in /mnt/{drive}/boot/extlinux/extlinux.conf? and what should i put for the address.. say i wanted to simulate 64mb ram then what would i put as the value??

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: Simulate system with less resources??
« Reply #4 on: March 15, 2012, 09:31:27 AM »
The mem boot option is simpler to use than max_addr and does the same thing.
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Simulate system with less resources??
« Reply #5 on: March 15, 2012, 09:36:02 AM »
Hi mb0
To simulate 64Meg of RAM,  max_addr=64M
If extlinux is the boot loader you are using, add it to the  APPEND  line in extlinux.conf.

I see curaga got here ahead of me, so his suggestion is,   mem=64M

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Simulate system with less resources??
« Reply #6 on: March 15, 2012, 02:06:40 PM »
...
Would qemu allow me to get a rough idea of how my software would run on arm/mips systems without changing the (x86) software? Or would i just be able to scale to a slower x86 processor, unless i recompiled?? (ie, not quite sure how qemu works)
...
A particular strength of QEMU is that it has two operating modes:
  • Full system emulation. In this mode, QEMU emulates a full system (for example a PC), including one or several processors and various peripherals. [...]
  • User mode emulation. In this mode, QEMU can launch processes compiled for one CPU on another CPU. [...]
(abbreviated quote from the QEMU man page) So yes, you could use your PC (i.e. a x86 system) to see how your piece of software would work on a different CPU (e.g. MIPS); provided you've either cross-compiled it on the host or compiled it from source either inside the VM or on a different "native" system.

Using user mode emulation will probably only make sense if you've got a simple stand-alone executable (e.g. statically linked) and very little other dependencies. I've got to admit that I've used this mode maybe once or twice (essentially "just for fun") in the several years I've been using QEMU now on a virtual daily basis. So I'm not really sure about its limitations.

OTOH the full system emulation can work indeed "as advertised". I'm saying this with a bit of hesitation as non-x86 systems can be a bit more tricky: For example a few days ago I wanted to check out the behaviour of a certain Perl module on a big-endian CPU, and I picked for no particular reason the PowerPC CPU for this exercise. So the idea was to find a PPC Linux distribution that could be operated in a Live system manor, as this is what I've come to appreciate in my work with TC. In the end I had to give several different (small) distributions a try, and I've stumbled over a few bugs (or limitations) in those when run in an QEMU VM. Some of the issues encountered might be a problem in QEMU itself, others I'd say are clearly distribution related (e.g. certain necessary kernel modules that were not included in the initrd). So all up I'd say it can work quite well, but it pays to be able to understand and troubleshoot all the problems one might uncover. IMHO the problems can be due to limited testing done by the smaller group of QEMU developers for the non-x86 systems, and the smaller group of people supporting those non-x86 Linux systems.

OTOH when running QEMU on a PC to emulate a PC we are rather talking of a Virtualizer. In this case you are better off to add the KVM extension (provided your host CPU supports it) to gain near native speed for the emulated system. But as you were rather asking to slow things down this might not be your primary concern right now.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: Simulate system with less resources??
« Reply #7 on: March 16, 2012, 01:01:17 AM »
If you merely need to see the effect of a slower cpu, you can run it on the host and limit with cpulimit.
The only barriers that can stop you are the ones you create yourself.