Setting up a Linux home server based on a low cost and low power hardware (Pc Engines Alix) – External USB disk mounted at boot – Part3
The Compact Flash we created is used only for the operating system and the binaries of the applications, we need some space for saving our data.
Most of PC Engines boards, like the Alix 2D2 we are using, have 2 USB 2.0 ports, perfect for managing an external USB disk!
If available a 2.5 inch external disk (for example an used notebook disk with an external case) is preferable because it’s lower power hungry and noisy respect a 3.5 disk.
This new post will describe how to format and mount an external USB disk at each boot to make available all the space we need for our data.
First of all, let’s power on our disk and plug it into a free USB port.
Now we need to identify the special device assigned to the new disk, partition and format: follow instructions in the first part of this howto.
Please remember that you want to work on the newly added USB disk, and not on the CF (hda1)
Fdisk will permanently delete all data contained in the disk, please pay attention.
Once the partition is created you can format it with ext3 filesystem with the following command:
homeserver:~# mkfs.ext3 /dev/sda1
We will use this new ext3 partition to store all downloaded and personal data.
We need a script to mount the disk at each boot of the operating system.
Let’s create a file mount_usb.sh in the directory /etc/init.d:
homeserver:~# touch /etc/init.d/mount_usb.sh
Edit it with "nano" and add the following content:
#! /bin/sh
mount -o defaults /dev/sda1 /data
We need to make this file executable and create the mount point
homeserver:~# chmod 755 /etc/init.d/mount_usb.sh
homeserver:~# mkdir /data
We can now try the script and see if the disk is correctly mounted with the command “df”:
homeserver:~# /etc/init.d/mount_usb.sh
homeserver:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 3.7G 337M 3.2G 10% /
tmpfs 125M 0 125M 0% /lib/init/rw
udev 10M 24K 10M 1% /dev
tmpfs 125M 4.0K 125M 1% /dev/shm
tmpfs 125M 0 125M 0% /tmp
tmpfs 125M 0 125M 0% /var/tmp
tmpfs 125M 24K 125M 1% /var/run
tmpfs 125M 100K 125M 1% /var/log
tmpfs 125M 0 125M 0% /var/lock
/dev/sda1 29G 173M 27G 1% /data
Everything is working correctly, we can now configure the automatic execution of this scripts at each boot.
homeserver:~# update-rc.d -f mount_usb.sh start 89 2 3 4 5 .
Now the mount_usb script is executed at boot time at each runlevel (remember the dot at the end of the command!).
But we also need to unmount the external disk when the system is powered off
Create a file umount_usb.sh always in the directory /etc/init.d:
homeserver:~# touch /etc/init.d/umount_usb.sh
homeserver:~# chmod 755 /etc/init.d/umount_usb.sh
edit it with nano and add the following content:
#! /bin/sh
umount /dev/sda1
Now we need to configure the execution the the umount_usb.sh script when the system powers off.
homeserver:~# update-rc.d -f umount_usb.sh stop 89 0 1 6 .
Now we have a lot of free space for our needs!
No comments yet.
Leave a comment
Categories
- AskoziaPBX (6)
- cisco (1)
- Debian Lenny (6)
- general (1)
- Home server (6)
- Linux (6)
- m0n0wall (1)
- switching (1)
- voice (1)
- Voyage Linux (6)
