Showing posts with label slax. Show all posts
Showing posts with label slax. Show all posts
0

All the Best Linux Cheat Sheets

1. Linux Command Line

2. Linux Security

3. Linux Administration

4. Gnome/KDE

5. sed/awk/vim and other tools

6. Distro Specific

7. Everything Else

  • Online Man Pages - The ultimate cheat sheet repository. Also use the ‘man’ command.

0

can't open or create /var/run/crond.pid: No space left on device

This error message told us that there is no disk space left on /var

When we run "df -h" on the system we get:

[root@A5AFETTASB pats]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p3     3.0G  1.7G  1.2G  59% /
/dev/cciss/c0d0p1      99M   15M   80M  16% /boot
/dev/cciss/c0d0p6      24G  5.9G   17G  27% /opt
none                  1.3G     0  1.3G   0% /dev/shm
/dev/cciss/c0d0p5     2.0G  1.1G  790M  59% /var


Seems like only 59% disk space is used but that is not true. As the difference here is MB of space versus the almighty inode. So if we try using "df -i", we get:

[root@A5AFETTASB pats]# df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/cciss/c0d0p3     393600   95644  297956   25% /
/dev/cciss/c0d0p1      26104      40   26064    1% /boot
/dev/cciss/c0d0p6    3123232   12620 3110612    1% /opt
none                  322278       1  322277    1% /dev/shm
/dev/cciss/c0d0p5     262144  262144       0  100% /var


Further investigation showed, there are huge number of files created under /var/spool/clientmqueue that caused the problem:

[root@A5AFETTASB pats]# du -h /var/spool/*
4.0K    /var/spool/at/spool
8.0K    /var/spool/at
1.1G    /var/spool/clientmqueue
12K     /var/spool/cron
4.0K    /var/spool/cups/tmp
8.0K    /var/spool/cups
4.0K    /var/spool/lpd
8.0K    /var/spool/mail
4.0K    /var/spool/mqueue
4.0K    /var/spool/repackage
4.0K    /var/spool/rwho
4.0K    /var/spool/samba
4.0K    /var/spool/up2date
4.0K    /var/spool/vbox


If you don't care about the content you can simply delete the files, but you should ask yourself why you have tons of messages in that directory.


# rm -rf /var/spool/cilentmqueue
# mkdir /var/spool/cilentmqueue
# chown smmsp:smmsp /var/spool/cilentmqueue
 
If the emails are the result of crontab, below will explain how to disable it:
http://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/


In this case the problem caused by sendmail. If you don't use it we can just disable the service


# svcs sendmail
STATE          STIME    FMRI
disabled       Sep_15   svc:/network/smtp:sendmail

Or you should probably enable it just to make sure that at and cron job output is delivered.  You can configure sendmail such that it doesn't accept remote SMTP connections.

0

How to block/unblock an IP from Linux?


In order to block an IP on your Linux server you need to use iptables tools (administration tool for IPv4 packet filtering and NAT) and netfilter firewall. First you need to log into shell as root user. To block an IP address you need to type the iptables command as follows:

Syntax to block an IP address under Linux

iptables -A INPUT -s IP-ADDRESS -j DROP
 
Replace IP-ADDRESS with your actual IP address. For example, if you wish to block an ip address 65.55.44.100 for whatever reason then type the command as follows:

# iptables -A INPUT -s 65.55.44.100 -j DROP

If you have IP tables firewall script, add the above rule to your script.
If you just want to block access to one port from an ip 65.55.44.100 to port 25 then type command:

# iptables -A INPUT -s 65.55.44.100 -p tcp --destination-port 25 -j DROP

The above rule will drop all packets coming from IP 65.55.44.100 to port mail server port 25.

CentOS / RHEL / Fedora Block An IP And Save It To Config File

Type the following two command:
# iptables -A INPUT -s 65.55.44.100 -j DROP
# service iptables save

How Do I Unblock An IP Address?

Use the following syntax (the -d options deletes the rule from table):
# iptables -D INPUT -s xx.xxx.xx.xx -j DROP
# iptables -D INPUT -s 65.55.44.100 -j DROP
# service iptables save

0

How to mount an USB drive maually so everyone can read/write to it?

Not only the umask=1000 but also users (plural) for more than one user and rw (read/write).

Read the man pages for umask, mount, fstab and this Quick and Dirty Guide to Linux File Permissions

In /etc/fstab:
Code:
/dev/sda1        /mnt/flash       vfat        users,umask=1000,rw,noauto 0   0

Then run:
mount /mnt/flash

0

Howto create Loop Device on Linux

This mini howto explain how to create more loop device on your operating system.You need to create more loop device in some case like encrypted file system or HVM xen virtualization.  By default there are 7 devices available, named /dev/loop0 through to /dev/loop7.

INFORMATIONS
You can find the loop device like that :


1# ls -al /dev/loop*
2brw-r----- 1 root disk 7, 0 Mar 19 09:34 /dev/loop0
3brw-r----- 1 root disk 7, 1 Mar 19 09:34 /dev/loop1
4brw-r----- 1 root disk 7, 2 Mar 19 09:34 /dev/loop2
5brw-r----- 1 root disk 7, 3 Mar 19 09:34 /dev/loop3
6brw-r----- 1 root disk 7, 4 Mar 19 09:34 /dev/loop4
7brw-r----- 1 root disk 7, 5 Mar 19 09:34 /dev/loop5
8brw-r----- 1 root disk 7, 6 Mar 19 09:34 /dev/loop6
9brw-r----- 1 root disk 7, 7 Mar 19 09:34 /dev/loop7
The creation of the loop device is very simple but you have 2 options for this creation one is without reboot and the other one is with a reboot.


HOT CREATION
Creation of loop8 :

1# mknod -m640 /dev/loop8 b 7 8
2-m640 define the permission of the device
3/dev/loop8 define the name of the device
4b for the creation of the special block device
57 8 the number 7 AND 8 define the MAJOR AND the MINOR
Check if the loop is created

1# ls -l /dev/loop8
2brw-r----- 1 root root 7, 8 Oct 3 14:54 /dev/loop8
Now you have the applied the good owner on this device

1#chown root:disk /dev/loop8
Now you have to change the module limitation and reboot your system.
STANDARD CREATION
You have to modify this file /etc/udev/makedev.d/50-udev.nodes

01#vim /etc/udev/makedev.d/50-udev.nodes
02loop0
03loop1
04loop2
05loop3
06loop4
07loop5
08loop6
09loop7
10loop8
11parport0
12parport1
13parport2
14parport3
15net/tun
16ppp
17console
18null
19zero
Now you have to change the module limitation and reboot your system.

MODULE LIMITATION
In the kernel, you have to allow more creation of loop device.
There is an absolute maximum of 256 devices limited in the kernel. The default limit is set to 8.

01# modinfo loop
02filename: /lib/modules/2.6.18-53.1.14.el5.centos.plusxen/kernel/drivers/block/loop.ko
03alias: block-major-7-*
04license: GPL
05srcversion: 82DB6DB3DABF3B945D6394D
06depends:
07vermagic: 2.6.18-53.1.14.el5.centos.plusxen SMP mod_unload gcc-4.1
08parm: max_loop:Maximum number of loop devices (1-256) (int)
09module_sig: 883f35047d15787f0a982eee333b2d8112f51f09f68f09b79223a34983b3aef66820c08
10
11cc6e8cd3709f6d7c56171e5a579ee1ca2ca56349c56b983a7c46
Now you have to change this value with the modprobe.conf file.

1#vim /etc/modprobe.conf
2 ...
3options loop max_loop=64
4...
TIPS & COMMAND
The commande line losetup is used for set up and control loop device.

1# losetup
2usage:
3losetup loop_device # give info
4losetup -d loop_device # delete
5losetup -f # find unused
6losetup -a # list all used
7losetup -r # read-only loop
8losetup [-e encryption] [-o offset] [-r] {-f|loop_device} file # setup

0

Thin client + Slax + LCD TV= Media Center



I have a 1.5TB external hard drive(with its own power adapter) and three computers at home, it was not convenient if I want to get the files or save them to the external storage. So I planned to make my external hard drive to be shared in the home network:


There are at least three ways to set up this:
1) NAS drive;
2) Router with USB support;
3) File server;


I chose option 3 because I also need a light-weight computer to connect to my LCD TV, ideally can play movies.

After a long time googling, I bought HP Thin Client 5710 from the internet. Here are the specs:

Transmeta Efficeon 1.2GHz
256 MB Flash memory,
256 MB DDR SDRAM (upgraded to 512MB)
(24 MB of system RAM is reserved for processor usage)
ATI® Radeon 7000M
10/100 BaseT Fast Ethernet,

4 USB 2.0 ports, 1 serial, 1 parallel, 1 PS/2,
Sound: Internal amplified speaker, full 16-bit stereo, 44 kHz sample rate
Weight: 1.4Kg
Operating Temperature Range 0 to 40° C

The advantage of using this Thin client for this Job rather than a full size PC are its size (small and unobtrusive), tiny power consumption and the fact that the unit is totally silent ( apart from its Audio Output ).
 
I uses Ubuntu at work, so I would like to install one of the Ubuntu edition or light weight Debian. Because the internal flash memory is too small(256MB) and it already has a Genuine Windows XP Embedded SP2 installed which I don't want it to be ruined. So I will need to install Linux to the USB flash drive and boot the system from there(This needs USB2.0 support, if your Thin Client only has USB1.1, don't try it).

I tested the following Linux editions:
1) Ubuntu 10.10 (too slow, not usable);
2) Xubuntu 10.10 (better but still slow);
3) LXDE (fast, but can't play movie well);
4) Puppy Linux (fast, good);
5) Slax (fast, good);

I picked Slax as my Thin Client OS, I likes its module management system.




The basic Slax version includes the following modules:
001-core.lzm
002-xorg.lzm
003-desktop.lzm
004-kdesktop.lzm
005-koffice.lzm
006-devel.lzm
007-firefox.lzm

To build a file server that the files can be used by the Windows computer, you will need to install samba-3.4.4.lzm. After set up, all my computer's can access the external hard drive now through the wireless network, even play movies.

For the Thin Client itself with Slax, kplayer is enough to play AVI movies well without video latency issue, you are also able to load subtitles if you needed. But by default it does not support some video format like rm,rmvb etc. Install codecs-essential-20071007.lzm will load most of common codec in the system to allow you to watch different formats of movies.

There were still some problems after using Slax USB version, here are the solutions:

1)
The major problem I had from Slax was KDE mime type error, if you have this problem you will not be able to open any drives or folders as it will prompt an "open with" dialog box.

The mime type error is caused by a PosixOVL error. If you're running Slax from a FAT partition, it can't save file permissions the way it'd do on a Posix file system like EXT2 or XFS. PosixOVL is supposed to compensate for that by saving the permissions in individual files, but it's still quite buggy at this point.

The obvious solution is to not save your changes to a FAT partition.  The default Slax installation package already include a file called slaxsave.zip, unzip one of the files inside like save1024.zip(include a 1GB size slaxsave.dat file), this file represent a XFS-partition-image. Please see ReadMe file or click here for more information.

2)
512MB memory for this Thin Client is not enough sometimes, so you need to create a swap "partition" for the system. The "partition" here doesn't have to be a real physical one, we can make a swap file as a virtural swap partition. The steps are:

1 dd if=/dev/zero of=/mnt/hdc1/slax/swapfile bs=1M count=1024
2 mkswap /mnt/hdc1/slax/swapfile
3 swapon /mnt/hdc1/slax/swapfile
4 (adding this text in /etc/fstab file )
/mnt/hdc1/slax/swapfile none swap sw 0 0

(reference: how can create swap(virtual memory)in-live-slax)

0

Slax: solution to read only external hard drivers


When Slax auto detect External hard drives or USB keys but it permission defaulted to read only. Slax will not allow you to change the file permission. You will not be able to copy important files to the external hard drive.

Following steps will fix the permission problem.

Open Slax Konsole (Terminal Control) and type the following commands in

umount /mnt/sdb1
mount -t ntfs-3g /dev/sdb1 /mnt/sdb1 -o force