2013-01-03, 21:45
(2013-01-03, 01:39)cirkator Wrote: I want to set it up in a similar way. Can you tell me how to mount the external hdd as /var.
WARNINIG: The following steps will completely erase all files/folders on the external hdd
I have installed debian wheezy on my PI so these commands may need to change slightly if you are using a different linux distribution.
1) ssh into your PI. If your using Windows you can use putty.
2) Connect the drive up to the pi and switch it on.
3) Type the following:
Code:
sudo fdisk -l
You may be asked to provide the password for your PI user account. Just type it in and press ENTER. This command should show you all drives connected to the PI. If you only have one usb drive connected it should appear as /dev/sda. DO NOT touch anything starting with /dev/mmcblk0 as this is your sd card.
4) load fdisk
Code:
sudo fdisk /dev/sda
5) If you had previously used this hard disk then you need to remove the existing partitions. To see what's already on the disk press 'p' at the command prompt
The above command on my PI shows the following for /dev/sda
Disk /dev/sda: 500.1 GB, 500106780160 bytes
48 heads, 29 sectors/track, 701703 cylinders, total 976771055 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009a57a
Device Boot Start End Blocks Id System
/dev/sda1 2048 976771054 488384503+ 83 Linux
6) To delete a partition press 'd' and then the number of the partition. You need to do this for all partitions on the drive. If you need to see what partitions are left :
Code:
Command (m for help): p
7) Create a new partition:
Code:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-xxx, default 1):<RETURN>
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-xxx, default xxx): <RETURN>
This will create a partition that will take up the whole disk (see http://www.tldp.org/HOWTO/Partition/fdis...oning.html for a more complete explanation). xxx should be the number of cylinders your drive possesses.
7) Write the changes to disk and exit fdisk:
Code:
Command (m for help): w
Command (m for help): q
8) Now you need to format the partition
Code:
sudo mkfs.ext4 /dev/sda1
Just accept any defaults. Once you press enter the program will format the partition.
9) Mount the drive
Code:
sudo mount -t ext4 /dev/sda1 /mnt
10) Ensure the drive mounted correctly:
Code:
sudo df -h
You should see an entry for /dev/sda
In my case df -h shows:
Filesystem Size Used Avail Use% Mounted on
... other partitions
/dev/sda1 459G 885M 435G 1% /mnt
Ignore the size/User/Avail as these will be different for your drive.
10) Copy the contents of the existing /var folder to your new partition under /mnt
Code:
sudo cp -a -v /var/* /mnt
This may take a while.
11) Unmount the drive
Code:
sudo umount /mnt
12) Edit your /etc/fstab to mount your new partition as the /var folder
Code:
sudo nano /etc/fstab
place the following line at the end of the file
Code:
/dev/sda1 /var ext4 defaults,noatime 0 1
save the file by typing Ctrl X, then press Y and enter to save.
13) Reboot the PI. Once it has rebooted, login and type:
Code:
df -h
This should show you that the /dev/sda1 partitiion is now mounted under /var.
In my case df -h shows:
Filesystem Size Used Avail Use% Mounted on
... other partitions
/dev/sda1 459G 885M 435G 1% /var
...and your done.
If you ever unplug your PI and then re-connect it, ensure that the USB drive is connected and switched on first before applying power.
HTH
NB: I followed various tutorials to do all this and it worked for me. YMMV.