Make Space on System Partition

=Introduction= The TeraStation and Linkstation family of systems come with suffient space on their system partition (partition 1) to run the Buffalo provided firmware. However if you have enabled telnet access to your system then you are likely to be installing additional software. In that case you can easily run out of space on the System partition.

The standard partition layout on both LinkStations and TeraStations is the same:


 * Partition 1: System Partition. This holds the linux software that runs the system.  On TeraStation systems the content of this partition is duplicated on each drive as part of a RAID1 type array.   There is normally around 100MB or more free on this partition after the standard Buffalo firmware has been installed.


 * Partition 2: Swap Partition. Used to provide swap space for the Linux system.  This partition is always 128MB in size


 * Partition 3: Data partition: Used to hold the user data files.  On TeraStation systems Partion 3 on each disk can form part of a RAID array. The size of this partition varies according to the disk size, but it occupies most of the rest of the drive.


 * Partition 4: Spare partition: This is a small partition at the end of the drive that is not used. It is surmised that this is used to allow Buffalo to use different makes of drive from differen manufacturers and still hve the first 3 partitions the same size.  Given a nominal capacity quoted by a manufaturer, the actual physical capacity vary slightly in capacity and this can be handled by varying the size of the last partition.

=Larger System Partition=

The most effective way to get more space is to simply start with more allocated to the system partition in the first place. However most people will already have data on their system that they cannot afford to lose, so for them this technique will not be possible.

Those who are in a position to allocate the partition sizes manually by using attaching the disks to another system should know how to handle this, so the details are not covered in this article.

=Moving Files to Share=

Assuming that you cannot easily repartition your system, then you may want to find an alternative way of freeing up some space.

The techique that is recommended is:


 * Create a folder on the share that is to hold the files to be moved.


 * Copy the existing contents of a folder that is to be moved to its new location on the share


 * Remove the original folder


 * Create a symbolic link with the original folder name that point to the new location on the share. This will mean that although the files have been physically moved to the share the path to them will remain what it it used to be so other software and scripts will continue to find the moved files.

There is one important caveat that needs to be borne in mind when selecting what folders are suitable to be moved. This is the fact that you must not move any folder that contains files that will be required before the share has been mounted. This tenfs to mean that you should not move any of the following (although sub-folders of these might be candidates for moving): /etc /bin /sbin /lib /usr/bin /usr/sbin /usr/lib /usr/local/bin /usr/local/lib

The script shown below that can be used to automate much of this. Some point to note are:


 * If you ever reflash your system, then the symbolic links will be broken. You will need to rerun this script to establish them.


 * You would probably find it convenient to set DEV to match the path to the share on your system. This is not critical as you can set it at runtime.


 * At the moment LOCAL is set to the folder within the share that hold the folders/files moved off the system partition. If you would prefer another name then change this.


 * You may want to customsie the list of folders that are to be moved.  The CheckLink line identify the folders that are to be moved.   The first parameter is the name to be given to the folder created under _local on the share, while the second one is the actual full path to the folder on the system partition.

# # #	11:32, 25 March 2010 (UTC)11:32, 25 March 2010 (UTC)Itimpi 11:32, 25 March 2010 (UTC) DEV=/mnt/array1/share LOCAL=_local checkLink { 	if [ ! -d $DEV/$LOCAL/$1 ] then mkdir $DEV/$LOCAL/$1 echo "[INFO] directory '$DEV/$LOCAL/$1' created" fi chmod 755 $DEV/$LOCAL/$1 if [ -h $2 ] then echo "[INFO] $2 already set as symbolic link" else # See if hard link exists if [ -d $2 ] then echo "[INFO] Moving files from $2 to $DEV/$LOCAL/$1" cp -rp $2/* $DEV/$LOCAL/$1 rm -fr $2 fi ln -s $DEV/$LOCAL/$1 $2 echo "[INFO] $2 linked to $DEV/$LOCAL/$1" fi chmod 755 $DEV/$LOCAL/$1 chmod 755 $2 } echo "" echo "[INFO] --- Starting MakeSpace script -" echo "[INFO] The purpose of this script is to free up space on the system partition" echo "[INFO] by moving files not critical to the startup phase to the share. After" echo "[INFO] the files have been moved, then symbolic links are set up so that the" echo "[INFO] old paths remain valid." echo "" echo "[INFO] Current file system usage is:" df echo "[INFO] Please confirm you want to proceed [y/n]: " read userreply if [ "$userreply" != "y" ] then echo "[INFO] --- Aborted MakeSpace script -" exit 0 fi echo "[INFO] Please provide following settings (or press ENTER to accept default)" echo "[INFO] Path to share [$DEV]: " read userreply if [ "$userreply" != "" ] then DEV=$userreply fi if [ ! -d "$DEV" ] then echo "[ERROR] Specified share does not exist" echo "[INFO] --- Aborted MakeSpace script -" fi echo "[INFO] Folder to hold moved folders [$LOCAL]: " read userreply if [ "$userreply" != "" ] then LOCAL=$userreply fi if [ ! -d $DEV/$LOCAL ] then mkdir $1 echo "[INFO] directory '$DEV/$LOCAL' created" fi chmod 755 $DEV/$LOCAL checkLink "opt" "/opt" checkLink "www" "/www" checkLink "include" "/usr/local/include" checkLink "man" "/usr/local/man" checkLink "mediaserver" "/usr/local/mediaserver" checkLink "PCast" "/usr/local/PCast" checkLink "theme", "/etc/pcast/theme" checkLink "theme_us", "/etc/pcast/theme_us" checkLink "samba" "/usr/local/samba" checkLink "samba2" "/usr/local/samba2" checkLink "samba3" "/usr/local/samba3" checkLink "share" "/usr/local/share" checkLink "src" "/usr/local/src" if [ ! -h ${DEV}/_root ] then echo "" echo "[INFO] It can be convenient to have a way of looking at the" echo "[INFO] linux system partition contents from Windows Explorer." echo "[INFO] If you want a link called '_root' can be set up" echo "[INFO] under your share to support this." echo "" echo "[INFO] Set up link to system partition [y/n]: " read userreply if [ "$userreply" = "" ] then ln -s / $DEV/_root echo "[INFO] $DEV/_root linked to '/'" fi fi echo "" echo "[INFO] New file system usage is:" df echo "[INFO] --- Completed MakeSpace script -" exit 0
 * 1) !/bin/sh
 * 2) 	MakeSpace.sh
 * 1)       Script link folders from system partition to share area.
 * 2) 	The purpose is to make space on the system partition.
 * 3) 	Used primarily on development system, although valid on all systems
 * 1) 	CHANGE HISTORY
 * 1) 	14 Aug 2009   itimpi	Added Error checking
 * 2) 	22 Dec 2009   itimpi   Added checks and progress messages
 * 3) 	24 Mar 2010   itimpi	Added rename/copying of data if hard link exists
 * 4) 				Information messages added to get ready for general use
 * 1) Check that soft links exists.
 * 2) If necessary files are moved to create space
 * 3) $1	Location on share for real target relative to $DEV/$LOCAL
 * 4) $2	Location in normal file system for symbolic link
 * 1) Get folder names to be used
 * 1) *** Not sure that library should use symbolic link ***
 * 2) *** (May be required before share mounted)         ***
 * 3) checkLink "lib" "/usr/local/lib"
 * 1) Also set up special link for navigating to linux system via share