Mount it! Part 1: How to manually mount your Local Hard Drive:
NOTE: This is an old article and remains here for posterity. The updated article can be found at:
http://wp.me/ptjWO-dB (short link)
You connect your new external drive, USB drive, or even want to connect to your local server’s hard drive share. In this post of Linux Cauldron, we will show you the in’s and out’s of mounting Hard Drives. Mounting server shares, will be covered in a later tutorial! First thing you will want to do is get familiar with the Terminal command “fdisk -l” Output would appear as so You want to get familiar with the above command and what each area means: Device boot is the “location” of that particular hard drive. Typically each partition will be appended with a number, and generally prefixed with “sda.” Don’t be too concerned about the start and end sections, it is not necessary for this tutorial. Same goes for blocks and ID Take note of the “System.” This is the file system type of your hard drive, this will help determine which drive is which, other than the “label” you may have given your drive. Next we will tack simple use of the “mount” command in Linux for quick mounting of drives First, take note of what “/dev” location your unmounted hard drive is. Many times a drive will not mount, because it was improperly removed in Linux OR Windows. This includes not “unmounting” the drive via the GUI in liux, the Termainl in linux, or using the “Safely Remove” function in windows. The syntax for a typical mount is “sudo mount /dev/hard_drive / /mnt” , where hard_drive is you your drive location such as “sda1” While you want to always boot back into windows if you can and “Safely Remove” the drive first. Other wise type “sudo mount /dev/hard_drive/ /mnt -o force” This will force the drive to mount, and reset that particlar drive’s Log File. If you wish to “unmount” the Hard Drive, syntax is as follows, with sudo optional “sudo umount /dev/hard_drive” If the drive will not umount type “lsof /dev/hard_drive” to try and find out what process has its death grip on the drive. If you REALLY wish to unmount it, type the following, “sudo umount -f /dev/hard_drive Next we will tackle Creating an “fstab” entry in “/etc/fstab” to edit fstab, you will need root privileges. Obtain this by either dropping to a root shell with “sudo su -” or by doing “sudo nano /etc/fstab” You will an entry or several entries here. The basic syntax is <file system>, <mount point>, <type>, <options>, <dump>, and <pass>. <file system>: the location of the drive, for example, “/dev/sda3″ NOTE: what I typically do here is use the “blkid” command and note the information for that particular drive. Instead of “/dev/hard_drive” you can use that drive’s UUID (explained below). <mount point>: Where you want the drive mounted, for example, “/mnt/my_drive” (assuming you made a folder called “my_drive” in the /mnt folder) <type>: If you drive is ntfs , this will be “ntfs-3g“, if it is ext3, this would be “ext3” or if it was FAT32, it would be “fat32“ <options>: put defaults for most occasions <dump>: put 0 <pass>: put 0 Explanation of a drive’s UUID (universal unique Identifier) type the command “blkid” into Terminal. This will show you the “/dev/location”, the UUID for that drive, nad its TYPE type the command”vol_id -u /dev/hard_drive” to get the UUID for that hard drive. hard_drive is your devices location in “/dev” you can use this UUID of this information in your fstab entry for <file system> , that is normally the “/dev/hard_drive” This is a good idea to do this as it is a Truly Unique Identification for your hard drive. Device names are not always persistent. They are named according to the order of loading the kernel modules usually at start up time, and names may be different if for instance, you boot up with a flash drive plugged in. GRUB itself relies on UUIDs for /boot/grub/menu.lst Now I will show you two examples of an fstab entry:
# / was on /dev/sda5 during installation
UUID=e26f0af2-ab9d-4307-9372-33b7fbfb2ca2 / ext4 relatime,errors=remount-ro 0 1 #my added ntfs drive /dev/sda2 /mnt/my_ntfs1 ntfs-3g defaults 0 0 You will have to reboot to apply the mounts.
So, that’s it for today, if you have any questions, be sure to hit up the “Contact Us” link or leave a comment on this blog entry. I will def. take suggestions for this guide, and I welcome any criticism. Thanks for reading, _Nano
Posted on 20090321, in Basics, How-To, Terminal and tagged how to mount, how to mount hard drive, Linux, manually mount drive in linux, mount hdd with terminal, Terminal, Ubuntu. Bookmark the permalink. 10 Comments.