How to add a new disk drive
- Physically install the disk.
- Find the device id (e.g.
/dev/hdb
or/dev/sdb
). Hardware browser orfdisk -l
can help with this. - Option 1: Create the partition table with
fdisk
(up to 2 TB):
fdisk /dev/sdb
("p" = print table, "n" = new partition, "w" = write table)
- Option 2: use parted (for big arrays):
parted /dev/sdb (parted) mklabel gpt (parted) print (showed size of disk to be 10.5TB) (parted) mkpart primary xfs 0 -1 (use the whole disk) (parted) quit
If mkpart complains about being improperly aligned, use "1 -1" instead of "0 -1".
- Format the partition(s):
mkfs.ext3 /dev/sdb1 (for ext3) mkfs.ext4 /dev/sdb1 (for ext4) mkreiserfs /dev/hdb1 (for Reiser) mkfs.xfs /dev/sdb1 (for XFS)
Note: For an XFS filesystem on a hardware RAID5 array with 15 disks and 256K stripe size, use this command:
mkfs.xfs -f -L export -d su=256k,sw=14 -l su=256k /dev/sdb1
This tells mkfs to label the filesystem "export", to use the native stripe size for the filesystem and the log, and that the stripe width is N-1=14 for a 15-disk array.
- Create the mount point:
mkdir /u1
- Add an entry to /etc/fstab. Something like
/dev/sdb1 /u1 ext3 defaults 0 2
(0 for no dump, 2 for second priority in fsck). Instead of defaults, use noatime,nodiratime for a big array.
- Mount the partition:
mount /u1
- To mount an existing disk (don't forget the partition number):
mount -t reiserfs /dev/hdb1 /data
Disk Labels
If device letters aren't always consistent, it may be useful to create disk labels and assign them in the fstab. To label an ext3 partition:
e2label /dev/sdb1 my_label
To label an xfs partition:
xfs_admin -L my_label /dev/sdb1
To read an existing xfs label:
xfs_admin -l /dev/sdb1
To refer to this in /etc/fstab:
LABEL=my_label /u1 (etc.)