Friday, January 7, 2011

You just bought a new 1 Terrabyte drive for your Ubuntu server. Now what?

After installing the RAID card for the SATA drive, and after seeing the drive at boot-up time, you're ready to partition the drive, format it, and mount it by id, and then use it.

1. List drives:
sudo fdisk -l

2. If drive is not formatted but it is listed, format it (ex: drive is /dev/sdb):
sudo fdisk /dev/sdb
p (print partition information)
n (create new partition)
p (primary partition)
1 (partition #1)
[enter] (accept first cylinder default, which is 1)
[enter] (accept last cylinder default, whatever that is)
w (write partition information, and then the program will exit)

Verify that a partition has been created (it's not yet formatted), do a list:
sudo fdisk -l

You should see the new partition listed, and a number added to the device name. For example, the drive is /dev/sdb and the partition became /dev/sdb1

3. Format the partition (Be very careful that it's the correct partition, in this example /dev/sdb1):

mkfs.ext3 /dev/sdb1

Wait for the formatting to be over.

4. List drives by UUID:
ls -l /dev/disk/by-uuid/
Note down the UUID of the disk that you've just formatted, for example sdb1.
The UUID is a long sequence of alphanumeric characters.

5. Create directory where to mount drive (disk 1 = /mnt/d1)
sudo mkdir /mnt/d1

6. Copy UUID of drive in fstab so that it gets mounted every time the server is booted:
sudo nano /etc/fstab

# My 1TB drive on /dev/sdb1
UUID=91f86f8a-4b59-4b67-b62b-0f2a3c2b235c /mnt/d1 auto defaults 0 2

6b. Optionally, if you just want to mount the drive now without adding it to the automatic mounting in the /etc/fstab file, then you can mount it manually, also by UUID:
sudo mount -U 91f86f8a-4b59-4b67-b62b-0f2a3c2b235c
or
sudo mount /dev/sdb1 /mnt/d1


7. Restart server, if you have to. (you shouldn't have to)
sudo shutdown -r now

Now the drive is available in /mnt/d1. Check the space: df -h /mnt/d1

No comments:

Post a Comment