->
A while ago, I’d written a post on howto mount CD images, such as .iso, .mdf files etc via the command prompt using the mount command. In the post, among the comments, Sumeet had asked if there was a way to do all of this without having to type lengthy commands. Well yes there is! And it can’t get simpler than this!
->
Previously I’d posted on auto-mounting partitions at startup using pysdm. This post shows how you can do so by making use of mount command.
Below steps require root priviliges, so switch to root or prefix sudo to the commands.
For mounting NTFS drives with read and write support, open the terminal and type
mount -t ntfs -o nls=utf8,umask=0222 /dev/device_name /where_you_want_to_mount
mount -t ntfs-3g /dev/device_name /where_you_want_to_mount/
Editor’s note: ntfs has been superseded by ntfs-3g and will mount with read/write privileges. However it may happen that you’ve created a mount point which requires root priviliges for read/write access. Hence I suggest that you create a mount point for your Windows drives within your /home directory, that way you won’t be needing root priviliges
For FAT32 use:
mount -t vfat -o umask=000 /dev/device_name /where_you_want_to_mount
Replace /dev/device_name with your hard disk device partition.
Adding these options to /etc/fstab file will result auto mounting of your drives.
Editor’s note: I don’t suggest touching the /etc/fstab unless its really necessary, as fuse takes care of mounting drives perfectly
PS: If someone knows how to mount ext3 drives with read and write support and other commonly used filesystems please post it as a comment. Adding “user” to the options didn’t work for me.
Editor’s note:
For ext2/3 also, the command remains the same with few changes
mount -t ext3 -o user /dev/device_name /where_you_want_to_mount
Again as mentioned above, it may happen that you’ve created a mount point which requires root priviliges for read/write access and hence you don’t get read/write access.
Bonus tip: If you don’t mention -t option, Linux will autodetect the filesystem type.
In my previous posts I’d written on how to mount your partitions using the mount command. In the post I’d mentioned that you’d have to mention the partition that you want to mount by specifying /dev/device_name as part of the command. The question that would come to your mind is, How do I know which of my partition is on what device? So let me show how to find out which partition is on what device! [...]
Today as I booted into my openSUSE box, for reasons unknown to me, my LVM partitions failed to mount. fsck didn’t help, and and LVM based container system meant that I couldn’t use the standard mount /dev/sdxx style of mounting as well. With my /home and / configured as a LVM, the root (/) partition was active, but the /home partition was not being mounted, as a result, X and KDM wouldn’t start, giving a console login. After a bit of digging around the man files, I found thw lvm manfile and started experimenting(remember, no net access too!) and found out how to mount the LVM’d partitions.
Although Linux had progressed far from being a command-line only OS to a full fledged totally GUI based one, sometimes, the command line is the best way to get something done. Here are 5 of the must-know commands. These commands can b quite useful and handy.
1: mount: Used for mounting Windows/Other partitions, just in case it isn’t automatically mounted.
Usage:
mount <device> <mount-point>
here <device> refers to the special device where your partitions are.
Rather than referring to partitions as drive letters as Windows, every partition in Linux is indicated by a special device. For eg in case if IDE(parallel ATA drives) the Primary master will be /dev/hda and the primary partition will be /dev/hda1(Windows C
and the logical partitions will be /dev/hda5, /dev/hda6 and so on(for Windows D:, E:.. so on).
<mount-point> indicates to which directory you want the partition to be available as.
Please note that mount command requires root privileges, so run the command as sudo ie,
sudo mount <device> <mount-point>
Eg: If you wish to mount the Windows C partition to a /windows/C the command will be,sudo mount /dev/hda1 /windows/C
For SATA drives, the “hdx” will be replaced by “sdx” ie, instead of /dev/hda1
it’ll be /dev/sda1
2: tar/bzip2/bunzip2: For extracting archives, this command is useful for extracting to directories other than the home directory, where root privileges are required
Usage:
(i) For GZipped files(.tar.gz extension)
tar xvfz <archive-name>
Eg: If the archive name is some-file.tar.gz, then the command will be
tar xvfz some-file.tar.gz
(ii)For Bzipped files (.tar.bz2 extension)
First, unzip the archive using
bunzip2 <archive-name>
Then untar using the command
tar xvf <archive-name>
Eg: If the archive is some-file.tar.bz2 then first unzip it using
bunzip some-file.tar.bz2
You’ll get the file some-file.tar. Next untar it using
tar xvf some-file.tar
3. rpm/dpkg – Install/Upgrade/Remove RPM/Debian Packages
Usage:
(i) Installing new packages
rpm -ivh <package-name.rpm>
dpkg -i <package-name.deb>
(ii) Upgrade existing packages
rpm -Uvh <package-name.rpm>
dpkg -i <package-name.deb>
(iii) Removing existing packages
rpm -e <package-name>
dpkg -r <package-name>
Note that these commands are suited for individual commands, whose dependencies are met. For complex packages, having many dependencies it’s better to use apt-get/smart.
For smart: smart install <package-name>
For apt-get: apt-get install <package-name>
Again these commands require root privileges, so prefix sudo before each of these commands.
4. cat – Concatenate files and print on the standard output. Useful for viewing short text files, logs without having to open any editors
Usage:
cat /path/to/file
Eg: cat /var/log/syslog
If the text file is lengthy, pipe it via more to scroll ie
cat /path/to/file |more
Eg: cat /var/log/syslog |more
5. dmesg – The program helps users to print out their bootup messages. Instead of copying the messages by hand, the user need only:
dmesg > boot.messages
and mail the boot.messages file to whoever can debug their problem.
dmesg |tail Outputs only the last part of dmesg, and is useful to identify any errors, which occured, say if a removable drive is inserted.