1 / 26

Meeting 4

ITI-481: Unix Administration Rutgers University Center for Applied Computer Technologies Christopher Uriarte, Instructor. Meeting 4. Today’s Agenda. Disk Partitioning Directories and File Systems Mounting Local File systems. Disk Partitions.

Télécharger la présentation

Meeting 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ITI-481: Unix AdministrationRutgers University Center for Applied Computer TechnologiesChristopher Uriarte, Instructor Meeting 4

  2. Today’s Agenda • Disk Partitioning • Directories and File Systems • Mounting Local File systems

  3. Disk Partitions. • A typical UNIX installation will divide one or more hard drives into multiple partitions. • In Linux, each disk is given its own device name:/dev/hdX (X can range from a-z) – IDE disks/dev/sdX (X can range from a-z) – SCSI disks • A partition number is added to the device name:/dev/hdXY (Y is the partition number) – IDE disks/dev/sdXY (Y is the partition number) – SCSI disks For example, the first partition on the first IDE drive on a system would be /dev/hda1. • Disk partition information can be viewed using the ‘df’ command.

  4. Understanding File System Types • Different operating systems use different file systems. • A file system type is essentially the “specification” for how blocks of data are organized on disks. • Some file systems have features that other file systems may not have, such as the ability to more easily handle corrupted data or system crashes.

  5. Some Common File System Types: • FAT – used with DOS, Windows 3.1, Windows95, Windows98 • FAT32 – used with Windows98/SE, WindowsME an some Windows95 distributions. Can also be used on Windows NT,2000 and XP. • NTFS – used on Windows NT, 2000 and XP • UFS (Unix File System) – a generic UNIX file system used on many UNIX flavors. • EXT2 – a Linux-specific file system used in most Linux distributions • JFS, ReiserFS, EXT3 – next-generation advance file systems available as an option on some UNIX systems today. (actually, all are available for Linux)

  6. Selecting a File System Type • Linux is unusual, as it allows you to choose the file system type of a partition during setup. • Most UNIX’s use their default file system type during install (usually UFS). • Linux, however, has the flexibility to create and mount many different file system types, although we generally use EXT2, as it’s the most Linux-compatible. (remember, EXT2 is the Linux default)

  7. Partitions and File Systems: A Recap • (From Class 1) Disk Partitioning is the concept of dividing your hard disk into logical partitions, making one hard drive appear as if it’s actually multiple drives. • There’s several reasons why we partition disks: • Performance • Ease of storage management • Security

  8. Disk Partitioning in UNIX • In UNIX, a physical disk partition is associated with a directory path, sometimes referred to as a mount point. • All files that are in directories associated with a mount point are stored on the mount point’s physical partition. • If a directory path is not explicitly associated with a physical disk partition, its files are stored under the root ( “/” ) partition.

  9. UNIX Partition Example Contains all files under the /usr directory (I.e. /usr/local/bin/pico, /usr/bin/vi, etc.) [HARD DRIVE] Example Partitioning Scheme: Total Hard Drive Space: 8GB /usr 2GB /home 4GB / (root) 1.5GB Contains all files under the /home directors (I.e. /home/chrisjur, /home/iti1234) Contains all other files and directors, such as /var, /opt, /sbin, etc. swap

  10. Disk Partitioning: Rules to Live By • Making disk partitions is easy; Changing them can be hard. • It’s not often easy to expand or shrink disk partitions (in fact, it’s impossible to do on many operating systems), so make sure you have adequate space for your data storage. • You can always create partitions from new hard drive. • You can always create partitions from un-partitioned space on existing, in-use hard drives.

  11. Example: Adding a Partition Using Un-partitioned Space /dev/hda1 Mounted on /home /dev/hda2 Mounted on /home2 /dev/hda1 Mounted on /home (Unused) You can easily take unused hard disk space, format it, partition it and mount is as a new file system.

  12. Steps Required Make a New Partition • Partition empty space on the hard drive • Format the newly created partition • Create a mount point for the partition • Mount the partition

  13. Partitioning Empty Hard Drive Space • Empty hard drive space can be partitioned using a utility called fdisk. • Fdisk allows you to create, delete and modify partitions, as well as to set their partition types. • Allows you to print the partition table for a particular hard drive. • Can be started with: /sbin/fdisk <hard drive to edit> • e.g. /sbin/fdisk /dev/hda

  14. Fdisk: Sample of Help Menu # /sbin/fdisk /dev/hda Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)

  15. Example: Creating a New Partition with Fdisk • Launch fdisk – edit hard disk /dev/hda:> /sbin/fdisk /dev/had • Type “p” to print the current partition table. • You can now create a new partition, specify the size of the partition and then specify its file system type. • The “n” option will allow you to add a new partition. You are prompted to specify whether you want to use a primary partitions 1 to 4) or logical partition (partitions 5 and above). You should choose “p” for primary partition. • You will be asked to specify a partition number. Refer back to the partition table -You can choose a partition number that is not used from 1-4.

  16. Creating Partitions, con’t • You will then be asked to specify the starting cylinder – simply choose the default. • You will then be asked to specify the size of your new partition. You can specify this size in cylinders, kilobytes or megabytes (e.g. +1500M makes the partition 1500MB). • You must now specify the partition’s file system type by using the “t” option. Typing “L” will list the partition type codes. You want to use type 83 – Linux native. • Finally, type “w” to write the new partition table and exit – you may have to reboot.

  17. Step 2: Formatting the new File System • Assuming you just created partition #3 on /dev/hdb, the partition you just created is now called /dev/hdb3. You must now format that partition. • Partitions are formatted using the mkfs command. There is a special mkfs, called /sbin/mkfs.ext2, used to format Linux EXT2 file systems. • Usage: /sbin/mkfs.ext2 <partition to format> • e.g. /sbin/mkfs.ext2 /dev/hdb3

  18. Step 3: Choosing and Creating a Mount Point • Now that you have a fresh chunk of useable disk space, you need to decide how you will access it. • You must choose a unique and empty directory path to be associated with your partition – this is referred to its mount point. • For example, if you’ve created a partition /dev/hdb2, and you want to access its disk space via the path /newdisk, you must first create the path /newdisk (“mkdir /newdisk”) and we must then mount the partition on that path.

  19. Step 4: Mounting the New Partition • After choosing and creating a mount point, you can mount the partition using the UNIX mount command: • mount [options] <partition> <mount point>For example:mount –t ext2 /dev/hdb3 /newdisk • ( -t specifies file system type) • After mounting the file system, you are now ready to use it!

  20. Viewing Mounted File Systems • You can view mounted file systems using the “df –k” command: Filesystem 1k-blocks Used Available Use% Mounted on /dev/hda5 3309736 913788 2227820 29% / /dev/hdb1 495204 13 469623 0% /home

  21. Unmounting File Systems • File systems are unmounted with the umount command: • umount <mount point> • For example:umount /newdisk • File systems should only be unmounted when they are not in use.

  22. Typical Directory Structure Note: Not all directory paths have their own partitions – in fact, a system may only have 1 partition! / - begins the file system structure (root) /boot - kernel files /usr – scripts and binary applications /sbin – basic system tools /home – user home directories /var – log files and other time sensitive data /etc – configuration files /dev – device drivers /opt – typical install location for some commercial software /tmp – temporary storage /mnt – mount points for floppy disks and CD-ROMS swap – swap space

  23. Sample Directory Tree with Mount Points

  24. /etc/fstab • Specifies what partitions to mount automatically during boot time. • Entry format:<partition> <mount point> <fs type> <parameters*> <fs_freq*> <fs_passno*>Sample entry:/dev/hda3 /newdisk ext2 defaults 1 2 • *These fields are usually set to defaults, 1 and 2, respectively. • For entries in /etc/fstab, you can run mount command with just mount point:> mount /tmpTo mount all file systems in /etc/fstab:> mount -a

  25. Exercises/Problems • How do you rename a the mount point associated with a partition? (I.e. change the mount point for /dev/hdb3 from /newdisk to /home?) • What do you do if you’re running out of disk space on a new partition? • What do you need to do after you’ve added a new hard drive?

  26. Homework • As Assigned in class…

More Related