HOWTO: Mount Partitions in Terminal – FSTab
Here’s a How-to, taken from one of my posts on Ubuntu Forums. This how-to explains how to mount a partition in Ubuntu via the command line, and how to set up an auto-mount in your FSTab 🙂
All the writing in this kind of font, is writting that you type into a command line, either on a CLI system such as Ubuntu Server, or through a Terminal (Applications>Accessories>Terminal). To mount a drive, you first need to know it’s name. Run the following command in a terminal to list all your harddrives and partitions.
sudo fdisk -l
Take a note of the drive names, and partition numbers of the drive you want to mount. This would be something like /dev/sdb1 or /dev/sdc3. If there are no partitions, you’ll need to create some with fdisk (How-to for this is on it’s way ;))
Now, create a mountpoint for your drive. You can make it whatever you want, but a common place to mount things is in the /mnt dir. Create a folder there with
sudo mkdir mount_name
Of course, you can have “mount_name” as whatever you want.
Finally, after that, we can try to mount the drive to the folder. If the partition you want to access is called /dev/sdb1 the command would be this
sudo mount -t auto -v /dev/sdb1 /mnt/mount_name
The -t option is the filesystem type. Since we don’t know it, leave it to auto and let the mount command figure it out. The -v option is for verbosity, and with luck, should show something like this.
mount: you didn't specify a filesystem type for /dev/sdb1 I will try type vfat /dev/sdb1 on /mnt/mount_name type vfat (rw)
Now we know that the filesystem is vfat. It could also be ntfs-3g, ext3, ext4 or a few others.
Before we proceed, unmount the drive we just mounted with
sudo umount /dev/sdb1
To tell Ubuntu to mount your drive everytime it boots, you need to edit your fstab file. The options here vary quite a bit, so this guide will be very useful. The following is just an example.
Edit the file using Nano
sudo nano /etc/fstab
As a general rule of thumb, assuming that /dev/sdb1 was an NTFS partition, you would add a line like this to the end of the file. The line with the # in front is commented out, and is just there for your own reference.
#Write whatever comment you want /dev/sdb1 /mnt/mount_name ntfs-3g defaults,uid=1000,umask=0 0 0
UID is your user id. If your the first user created, this will most likely be 1000. Again, the options you can give here vary a lot, but the Ubuntu docs have quite a good list.
For a Linux partition, the line would be a bit simpler.
#Write whatever comment you want /dev/sdb1 /mnt/mount_name ext4 defaults 0 0
Finally exit and save the file with Ctrl+X, press Shift+Y and then Enter.
Test that your fstab line is correct by trying to mount it.
sudo mount /dev/sdb1 -v
It should tell you that it has been successfully mounted.
That’s it. You may have to change the permissions of the mounted drive to allow you to read/write to it, but that’s as simple as running
sudo chmod -Rv 777 /mnt/mount_name
followed by
sudo chown -R you_user_name /mnt/mount_name
That will change the permissions to 777 (Full access to everyone) and list every file as being owned by you.
After all that, your done 🙂
Filed under: HowTo, Operating Systems, Posts, Ubuntu | 7 Comments
Tags: FSTab, HowTo, Operating Systems, Ubuntu
- AMD64 Apt Apt-Cacher Apt-Cacher-NG Arch ArchBang Artic Silver 5 Backups Bang86 Broadband Celeron CentOS Cleaning Clonezilla Compiz Conky copy recursively CPU Crunchbang Debian DPKG Ebay find Firefox Flash Gnome GRUB GTk Hardware Heatsink HowTo Jesred Karmic Laptop Linux LUbuntu Maverick Network New Computer NTFS Nvidia Office 2007 Openbox Operating Systems Packages Packard Bell Pentium Pentium IV Perlico PIII postaweek2011 Posts Proxy RAID Repairs RSync Sensors Server Size Mismatch Snow Squid SSH Synaptic System64 Tecra terminal commands Themes Ubuntu Upgrade USB VNC W2K3 Windows Wine Xubuntu 9.10
Top Posts
Archives
-
Join 86 other subscribers
Meta
-
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License.
Thank you very much! 🙂
If I could only add one thing – it should be:
#Write whatever comment you want
/dev/sdb1 /mnt/mount_name ext4 defaults 0 0
instead of:
#Write whatever comment you want
dev/sdb1 /mnt/mount_name ext4 defaults 0 0
Ah, thank you, I had missed that typo 🙂
“HOWTO: Mount Partitions in Terminal – FSTab Linux Expresso”
was a relatively good post, . Keep authoring and I’m going to keep on reading! Thanks -Dianne
Hello to all, how is all, I think every one is getting
more from this web site, and your views are good in favor of new viewers.
Good day! Would you mind if I share your blog with my zynga group?
There’s a lot of folks that I think would really appreciate your content. Please let me know. Cheers
Which was both of those interesting too as insightful!
Thank you for sharing your ideas with us.