Quantcast
Channel: Open Source Software Development » media-server
Viewing all articles
Browse latest Browse all 11

Adding disks to ubuntu

$
0
0

When attaching new disks to ubuntu, they are added as /dev/sdX. The fdisk command will list the disks that are currently available on the system, also including their configured partitions.

For example:

$ sudo fdisk -l
Disk /dev/sda: 64.0 GB, 64023257088 bytes
255 heads, 63 sectors/track, 7783 cylinders, total 125045424 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: 0x00097178

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   120868863    60433408   83  Linux

In order to mount this device, the command mount /dev/sda6 /mnt will put it into the /mnt directory. All the contents on the partition can then be accessed.

There are lots of different options to mount. A couple of useful options:

  • -o <opt> Specifies different options for the mount. These can include write access (rw) or read-only (ro)
  • -t <type> Specifies the filesystem type. Most of the time, mount will automatically and correctly detect the mount type
  • Refer to mount(8) for more options

The only problem with manually issuing the mount command, is that devices will not remain after a system reboot! In order to keep devices, modify the file /etc/fstab and run mount -a. For example, the fstab will already contain the boot devices

$ cat /etc/fstab
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/sda1 /               ext4    errors=remount-ro 0

The format of the fstab file is documented in fstab(5). There are 6 colums, each delimited by whitespace. The columns define:

  1. Device
  2. Mount point
  3. File system type
  4. Mount options
  5. Determines if the file system needs to be “dumped” (optional)
  6. Determines the order of file system checks (optional)

If you are unsure of any of the options required for fstab, running mount (without any options will describe the mounts in a format close-to what’s required. For example

$ mount
/dev/sdf1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)

Once important note with mounting devices:

As this is a media server, the chances of adding additional storage is considerably high! Once my photo collection breaks the capacity of the disk it will need to be migrated to bigger storage. A problem arrises when adding another disk to the server… the device names can get jumbled! As the names of disks is mapped to different SATA ports on the motherboard, sometimes adding a new device can change its name! How do we fix this!?

Each device attached to the system has a universally unique identifier (UUID) that can be used instead of the device name. Under ubuntu, to see the UUID, run

sudo blkid /dev/sda1

Then, in fstab, replace the device path with UUID=”<uuid>”. For example

UUID="bc17609f-31cd-413a-ab3c-b26d23ffc7db" /               ext4    errors=remount-ro 0       1

Then, upon reboot, and no matter if any new devices are added, the chosen device will always be mounted correctly!


Viewing all articles
Browse latest Browse all 11

Trending Articles