Archive for the ‘DEBIAN/UBUNTU’ Category

How To Expand Usable Storage Space In Ubuntu

October 31st, 2010 No comments


1. Using LVM

For partitions created on Logical Volume Manager (LVM) (Linux feature) at install time, they can be resized easily by concatenating extents onto them or truncating extents from them over multiple storage devices without major system reconfiguration.

Caution: Deployment of the current LVM system may degrade guarantee against filesystem corruption offered by journaled filesystems such as ext3fs unless their system performance is sacrificed by disabling write cache of hard disk.

Run a df from terminal.

$ df
Filesystem	1K-blocks	Used	Available	Use%	Mounted on
/dev/mapper/VolGroup00-LogVol00	7935392	6773500	752292	91%	/
/dev/sda5	497829	20904	451223	5%	/boot
tmpfs	1037084	0	1037084	0%	/dev/shm
/dev/mapper/VolGroup00-LogVol01	70877776	14988144	51045372	23%	/home

We have two partitions here, / partition is about 8 Gb and the /home partition is about 71 Gb. What we are trying to do is to expand the / partition to 10 Gb by taking free space from /home.

For /home you do:

# sudo umount /home
# sudo e2fsck -f /dev/VolGroup00/LogVol01
# resize2fs /dev/VolGroup00/LogVol01 69G
# lvreduce -L-2G /dev/VolGroup00/LogVol01
# mount /home

For / you do:

# lvextend -L+2G /dev/VolGroup00/LogVol00
# resize2fs /dev/VolGroup00/LogVol00

e2fsck and resize2fs belong to package e2fsprogs.

After resizing you will get

$ df
Filesystem	1K-blocks	Used	Available	Use%	Mounted on
/dev/mapper/VolGroup00-LogVol00	9299624	6779304	2043564	77%	/
/dev/sda5	497829	20904	451223	5%	/boot
tmpfs	1037084	0	1037084	0%	/dev/shm
/dev/mapper/VolGroup00-LogVol01	68877776	14999888	51033628	23%	/home

Read the lvm-howto for detailed infotmation.

2. Mounting another partition

If you have an empty partition (e.g., “/dev/sdx”), you can format it with mkfs.ext3(1) and mount(8) it to a directory where you need more space. (You need to copy original data contents.)

$ sudo mv work-dir old-dir
$ sudo mkfs.ext3 /dev/sdx
$ sudo mount -t ext3 /dev/sdx work-dir
$ sudo cp -a old-dir/* work-dir
$ sudo rm -rf old-dir

3. Using symlink

This might be the easiest way. If you have an empty directory (e.g., “/path/to/emp-dir”) in another partition with usable space, you can create a symlink to the directory with ln(8).

$ sudo mv work-dir old-dir
$ sudo mkdir -p /path/to/emp-dir
$ sudo ln -sf /path/to/emp-dir work-dir
$ sudo cp -a old-dir/* work-dir
$ sudo rm -rf old-dir

4. Using aufs

If you have usable space in another partition (e.g., “/path/to/”), you can create a directory in it and stack that on to a directory where you need space with aufs. With aufs you can unite several directories into a single virtual filesystem.

$ sudo mv work-dir old-dir
$ sudo mkdir work-dir
$ sudo mkdir -p /path/to/emp-dir
$ sudo mount -t aufs -o br:/path/to/emp-dir:old-dir none work-dir

Recording and copying system configuration in Debian/Ubuntu

July 9th, 2010 1 comment

debianYou can make a local copy of the package and debconf selection states using dpkg and debconf-get-selections command. The debconf-get-selections command output the content of current debconf database.

You will require the “debconf-utils” packages to do that.

Install debconf-utils:

$ sudo aptitude install debconf-utils
$ sudo dpkg --get-selections '*' > selection.dpkg
$ sudo debconf-get-selections    > selection.debconf

Here, “*” makes “selection.dpkg” to include package entries for “purge” too.

You can transfer these 2 files to another computer, and install there with the following.

$ sudo dselect update
$ sudo debconf-set-selections < myselection.debconf
$ sudo dpkg --set-selections  < myselection.dpkg
$ sudo apt-get -u dselect-upgrade    # or dselect install

If you are thinking about managing many servers in a cluster with practically the same configuration, you should consider to use specialized package such as fai to manage the whole system.

Using The Debian Alternatives System

April 28th, 2010 No comments

debianThere are several cases where two packages provide two different versions of a program, both of which provide the same core functionality. Users might prefer one over another out of habit, or because the user interface of one package is somehow more pleasing than the interface of another. Other users on the same system might make a different choice.

For example, there might exist two different versions of newsreaders on a system. Which program is invoked is determined by a link pointing from a file with the virtual package name /etc/alternatives/vim to the selected file, e.g., /usr/bin/vim.gtk.

The Debian system has mechanism to install somewhat overlapping programs peacefully using update-alternatives(8). The Perl script update-alternatives provides a way of ensuring that all the files associated with a specified package are selected as a system default.

For example, you can make the vi command select to run vim while installing both vim and nvi packages.

The Debian alternatives system keeps its selection as symlinks in “/etc/alternatives/“. The selection process uses corresponding file in “/var/lib/dpkg/alternatives/“. The “/etc/alternatives” defines default applications for the Debian system – such as, the default application to handle editor, to browse the web etc.

For example, to check what executables provide `vim’, run:

$ sudo update-alternatives --display vim
vim - status is auto.
link currently points to /usr/bin/vim.gtk
/usr/bin/vim.tiny - priority 10
/usr/bin/vim.basic - priority 30
/usr/bin/vim.gtk - priority 50
Current `best' version is /usr/bin/vim.gtk.

or use the ls command

$ ls -l $(type -p vim)
lrwxrwxrwx 1 root root 21 2008-09-27 13:10 /usr/bin/vim -> /etc/alternatives/vim
$ ls -l /etc/alternatives/vim
lrwxrwxrwx 1 root root 16 2010-01-23 14:06 /etc/alternatives/vim -> /usr/bin/vim.gtk

If you want to change it, run:

$ sudo update-alternatives --config vim
There are 3 alternatives which provide `vim'.
  Selection    Alternative
          1    /usr/bin/vim.tiny
          2    /usr/bin/vim.basic
*+        3    /usr/bin/vim.gtk
Press enter to keep the default[*], or type selection number:

And follow the instructions on the screen (basically, press the number next to the entry you’d like better).

To change the default web browser run:

$ sudo update-alternatives --config x-www-browser
There are 3 alternatives which provide `x-www-browser'.
  Selection    Alternative
*         1    /usr/bin/iceweasel
 +        2    /usr/bin/epiphany-gecko
          3    /usr/bin/google-chrome
Press enter to keep the default[*], or type selection number:

To change the default editor run:

$ sudo update-alternatives --config editor

There is also a GTK program for doing this named galternatives.

Install galternatives:

$ sudo apt-get install galternatives