Recipe 9.11. Mounting and Unmounting Filesystems on Hard Drives

 < Day Day Up > 

9.11.1 Problem

You have a multiboot system with several different Linux versions, or Linux and Windows, and you want to access the filesystems from whatever Linux you've booted into or maybe you've created some new partitions, and you don't know how to access them.

9.11.2 Solution

Use fdisk to find all the partitions on local drives, mount to access them, and /etc/fstab to automate mounting. First, identify all the local partitions:

# /sbin/fdisk -l Disk /dev/hda: 20.5 GB, 20576747520 bytes 255 heads, 63 sectors/track, 2501 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes      Device    Boot  Start   End    Blocks  Id  System /dev/hda1   *     1      893    7172991  7  HPFS/NTFS /dev/hda2       894     1033    1124550  c  W95 FAT32 (LBA) /dev/hda3      1034     2501   11791710  f  W95 Ext'd (LBA) /dev/hda5      2437     2501     522081  82  Linux swap /dev/hda6      1034     1670   5116639+  83  Linux /dev/hda7      1671     2436   6152863+  83  Linux     Disk /dev/hdc: 255 heads, 63 sectors, 4865 cylinders  Units = cylinders of 16065 * 512 bytes  Device    Boot  Start   End    Blocks     Id  System /dev/hdc1   *      1         5     40131   83  Linux /dev/hdc2          6      4865  39037950    5  Extended /dev/hdc5          6        69    514048+  83  Linux /dev/hdc6         70      2680  20972826   83  Linux     Partition table entries are not in disk order

How do you know which ones are already mounted, and what their mountpoints are? Use df (disk free) to show which partitions are mounted, and their mountpoints:

$ df Filesystem   1K-blocks    Used    Available Use% Mounted on /dev/hda6     5116472    1494584   3621888   30% / /dev/hda7     6152668    4011652   2141016   66% /home

You can use df to show information on a single mounted partition. Use the -h flag to make "human-readable" numbers:

$ df -h /dev/hdc6 Filesystem         Size   Used  Avail  Use%   Mounted on /dev/hdc6          4.9G   1.4G   3.5G   29%   /home

To mount /dev/hda1, the Windows NTFS partition, follow these steps:

# mkdir -m  755 /win2k # mount -t ntfs -r /dev/hda1 /win2k

Write access for NTFS is still experimental. Don't enable write access unless you wish to risk your NTFS data. That's why we used the -r option in the mount command. If you need to share NTFS files, use Samba.


To unmount, use:

# umount /win2k

9.11.3 Discussion

Remember to adjust mount directory permissions to suit your own needs. If you're running a multiboot system, you can access all installed filesystems with the mount command.

9.11.4 See Also

  • mount(8)

  • The NTFS FAQ (http://linux-ntfs.sourceforge.net/info/ntfs.html)

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net