Tuesday, August 26, 2014

move /var to a new partition or directory


http://blog.oshim.net/2011/10/how-to-move-var-folder-to-new-partition.html

http://serverfault.com/questions/344014/proper-way-to-remap-a-partition-to-a-new-disk



Tuesday, February 11, 2014

Find top 10 biggest files/directories from Linux shell

When disk is about full and I have to delete some files, I want to find the biggest file or directory and then probably delete it.

Following commands find the largest directories/files in current directory:
for i in $(ls); do du -s -h $i; done | sort -h  -r | head -n 10
 Sample output:
for i in $(ls); do du -s -h $i; done | sort -h  -r | head -n 10
4.9G    lib
231M    cache
23M     log
2.3M    backups
116K    spool
4.0K    tmp
4.0K    opt
4.0K    metrics
4.0K    mail
4.0K    local

Another similar command which is less helpful due to some duplicate info:

du -a -h /var | sort -h -r | head -n 10
Sample output:
# du -a -h /var | sort -h -r | head -n 10
5.1G    /var
4.9G    /var/lib
4.6G    /var/lib/libvirt/images/vn1.img
4.6G    /var/lib/libvirt/images
4.6G    /var/lib/libvirt
263M    /var/lib/apt/lists
263M    /var/lib/apt
231M    /var/cache
112M    /var/cache/pbuilder/aptcache
112M    /var/cache/pbuilder 

Note, the 2nd command is copied from here: http://www.cyberciti.biz/faq/how-do-i-find-the-largest-filesdirectories-on-a-linuxunixbsd-filesystem/

But I put -h  for both du and sort commands so that the result is easier to read (Otherwise, you will probably get a very long sequences of numbers). When  using -h, both du and sort need to be consistent, otherwise, it will give wrong output, like following:

# du -a -h /var | sort -r | head -n 10
988K    /var/cache/pbuilder/aptcache/libssl1.0.0_1.0.1-4ubuntu3_amd64.deb
976K    /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_raring-security_main_binary-amd64_Packages
96M     /var/cache/apt-xapian-index/index.1  ### should move up, and vn1.img is missing.

Tuesday, November 19, 2013

fix a vncserver issue on Scientific Linux 6.1


I tried to connect a vncserver from a Windows 7 machine to a SL 6.1 server. But it gave following error:

Failed To Connect: Connection Refused (10061)

After checked lots of things, I finally found that following command caused the problem:

sudo service vncserver start

(btw: I was logined in as a normal user, not root.)

The output of this command looks good, but you will never connect the vnc server.

The correct commands is to start vncserver as the login user, just type:

vncserver


Tuesday, November 12, 2013

pass QEMU monitor commands to virsh


Virsh supports qemu-monitor-command to pass any QEMU monitor commands. Following is an example:

virsh # qemu-monitor-command 45 --hmp info cpus
* CPU #0: pc=0xffffffff8144d27a thread_id=19994

"45" is the domainID
"--hmp" tells the virsh to use human readable mode
"info cpus" are QEMU monitor commands, you can use any supported by QEMU.