|
|
![]() |
Web Sequence Diagrams
Create sequence diagrams in seconds for free.http://www.websequencediagrams.com Why was this ad not blocked? |
Firefox 3 has a hard-to-fix bug that causes linux to write to disk every time you visit a write page. But it doesn't just write Firefox stuff -- it causes your entire system to dump all changes to disk. Unfortunately, your USB key might only have a 6 MB/s write speed, causing everything to freeze up.
It's kind of like putting magnets under your pillow to improve health. Maybe it's having an effect, but I can't tell. I install it anyway:
sudo aptitude install preload
On solid state storage, space is expensive. Ubuntu uses a huge amount of space will all the programs it installs. The /usr folder contains your programs, and it is usually 1.8 GB. Using squashfs, it can be compressed to 0.7 GB. Since read speeds are so slow, you can actually gain performance because there is less data to read. I've adapted these instructions from here.
Install squashfs and unionfs:
sudo apt-get install squashfs-tools unionfs-tools
Add the following lines to /etc/modules:
unionfs squashfs loop
Remove apparmor. Otherwise, the cups print server will stop working:
sudo apt-get purge apparmor
Make space for the filesystem:
sudo mkdir -p /.filesystems/usr/overlayCompress your filesystem:
sudo mksquashfs /usr /.filesystems/usr/usr.sqfsAdd these lines to /etc/fstab:
/.filesystems/usr/usr.sqfs /usr squashfs ro,loop,nodev 0 0 unionfs /usr unionfs nodev,noatime,dirs=/.filesystems/usr/overlay=rw:/usr=ro 0 0Switch to runlevel 1. (Ubuntu will close all open programs, then prompt you what to do. Choose opening a root shell)
sudo init 1
Move aside the old /usr directory and create a new mount point:
mv /usr /usr.old mkdir usr
Test whether you previously edited fstab successfully by typing:
mount -a
If you get error messages or your /usr directory shows up empty, either fix your fstab or undo the changes before continuing.
Now reboot and make sure it all works:
reboot
If it works, remove the /usr.old directory to reclaim the space.
This tip can also lead to data loss. If you do it, you will have to always shut down your computer properly from now on, because unexpected power failures will lead to data loss.
Linux usually ensures that all changes are written to disk every few seconds. Since disk writes are so slow, you can change your system to keep things in memory longer. All changes will be written to memory, and the excruciatingly slow writes to happen in the background while you continue working. This has an instant, noticeable effect, but it can lead to data loss.
Add these lines to /etc/sysctl.conf, and reboot.
vm.swappiness = 0 vm.dirty_background_ratio = 20 vm.dirty_expire_centisecs = 0 vm.dirty_ratio = 80 vm.dirty_writeback_centisecs = 0
The problem: using this tip means that your system stops writing changes to disk until you shut down or type "sync" at a command line. If your system loses power unexpectedly, you will get bad blocks. I did. You can limit the amount of data loss in the event of a power failure to one minute by setting vm.dirty_writeback_centisecs = 6000.
A side effect is that shutting down your computer will may take several minutes where it appears to be doing nothing. Don't cut the power until it's done, because it is busy writing all those changes to disk.
Want more programming tech talk?
Follow on Google Buzz
Subscribe to posts
This actually makes disk read faster. Booting is quicker.
If a lot of new packages are installed updated, one can repeat TIP3, starting with "Make space for the filesystem" but make make /overlay1 and usr1.sqfs, edit fstab accordingly, go down to init 1, sudo mount -a: no errors? Reboot and delete usr.sqfs and /overlay
I also did the "dirty" stuff with sysctl.conf: This makes a HUGE difference in speed. I assume it is a little dangerous, but on a laptop, a power failure is not too much of an issue unless you don't let power management shut the computer down when the battery gets really low.
THANKS!
Post comment