25 January 2018

Editing entries in Kanotix Grub menu (quick and tricky)


This regarding the Kanotix live distro (version steelfire 2017) that boots from USB with persistence activated.



If you don't want to add your menu entries in the right place and then do all the work necessary to be able to run properly grub-update, then you can just find the file

/lib/live/mount/persistence/sda3/grub.cmdline

edit it with the parameters you want and leave (you must be running in persistent mode).



Presently, the content of that file on my pc looks like

set persistence_cmdline='boot=live config utc=yes locales=en_GB.UTF-8 quiet splash persistence'




Once you reboot in Grub, you cannot see your edits directly on the menu, but you can press 'c' for command line mode and there do

# echo ${persistence_cmdline}

and you will see your edits.




I don't add "toram" into that line because sometimes I may want to run with persistence but without toram and removing something from the GRUB command line is way harder than adding it (you have to edit that ${persistence_cmdline} vs simply adding something after .



To boot toram (it needs 1.4GB RAM) I just select the GRUB line I want, press c and add toram at the end of the kernel parameters, like:

set persistence_cmdline='boot=live config utc=yes locales=en_GB.UTF-8 quiet splash persistence     toram


PC & OS (Linux) : lighter, faster, smaller, more portable and versatile

For a while know I have been searching for a way to have a computer that is much lighter to travel with that the one I have now.

What I have now is a laptop of about 3.9Kg (charger included) and that's too much when you like to have a luggage of ~10Kg for hand luggage, which normally is my only luggage.

I thought about using a mini-PC or a TV-Box as CPU and my tablet as monitor. TV-Box option was too weak on cpu power and small RAM. The mini-PC was giving a similar or higher cpu power in a much smaller size/weight than the laptop, at a higher price than the laptop. I don't like paying twice for the same thing.

Then I thought that I could strip down the laptop (as I had to do with an older laptop with dying components) removing the CD/DVD unit and the HD. Yes, the HD too.

The HD not only for its weight, and maybe its power consumption, but mainly because I need more speed and having a bit better CPU will not help much, but running the OS entirely from RAM ... oh yes, that's speed.

So, my OS would boot from a usb stick to RAM and in another partition on the same stick/sdcard I would place my personal files in an encrypted container.

The files that are going to be used many times (browsers' configuration stuff) would be copied to RAM and be used from there, syncing back at regular intervals and before shutdown, which rarely happens, as I tend to run for weeks and even months by suspending the laptop when not in use (tool: profile-sync-daemon).

Very large files like Virtual Machines (VMs) would be stored on the usb stick/sdcard or additional storage..

Mount options and serviceshave been configured for minimum wear of the storage.

Laptop without CD-ROM and HD :  3.4 -> 2.8 Kg  (charger not included)
OS: Kanotix on USB. Loads entirely on RAM using 1.4 GB of it. There is a partition for "persistence" that is not loaded into RAM. It saves the changes like software added to the base distro.
The USB memory is actually a micro SD card of 16GB. Everything fits perfectly on it.


I have been running for more than a week with this configuration and I don't think I will go back. It's quiet, fast, lighter. I haven't missed anything of what was on the HD (500GB). I can still run Virtual Machines using Virtual Box.

I even tried to run another Kanotix-on-USB on a VM (reading from a real usb stick) and that worked perfectly. Actually I used it because I needed to compile some modifications and I didn't want to 'dirty' my base installation, so I did all the dirty work over a clone in a VM and then save the result out and power off (= all changes are forgotten).

It feels like using a very large tablet, with the power of a PC and huge RAM (12GB).

24 January 2018

Measuring web server performance.


There are many commands out there with nice timings of many things.

I just wanted to know how long would it take to get sequentially a bunch of pages from different servers.


You can do that with:


BASE="http://YOURSITE.com";
for i in 1 2 3; do echo "========test $i";  time for w in $LIST; do   curl -s   -o /dev/null "$BASE/$w" ; done ; sleep 2; done


The list is like

# LIST="something.html
blah.html
image.png"


It will do the operation 3 times and display how long it took to get each list of documents. Simple!


Replace BASE with the different servers and run again.


Renaming a bunch of files in Linux to make them contain SEO keywords


Some files are like

blah-815x338.png
blah2-300x800.png

And we want them renamed to

blah--LIST-OF-KEYWORDS-815x338.png
blah2--LIST-OF-KEYWORDS-300x800.png


You can do that with
# rename  -n   's/(-[0-9]*x[0-9]*\.[png,jpg,jpeg,gif])/--LIST-OF-KEYWORDS$1/' *


And some other files were like:

aaaaaa.jpg
eeeeeeee.png
whatever.gif

And we want them like

aaaaaa--LIST-OF-KEYWORDS.jpg
eeeeeeee--LIST-OF-KEYWORDS.png
whatever--LIST-OF-KEYWORDS.gif


You can do that with:
# find .  | grep -v "LIST-OF-KEYWORDS" | cut -b 3- | while read file ; do echo $file;rename     's/(\.[png,jpg,jpeg,gif])/--LIST-OF-KEYWORDS$1/' "$file"  ; done


Hope it helps.
Too Cool for Internet Explorer