Randomness

Mount drive at startup

Posted by: Lloyd Puckitt on: October 10, 2007

This is partially reprinted from the Ubuntu community documentaion
https://help.ubuntu.com/community/InstallingANewHardDrive

Format the Partition via Command Line

To format the disk as ext3 filesystem (best for use under Ubuntu):

sudo mke2fs -j /dev/hdd1

Substitute “/dev/hdd1″ with your own drive’s path.

====================================

Modify reserved space (optional)

When formatting the drive, 5% of the drive’s total space is reserved for the super-user (Root) so that the operating system can still write to the disk even if it is full. However, for disks that only contain data, this is not necessary.

You can ajust the percentage of reserved space with the “tune2fs” command, like this:

sudo tune2fs -m 1 /dev/hdd1

This example reserves 1% of space – change this number if you wish.

Using this command does not change any existing data on the drive. You can use it on a drive which already contains data.

=====================================

Mount the Drive

You can choose to have the drive mounted automatically each time you boot the computer, or manually only when you need to use it.

Automatic Mount at Boot

You’ll need to edit /etc/fstab:

gksudo gedit /etc/fstab

Add this line to the end:

/dev/hdd1 /media/mynewdrive ext3 defaults 0 2

The “2″ at the end instructs your system to run a quick file system check on the hard drive at every boot. Changing it to “0″ will skip this. Run ‘man fstab’ for more info here.
You can now run “sudo mount -a” (or reboot the computer) to have the changes take effect.

If you want to allow a normal user to create files on this drive, you can either give this user ownership of the top directory of the drive filesystem: (replace USERNAME with the username)

sudo chown -R USERNAME:USERNAME /media/mynewdrive

or in a more flexible way, practical if you have several users, allow for instance the users in the plugdev group (usually those who are meant to be able to mount removable disks, desktop users) to create files and sub-directories on the disk:

sudo chgrp plugdev /media/mynewdrive
sudo chmod g+w /media/mynewdrive
sudo chmod +t /media/mynewdrive

The last “chmod +t” adds the sticky bit, so that people can only delete their own files and sub-directories in a directory, even if they have write permissions to it (see man chmod).

Manually Mount

Alternatively, you may want to manually mount the drive every time you need it.

For manual mounting, use the following command:

sudo mount /dev/hdd1 /media/mynewdrive

When you are finished with the drive, you can unmount it using:

sudo umount /media/mynewdrive

Leave a Reply