Sunday, April 13, 2014

How to mount automatically on linux


When do you bored to mount media when firstly turn on your laptop, you can set to automatically mount. Search on google and you will found many of your solutions, yeah maybe now i will repost that's trick on creatorb blog's, checkidot now...

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. i checked with type show -a on the terminal. 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. yeah now it's completed. when you still confused visit this My Friend Blogs it tutorial indonesian version.

0 comments:

Post a Comment