Linux swap space - real usage
Wednesday, January 19, 2011
Using top, ps aux, etc etc gives all kinds of memory usage with lots of blog posts and forum questions explaining how difficult they are to understand, and how typically aren't actually that useful.
As of kernel 2.6.14, smaps has been introduced which means each process reports its own memory usage breakdown.
smaps detail for a process can be seen by:
So, use top, find the big memory hoggers first. Then look at the smaps file for the swap usage. You can use, for example:
For more advanced smaps analysis, try the smaps.pl tool. Not sure at this stage, though, whether that tool gives separate swap values.
In Debian at time of this post, the pmap tool has been patched to use smaps, which may then offer swap values in its output.
mobile phone as modem
Sunday, October 26, 2008
There are a number of posts around the place on getting gprs or 3g cellphone connections working on linux. I wasn't interested in bluetooth as I have limited batteries and a usb cable. And you don't always know what your locla settings should be.
Here's all I did on Xubuntu Hardy:
- Plug the phone into the computer using the usb cable.
- In a terminal, type "sudo wvdialconf". (This sets up available baud rates, etc)
- In a terminal, type "sudo vi /etc/wvdial.conf".
- Edit this file with:
- phone = [for my nokia on Vodafone New Zealand, the number is "*99#". I phoned them to find out.]
- name = [the login name, if your mobile company requires it. Vfone NZ doesn't, but wvdial needed something here. I used "name"].
- password = [as with name. I used "password"].
- Save and close the file.
- Connect to the internet via your mobile by typing "wvdial" in a terminal window.
- When done, press ctrl-c in that window.
linux tools
Monday, September 29, 2008
What I use on xubuntu linux for specific tasks:....
| Task | Tool | Date | Ubuntu Package | Comment |
|---|---|---|---|---|
| pdf annotating | flpsed | Sep 2008 | flpsed | Very basic app that enables load/save of ps and pdf. Multi-line text can be added to the docs. No highlighting option or editing of existing content. |
| pdf editing | pdfedit | Sep 2008 | pdfedit | Allows editing of any part of multi-page PDF documents. Can be very slow to use on long documents. New content such as highlighting and single-line text can be added also. |
| vector graphics / single-page pdf annotating | inkscape | Sep 2008 | inkscape | Great tool for vector graphics, quick and easy results. Can import a single page of PDF documents. |
| xml viewing / formatting | XML Copy Editor | Sep 2008 | xmlcopyeditor | Load and view xml. Validate form and against dtd etc, plus nicely format. Quick and easy. |
| diff | meld | Sep 2008 | meld | Excellent visual diff/merge tool. |
| text/source editor | SciTE | Sep 2008 | SciTE | Excellent text editor with awareness of many languages and markups. Tabbed view. |
debug sound in linux - first steps!!
Wednesday, July 09, 2008
My sound stopped after having worked for 6 months. I hadn't run any updates, and even tried booting into previous kernels to check, but that didn't help. Finally I discovered the answer, but not thanks to internet searching. Here are the requirements:
- If you are running linux
- If you have Windows on another partition you can dual boot into
- If sound works ok in Windows
- Check for a hardware mute switch and/or volume control on the machine (especially laptops) - this will affect Windows as well, so if it's currently working there then this won't be the problem
- Boot into Windows. Unmute the sound. Try linux again
The silver-lining in this exercise in frustration was fixing my VLC performance. I had noticed for a few weeks that music and movies played in VLC would be silent for the first 10s or so. Running VLC in terminal gave complaints about pulseaudio not found.
Solution here for me was to go into the VLC preferences> Output Modules and check the box for advanced options. Change 'Audio Output Module' from default to 'ALSA audio output'.
The alternative option would be to install pulseaudio (sudo aptitude install pulseaudio). It seems pulseaudio is the new default sound server in Ubuntu and provides more advanced sound functionality, particularly when it comes to combining sounds, so this may be the best chouce.
opensource hardware in nz
Tuesday, May 27, 2008
Came across this site that stocks some really fun looking hardware. Of particular note is stocking only opensource-capable routers, laptops without an OS (no M$ tax!) and single-board computers that use only 5-7 watts that you could really have some fun with. Oh and who could pass up a GSM modem with built-in GPS? Oh, the gadgetry and geekyness.
nicegear.co.nz
printing from Windows virtual machine on linux host
Thursday, April 03, 2008
It's great to be able to use a printer that you have defined in your linux host from within virtualised Windows guest OS (where the printer is either connected directly to your box or over a network). This post assumes you've already setup networking between your guest and host.
Firstly in your printer settings on the host, make sure access hasn't been restricted (open access by default on Ubuntu).
Find the name of the printer that you want to access (ie not the Description which is what appears in network browsing)
Then on the virtual windows machine (for XP):
Choose Add Printer
Select network printer
Select Printer on Internet
For the url, use:
Should be away laughing!
This howto is has more direct CUPS fiddling than is needed for Ubuntu now, but I got key information from there to find out the above.
run a open-source virtual machine with qemu
I use the awesome qemu open-source processor emulator, that lets you run virtual OSs (guests) on a host computer (on my Xubuntu box, in my case). Qemu has the power to have guest os's think they're on a box with entirely different processor types (eg have a PowerPC guest on a x86 box). But what I've found awesome is that with the relatively new Kernel Based Virtual Machine (aka KVM) on linux, with a supported processor, virtualisation goes right down to the cpu level - so it's fast!
If you're on linux and want to check if your processor does support it, use:
managing networks without gnome
Wednesday, March 26, 2008
Having Xubuntu on my machine, gnome's Network Manager is an option, but I try to avoid the bloat of gnome. A great alternative (which many say is better) is wicd. It successfully scans for wireless networks, handles WEP connections, and is the only way I could find to connect to WPA/WPA2 networks. Great product. (howto)
keep grub boot switches between kernel updates
Thursday, March 06, 2008
I have been frustrated on numerous Linux systems where I have to use custom boot switches in Grub, so add them to the relevant entry in /boot/grub/menu.lst, but then a new kernel version (which adds a new boot entry) then doesn't have this new option. This has been simply annoying in the past because I've had to go back in and add the text to the entry. But now I've built a machine for a paying customer and I can't go round every time there's a kernel update!
It turns out the solution is simple:
Between the flags
### BEGIN AUTOMAGIC KERNELS LIST
and
## ## End Default Options ##
are settings that the updater will read in order to create the new boot entries.
The one we want is
While I'm on the topic, another useful setting in this set is
gtk dialogs in linux
Wednesday, December 05, 2007
Bash scripts are fantastic. I could end the post there, but they can be made even better for end users by using one of the simple GUI applications out there that can be run from bash. Here's a great little example (using gtkdialog)that pretties-up the interface for my infrared phone script from this post.
OUTPUT=$(/usr/local/bin/phone-connect $1 | sed -e 's/\(.*\)$/
Beautiful
get connected with infrared device in linux
Then use the following script:
# phone-connect. Copyright Brad Milne, 2007. Search for infrared phone
# and mount it using obexfs if available.
case "$1" in
start)
echo -n "Starting connection to phone..."
#first restart irda-utils if phone not visible
grep nickname /proc/net/irda/discovery > /dev/null
if [ $? -eq 0 ]; then
/etc/init.d/irda-utils restart > /dev/null
fi
obexfs -i /mnt/phone
if [ $? -eq 0 ]; then
PHONE=$(grep nickname /proc/net/irda/discovery | sed -e 's/nickname: //' | cut -d, -f1)
echo "Connected to $PHONE"
else
echo "Connection failed. Does phone have infrared turned on?"
fi
;;
stop)
# 'stop' I haven't yet been able to implement due to restrictions
# on unmounting the fuse device. For now I use 'sudo umount /mnt/phone'
echo -n "Stopping connection to phone..."
/bin/fusermount -u /mnt/phone/
if [ $? -eq 0 ]; then
echo "Done"
else
echo "Failed. Was it connected?"
fi
;;
status)
ifconfig irda0 | grep irda0 > /dev/null
if [ $? -eq 0 ]; then
echo "Infrared device is active"
grep nickname /proc/net/irda/discovery > /dev/null
if [ $? -eq 0 ]; then
PHONE=$(grep nickname /proc/net/irda/discovery | sed -e 's/nickname: //' | cut -d, -f1)
echo "Currently connected to phone"
if [ $(ls -l /mnt/phone | wc -l) -gt 1 ]; then
echo "Phone files accessible at /mnt/phone"
else
echo "Phone not mounted"
fi
else
echo "Not connected to phone"
fi
else
echo "Infrared device not active. Is infrared device plugged in?"
fi
;;
*)
echo "Usage: phone-connect {start|stop|status}"
;;
esac
Then to make it runnable by any user, do a chmod 4711 as described here, on the script itself, obexfs, irda-utils, and on fusermount (which needs to be readable by all users also).
tell apt your proxy settings
Thursday, October 11, 2007
Apt needs to be configured to use a proxy if you're using one (eg if using cntlm). This is done by creating /etc/apt/apt.conf.d/proxy, with content similar to:
Acquire {
Retries "0";
HTTP {
Proxy "http://127.0.0.1:3128";
};
};
Restore Grub
Tuesday, September 18, 2007
How to restore grub, the linux boot manager. Maybe a Windows installation has written over the MBR?
Use a boot disk, such as Knoppix or Ubuntu LiveCD.
1. $ sudo grub
2. grub> find /boot/grub/stage1
(If it fails here, jump to 'preparing root' below)
3. grub> root (hd#,#) (where 'hd#,#' is the result of step 2)
4. grub> setup (hd#)
5. grub> quit
That's it. Done!
-------------------------------------------------------------------------
Preparing root
If step 2 failed above then do these steps first:
A. $ sudo mkdir /mnt/root
B. $ sudo mount /dev/sda1 /mnt/root (where sda1 is your linux partition)
C. $ sudo mount -t proc none /mnt/root/proc
D. $ sudo mount -o bind /dev /mnt/root/dev
E. $ sudo chroot /mnt/root /bin/bash
Now start again from step 2 above.
Full credit to the guys on this thread at ubuntuforums.
Ubuntu (Feisty) Installation on Toshiba Tecra P5
Sunday, September 02, 2007
A place for my notes on the things I've done to get Xubuntu Feisty (Ubuntu is the same procedure) running from scratch on my Toshiba Tecra P5 laptop (PTS53A-02F01D).
Started by trying to boot into the LiveCD. This failed with:
/bin/sh: can't access tty; job control turned off
This message is a symptom of any boot problems - after some figuring out it turned out that there were problems with the cd module.
To fix, restart and on the boot screen, push F6. Edit the boot command ('e'), add:
break=top
(type 'b') to boot
This causes booting to stop early in the boot process (I think) and lets you type in stuff. When the prompt comes up, type:
modprobe piix
exit
This loads the module required to read the cd.
Booting then seems to continue happily but eventually it just freezes with text on the screen. This is because it doesn't recognise the video driver properly. We need to use the xorg default driver for now.
Pushing Ctrl+Alt+F1 takes you to the single user login.
sudo -s
vi /etc/X11/xorg.conf - (This uses the editor 'vi'. If you're not familiar with this, use 'i' to change to edit mode, 'esc' to come back out of edit mode, 'x' to delete a letter (when not in edit mode), ':w' to save (write) the file and ':q' to quit.)
change driver "nv" to "vesa" then exit
/etc/init.d/gdm restart
And Ubuntu should boot!
So play with it, enjoy the LiveCD, and when ready, double click 'install' on the desktop.
At first it couldn't manage to partition the hard drive, and unfortunately killed Windows :(.
-----------------------------------------------------------------------------------------------------------
ONLY DO THIS SECTION IF IT CAN NOT WRITE THE PARTITIONS - THIS WILL KILL WINDOWS.
I managed to get the disk manageable again by running:
mkfs /dev/sda
Now I could partition with:
cfdisk
--------------------------------------------------------------------------------------------------------------------------------
Congratulations, you should now be booting into Ubuntu :)
CD
So, in order to get continued cd support, we need to tell Ubuntu to load piix each time it boots. To do this, open a terminal and type:
sudo vi /etc/modules
To the end of this file, add:
piix
Graphics
I had difficulty setting up the nvidia graphics driver and really wanted the goods. So I found envy. Brilliant. Get it, run it. It downloads and installs the correct nvidia proprietary video drivers.
Sound
Initially I had a hardware problem so couldn't get sound at all which was very frustrating. Now that the hardware's fixed, it's fine. (Antony Williams also has a great script for automatically getting the latest alsa development drivers, should you need them.) Currently, plugging in headphones has no impact (i.e. sound still comes out of speakers and headphones are dead), so will update here when I resolve.
EDIT (Feb 08): I now have headphones sound as of alsa v1.0.16. You can find out your current alsa version by running:
Use the script above to get this version if you don't have it. Issues still outstanding with sound:
--------------------------------------------------------------------------------------------------------------------------------
Upgrade
-Gutsy
Upgraded to gutsy gibbon October 07 without a hitch. Great advances, so highly recommend. Still sticking with the lighter-weight Xubuntu distro, using the xfce window manager. It's nice :)
Wireless
Prior to Gutsy, ndiswrapper was needed to run the Tecra's Intel Corporation PRO/Wireless 4965 AG network card. From gutsy onwards, however, it is supported with the iwl4965 driver (pre-installed). Hurrah!
I still have to use WEP with my router (I know!), so just remember with WEP to use Hex keys, not ASCII and it should work fine.
If you aren't using network manager like I'm not (trying to minimise services), then EDIT:if you boot with wireless switched off, you'll need to do 'sudo ifdown wlan0' then 'sudo ifup wlan0' after switching it on use wicd.
--------------------------------------------------------------------------------------------------------------------------------
Upgrade
-Hardy
Upgrade went without a hitch. Have upgraded successfully from Feisty to Gutsy to Hardy (and have now been using that for 6 months).
exact copies in unix
Thursday, May 03, 2007
So often you want to copy files and folders between directories, but using cp all the file permissions are stuffed up and symlinks just cause problems. Not with good old tar!
cd into source dir
$ tar cf - * | (cd ../targetdir; tar -xf -)
with 'sudo' before each tar if required.
It's too good!