Linux File System setup


The /etc/fstab contains information about mounted file systems.

Each file system (I think of these as partitions) are mounted in a directory. Any file that is created in that directory will be saved onto that file system.

e.g. if the contents of fstab has

/dev/sda1     /
/dev/sda2      /home

then it means files written to /home and any subdirectories will be created on /dev/sda2. All other files will be written to /dev/sda1

When planning your mount points think about the size requirements of each directory.

UUID with blkid

With newer versions of fstab you can refer to disk drive partitions with a UUID. blkid will list all the UUIDs. This is better than the /dev/sdaX reference which can change when drives are added or removed, or internal cables are moved.

root@turtle:~# blkid
/dev/sda1: UUID="746c7a5a-4960-4bf1-9403-b6875006d981" TYPE="ext2"
/dev/sda5: UUID="Kao8Us-6YUs-OFsA-BBH4-ION9-Nz6I-eY7LTI" TYPE="LVM2_member"
/dev/sdb1: UUID="049ba9c1-0ca0-48a2-9ef2-325ca1370623" TYPE="ext4"
/dev/sdb2: UUID="b01f3205-982d-4bc3-9f6b-86bba6e900d0" TYPE="swap"
/dev/sdb3: UUID="7f58fea9-8065-4a18-99cd-fc0396ad83cd" TYPE="ext4"
/dev/sdb4: UUID="5003da93-0229-4da0-b48e-52770b98c3ca" TYPE="ext4"
/dev/mapper/turtle-root: UUID="80b8e195-5990-4a85-8e7e-214b885b2a1d" TYPE="ext4"
/dev/mapper/turtle-swap_1: UUID="b2f330fb-e457-472f-afa0-ff80c698ad75" TYPE="swap"

mounting partitions

Run blkid first to identify which HDD devices will have data.

In the above example, if you want to mount partition /dev/sdb1 onto /mnt/backup run

root@turtle:~# mkdir /mnt/backup
root@turtle:~# mount /dev/sdb1 /mnt/backup

Now you can access files in /backup. This will not survive a restart.

Published: Sunday, 1 July 2012