Wednesday, July 3, 2013

Installing a new HDD on Arch Linux

I decided to add some more storage to my HTPC, so I got a 2TB WD Green HDD, and this is what I did to install and configure it.

The hardware installation is the same as any hard drive, just mount it and add cables for power and SATA. In my case it's a little bit tight, I'd like to change out the power supply for a modular one, but I haven't been able to find one that is short enough to fit in the case yet.


Before
After













Anyway, now that the HDd is in place, it's time to set it up so that it is usable.

  • First find the device name of the new HDD
    • ls /dev
      • In my case it is "sdb"
  • Now the disk needs to be partitioned, I just need the one partition for the whole disk
    • fdisk sdb
    • o (creates a new, empty partition table)
    • n (create a new partition, in my case the default options are fine so I just hit enter for all of them)
    • p (shows the partition that has been created, just to make sure it looks ok)
    • w (write the partition table to disk and exit)
  • If we again check the devices with "ls /dev" we see that there is now a new device called sdb1, this is the new partition
  • Now that the partition exists, we can format it, I'll use the ext4 filesystem
    • mkfs -t ext4 /dev/sdb1
  • I also prefer to give it a name, in this case "storage"
    • e2label /dev/sdb1 storage
  • Next I want to add the new partition to fstab, so that it is automounted in future
    • Create a directory to mount it to
      • mkdir /media/storage
    • Find the UUID of the partition
      • blkid (Response as below)
      • /dev/sda3: LABEL="home" UUID="d0e114fa-b428-4605-851d-504c86c0e7ac" TYPE="ext4"
        /dev/sda5: UUID="21ecefbb-1c9d-48fa-a5f3-c9ba9a09b547" TYPE="swap"
        /dev/sda6: LABEL="root" UUID="fb22b964-b38f-42df-bded-d9ac6df54ec5" TYPE="ext4"
        /dev/sdb1: LABEL="storage" UUID="5d003827-efca-4dfe-955d-bbec787a454a" TYPE="ext4"
    • Now we just need to add it to fstab, so open /etc/fstab and add the line
      • UUID=5d003827-efca-4dfe-955d-bbec787a454a       /media/storage    ext4            defaults        0 2
Now, unfortunately I didn't really set up the system for additional HDD's from the start. The partition of the 1st HDD that is used for storage is mounted as /home, which works quite well, but I can't mount additional ones in the same spot now can I.

Originally, I planned to solve this by mounting it in /media/storage, and then create a symlink to that from my home folder. This led to me finding out about a bug/feature of samba, which is how I usually access the media from my "normal" computer. Samba always reports the remaining space of the root drive so even though it is a separate drive, the file browser thinks of it as only one, and with the remaining space of the first one. So it seems that Samba does not agree with more than one partition on the same share. The only way around it, that I could find, was simply to create a second share.

Since I'm the only user, I set up samba in such a way as to get full permission, for all users, for the files. This is my share configuration in /etc/samba/smb.conf:
[XBMC2]
    comment = XBMC media 2
    path = /media/storage
    public = yes
    browseable = yes
    force user = <username>
    force group = <groupname>
    force create mode = 777
    force directory mode = 777
    available = yes
    writable = yes

And that's it, the new HDD is up and running.

No comments:

Post a Comment