[plug] Disk space ...

Bernd Felsche bernie at innovative.iinet.net.au
Mon May 22 09:31:56 WST 2006


"Tomasz Grzegurzko" <tomasz89 at gmail.com> writes:
>On 5/21/06, Dave Dartnall <darts at dialix.com.au> wrote:
>> Here is the output from df on my system:

>> Filesystem            Size    Used     Avail    Use%  Mounted on
>> /dev/hdb6             2.9G    255M    2.5G    10%     /
>> /dev/hdb1             479M   12M      443M  3%        /boot
>> /dev/hdb9              13G     5.5G     7.3G    43%     /home
>> /dev/hdb8             2.9G    2.6G     157M   95%     /usr
>> /dev/hdb7             7.7G    6.4G     986M   87%      /var

/var probably has a *LOT* of crud accummulated unless you're
maintaining mailboxes with IMAP; or you have a humungous newsfeed...
I won't even try to imagine what somebody would do with a huge squid
proxy cache...

Clean up old log files (in /var/log) before you do anything else.

>> Obviously dumb initial partitioning - and now I've run out of
>> room on /usr and /var.

I'm always running out of space on /usr ... but it's not my fault
that so many applications install there instead of /opt where they
belong!!

>> I read somewhere that it's possible to increase the capacity of a
>> partition by initialising (touching?) a file elsewhere and
>> somehow linking the full directory to it. There's spare room on
>> /home and root that maybe could be used? How is this done - if at
>> all?

The only partitions that you can increase in size are logical
volumes.

>> Preferably though, I'd like to install a new hard disk and
>> transfer the existing system with all it's settings and links etc
>> to larger partitions. Is this possible or is it necessary to
>> reinstall everything?  And if possible how is it done?

>> Let's assume that I can install the new drive, that the system
>> will recognise it and that I can partition it using Mandriva's
>> utility. What then...

>Well you could make new mount points elsewhere and mount levels
>underneath from that. An example will explain better:
>/home/tomasz <-- this guy is greedy, the rest of /home is 100MB, but
>/home/tomasz is 1000MB so I want to move his to.. /usr for example,
>which is a different partition (with 20000MB free).
># mkdir /usr/tomasz
># cd /usr/tomasz
># cp -a /home/tomasz .
>(the -a flag will preserve all attributes, like sym links, file modes,
>etc etc, even a /dev file system will copy okay).
># rm -rf /home/tomasz
># ln -s /usr/tomasz /home/tomasz
>There. My home directory is in another partition, and I get the space
>I want now. From my perspective, I'm still at /home/tomasz too, which
>is nice.

Unfortunately, moving stuff from /usr and /var around "safely" is a
little more involved.

If you have a new hard drive installed, then partition it according
to your real needs. Don't assign raw partitions to filesystems if
you want to minimise the inconvenience of shuffling things around.
Assign the whole drive space to LVM (logical volume management) and
create logical volumes for a new /usr and /var in a new volume
group (which is often vg00 by default, but you can change its name).
Logical volumes are just like partitions; but they can span more
than one disc. The logical volumes can also be named as required...
in this case you'd make something like /dev/vg/usr and /dev/vg/var

Make filesystems on the logical volumes; Reiserfs seems to work
quite well for /var and /usr; and it's extendable so you can add
space when you extend the logical volume on which it's built.
Don't despair if Reiserfs isn't available on your system.

Don't mount the new filesystems as /usr and /var yet...
It's easiest if you set them up to be mounted as something like
/new/usr and /new/var respectively.

The contents of /usr and /var can only be moved safely with the
system in single-user mode. So so a shutdown... you should be
prompted for the root password before you get a shell prompt.

It's saver to copy than to move the files to the new partition (and
you will have a "backup" on the old partitions.

# cd /usr
# cp -a * /new/usr

That will take a while....

# cd /var
# cp -a * /new/var

Which'll also take a fair while....

# mkdir /old

Then edit the /etc/fstab to change the mount points for /dev/hdb7,
/dev/hdb8 to /old/var and /old/usr respectively; and change the ones
for /dev/vg/usr and /dev/vg00/var to /usr and /var respectively.

Unmount all filesystems

# umount -a

This should leave only the root filesystem mounted.

Mount the filesystems in their new places

# mount -a

If you run df, you should see /dev/vg/usr mounted as /usr and
/dev/vg/var mounted as /var

You can then return the system to multi-user mode using

# telinit 5

or 

# telinit 3

depending on GUI/non-gooey mode preference.
-- 
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ /  ASCII ribbon campaign | "Laws do not persuade just because
 X   against HTML mail     |  they threaten."
/ \  and postings          | Lucius Annaeus Seneca, c. 4BC - 65AD.




More information about the plug mailing list