Você está na página 1de 4

http://bytes.

com/topic/unix/insights/820158-how-mount-partitions-under-linux-unix
All Topics Business IT Development sign up login

Top Experts
bytes > unix / linux / bsd > unix / linux / bsd insights

How to mount partitions under Linux / Unix


Home Solar Power System Schletter's FS System Delivers Efficient Solar Power to Your Home www.schletter.us/fs-system.html Solar Racking & Mounting Simple, comprehensive & adaptive. Cutting installation time and cost. zillarac.com Sniffer Brasileiro O rootNet um produto Nacional, com qualidade e preo competitivo. www.amixsi.com.br

Nepomuk
E B

Join Date: Aug 2007 Location: Germany Posts: 1,721 #1 Jul 10 '08

A Calfiornia manufacturer Operable walls & folding partitions online spec writing wizard
www.advancedequipment.com

In most modern distributions of Linux and Unix (at least ones with graphical environments like KDE, Gnome or XFCE), you get to mount your partitions easily from the desktop. In some cases however, it isn't that easy.

AV Products, Inc. Anti vibration fail-safe mounts Rubber isolation mounts.


www.anti-vibration-mounts.net

Note, that all of these commands have to be run in a terminal as root user. To open a terminal (sometimes called a console), either press ALT+F2 and type xterm (alternatives could be konsole or terminal) or press CRTL+ALT+F1 to change to a terminal. However the latter will take you away from your graphical environment (or your desktop), so to get back to that, use CRTL+ALT+F7 or CRTL+ALT+F5, depending on your system.

Zarafa Outlook Sharing The MS Exchange replacement for your Linux mail server.
www.zarafa.com

To switch to root user once a terminal window is open, type


Expand | Select

| Wrap | Line

Numbers

Floppydisk.com Great prices on floppy disks & USB floppy drives. Transfer to CD too.
www.floppydisk.com

1.

su

and enter the root password. To "log out" root after you've finished, enter
Expand | Select

| Wrap | Line

Numbers

1.

exit

Total System Information Asset Agent & Utility for Windows, AppleMac, UNIX/Linux - GUI/CLI/API
www.MagniComp.com/sysinfo

Alternatively (if installed), you can use


Expand | Select

| Wrap | Line

Numbers

More
Latest Questions Latest Expert Insights

1.

sudo

before every command.

Need Help with Bytes? (FAQ)

First of all, you can check what partitions your system recognises with
Expand | Select

| Wrap | Line

Numbers

1.

fdisk -l

(That is a small 'L', not the number '1'.) The output will look something like this:
Expand | Select

| Wrap | Line

Numbers

1. 2. 3. 4. 5. 6. 7. 8. 9. or

Disk /dev/hda: 40.0 GB, 40060403712 bytes 255 heads, 63 sectors/track, 4870 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot /dev/hda1 /dev/hda2 /dev/hda3 /dev/hda4 *

Start 1 65 1403 3979

End 64 1402 3978 4870

Blocks

Id

System 82 83 83 83 Linux swap / Solaris W95 FAT32 Linux Linux

514048+ 10747485 20691720 7164990

Expand | Select

| Wrap | Line

Numbers

19/3/2011 14:13

http://bytes.com/topic/unix/insights/820158-how-mount-partitions-under-linux-unix
1. 2. 3. 4. 5. 6. 7. 8. 9. Device Boot /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda4 * Start 1 65 1403 3979 End 64 1402 3978 4870 Blocks Id System 82 83 83 83 Linux swap / Solaris W95 FAT32 Linux Linux Disk /dev/sda: 40.0 GB, 40060403712 bytes 255 heads, 63 sectors/track, 4870 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

514048+ 10747485 20691720 7164990

The devices called hdx (or sdx, x being something or the other; here found in line 1) in the directory /dev are your harddrives, the devices called hdx1, hdx2, etc (or sdx1, sdx2, etc) are your partitions.

As you can see, in my case the partition hda1 or sda1 is a SWAP-Partition, hda3 and hda4 (sda3 and sda4) are Linux partitions of some kind (like ext2, ext3, reiserfs or xfs) and hda2 (sda2) is FAT32 (a windows filesystem). If you have an NTFS drive, make sure the correct drivers are installed!

Next, check which partitions are already mounted with


Expand | Select

| Wrap | Line

Numbers

1.

mount

The output will look something like this:


Expand | Select

| Wrap | Line

Numbers

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.

/dev/hda4 on / type ext3 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) /sys on /sys type sysfs (rw,noexec,nosuid,nodev) varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755) varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777) procbususb on /proc/bus/usb type usbfs (rw) udev on /dev type tmpfs (rw,mode=0755) devshm on /dev/shm type tmpfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) lrm on /lib/modules/2.6.17-12-generic/volatile type tmpfs (rw) /dev/hda3 on /home type ext2 (rw)

In this case, hda4 and hda3 are mounted, but hda2 isn't.

Now, choose where the device is going to be mounted to. Normally, it's in a subdirectory of either /mnt or /media. Check, that the subdirectory exists (e.g. /mnt/c or /media/hdb2). If it doesn't, create it by using
Expand | Select

| Wrap | Line

Numbers

1. 2.

cd /media mkdir hdb2

(or appropriate).

With the above information, you should be able to choose the right partition and use something like
Expand | Select

| Wrap | Line

Numbers

1.

mount /dev/hdb2 -t vfat /media/hdb2

if you're mounting hdb2 and it's a FAT16 or FAT32 partition.

The most commonly used partition formats are: autofs (automatically try to determine format) ext2 ext3 iso9660 (for CD-ROMs) ntfs reiserfs smbfs (for SAMBA drives) udf (for DVD-ROMs)

19/3/2011 14:13

http://bytes.com/topic/unix/insights/820158-how-mount-partitions-under-linux-unix
usbfs (for some USB devices) vfat (for FAT16 and FAT32) xfs (More information about various file systems are to be found beneath the main article.) Now, the drive will be accessible, however only root will have full access.

To make things easier, if you want to mount that drive more often, you can put it into /etc/fstab. Just open it in an editor (as root!) and add the following lines at the bottom:
Expand | Select

| Wrap | Line

Numbers

1. 2.

# added manually /dev/hdb2 /media/hdb2 vfat defaults,users,noauto 0 0

(Of course, you'll have to change the device, type and mount directory to what you need.) This will allow anyone to mount that partition. If you want the drive to be mounted automatically on startup, change noauto to auto.

Then save the file and in future you'll just have to do


Expand | Select

| Wrap | Line

Numbers

1. or

mount /dev/hdb2

Expand | Select

| Wrap | Line

Numbers

1.

mount /media/hdb2

from any account to mount the drive.

More information about mounting can be found in the mount help


Expand | Select

| Wrap | Line

Numbers

1.

mount -h

or on the manpage of mount, which you can find by entering


Expand | Select

| Wrap | Line

Numbers

1.

man mount

or alternatively
Expand | Select

| Wrap | Line

Numbers

1.

info mount

into a terminal window.

Various File Systems Here are some short descriptions of the most common file systems: ext2 is a file system, which was very common on linux systems for a long time. Nowadays, it is mostly replaced by ext3. Use the format type ext2 to mount. ext3 is a so called journaling file system. Other than that, there are very few differences to ext2. Use the format type ext3 to mount. ext4 is a file system, which is currently under development. It is supposed to replace ext3. As it is unfinished, I'll not go into any detail. In future, you'll probably use the format type ext4 to mount. XFS is one of the oldest journaling file systems available for UNIX and almost all Linux distributions, one of the few exceptions being Red Hat Enterprise Linux. Use the format type xfs to mount. JFS is a 64-bit journaling filesystem created by IBM. There are two generations of JFS filesystem that are called JFS (JFS1) and JFS2, however under most operating systems, such as OS/2 and Linux, only the second generation exists and is called simply JFS. Use the format type jfs to mount. ReiserFS (occasionally referred to as Reiser3) is a general-purpose, journaled computer file system and the first

19/3/2011 14:13

http://bytes.com/topic/unix/insights/820158-how-mount-partitions-under-linux-unix
journaling file system to be included in the standard linux kernel. Use the format type reiserfs to mount. FAT12 / FAT16 / FAT32 are relatively straightforward file systems and are supported by virtually all existing operating systems for personal computers. They are no journaling filesystems and therefore affected by fragmentation at a much higher rate than those. Use the format type vfat to mount. NTFS is the standard file system of many newer Windows versions. It has several improvements over FAT, like the use of advanced data structures or it being a journaling filesystem. The support under Linux UNIX is good but not perfect, as the file system specification is a trade secret and the non-microsoft implementations are reverse engineered. Use the format type ntfs to mount. You have to have NTFS-3G installed! All of these descriptions are based on the wikipedia articles. Share this article on:

Niheel
E M A B

Join Date: Jul 2005 Location: Portland, OR, United States Posts: 718 #2 Jul 10 '08

re: How to mount partitions under Linux / Unix Hah, perfect timing. Just about to setup a new backup system on a nix box.

Bookmarks

digg

facebook

twitter

stumbleupon

Tags

mount unix

previous insight | next insight

Similar topics
Trying to mount windows folder on Linux - getting error ( Unix / Linux / BSD answers ) mount() function problem ! ( C / C++ answers ) how to use mount() system call for cd image mounting ( C / C++ answers ) Mount Unix Volume ( Visual Basic .NET answers ) Create and mount partitions ( C / C++ answers ) about mount func. ( C / C++ answers ) Get drives and partitions list (Linux) ( Python answers ) Easy way to detect hard drives and partitions in Linux ( Python answers ) Feedback on Sets, and Partitions ( Python answers )

Copyright 1995-2010 BYTES. All rights Reserved. Formerly "TheScripts.com" from 2005-2008 About Bytes | Advertise on Bytes | Help Latest Expert Topics | Popular Tags Sitemap | Unix / Linux / BSD Answers Sitemap | Unix / Linux / BSD Insights Sitemap

19/3/2011 14:13

Você também pode gostar