วันพุธที่ 24 พฤศจิกายน พ.ศ. 2553

mount usb on linux

Mounting the External File System (Hard Drive)


To mount your hard drive you need to use the mount command. (To unmount the drive when you are ready to unplug it and take it home, use the umount command.) Here’s an example:



mkdir /mnt/usbdrive

mount /dev/sda1 /mnt/usbdrive



The above command first creates a directory in your /mnt folder, typically the folder will be descriptive of the device, so we use /mnt/usbdrive. This only has to be done once, as you won’t be deleting this folder. This folder will be your mount point for the external hard drive.



The second line mounts the device at the /dev/sda1 location to the /mnt/usbdrive directory.



Now you can reference your hard drive from the command line using the folder /mnt/usbdrive.



Automount In the Terminal

To have your hard drive mount each time your server is restarted, you must edit your /etc/fstab file. Simply add at the bottom of your /etc/fstab file:



/dev/sda1 /mnt/usbdrive ext3 defaults 0 0



The first argument (/dev/sda1) tells the system what device to mount, and the second argument (/mnt/usbdrive) tells the system where to mount it. The third argument is the filesystem type (ext3). The fourth argument (defaults) tells the system what options to apply to the device, so in this case we’ll just use the defaults. The fifth and sixth arguments (both zeros) tell the system if the filesystem should be backed up using the dump utility, and the second zero tells the system whether to process the device when fsck is run. We can leave them both to zero for now.



Now you have a mounted hard drive that you can use for all your company backups, and by reading our previous two articles you can setup a script to automate your backup.

ไม่มีความคิดเห็น: