Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jun 052011
 

Create a swap partition using LVM

Answer:

To create a swap partition using LVM, you just need a few commands!

1. Create a 1G swap partition

# lvcreate -L 1G -n /dev/vg0/swap0

2. Set up a Linux swap partition

# mkswap /dev/vg0/swap0

3. Enable it

# swapon -s /dev/vg0/swap0

You might also want to put the settings in the /etc/fstab, so it will be mounted automatically when your system boot next time.

# sudo vi /etc/fstab

/dev/vg0/swap0       none            swap     sw              0       0

Save and restart your system to test if it is working when system reboot.

Jun 032011
 

How to echo string to standard error (stderr)?

Answer:

To echo string to the standard error (stderr), rather than the standard output (stdout), you can define the following function in your shell (put in your ~/.bashrc file)

# function echo2() { echo "$@" 1>&2; }

Then you can execute the command like:

# echo2 test

May 262011
 

Revert the effect of an earlier changeset in Mercurial

Answer:

In Mercurial, if you want to revert the effect of an earlier changeset, even the changes have been pushed to remote, it is still possible with the hg backout command.

1. Find the revision you want to backout using hg log
# hg log

2. Assume you want to backout to the revision 99, then you can
# hg backout -r 99