Unix Administration 4


Published on


Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Unix Administration 4

  1. 1. ITI-481: Unix Administration Rutgers University Center for Applied Computer Technologies Christopher Uriarte, Instructor Meeting 4
  2. 2. Today’s Agenda <ul><li>Disk Partitioning </li></ul><ul><li>Directories and File Systems </li></ul><ul><li>Mounting Local File systems </li></ul>
  3. 3. Disk Partitions. <ul><li>A typical UNIX installation will divide one or more hard drives into multiple partitions. </li></ul><ul><li>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 </li></ul><ul><li>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 . </li></ul><ul><li>Disk partition information can be viewed using the ‘df’ command. </li></ul>
  4. 4. Understanding File System Types <ul><li>Different operating systems use different file systems. </li></ul><ul><li>A file system type is essentially the “specification” for how blocks of data are organized on disks. </li></ul><ul><li>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. </li></ul>
  5. 5. Some Common File System Types: <ul><li>FAT – used with DOS, Windows 3.1, Windows95, Windows98 </li></ul><ul><li>FAT32 – used with Windows98/SE, WindowsME an some Windows95 distributions. Can also be used on Windows NT,2000 and XP. </li></ul><ul><li>NTFS – used on Windows NT, 2000 and XP </li></ul><ul><li>UFS (Unix File System) – a generic UNIX file system used on many UNIX flavors. </li></ul><ul><li>EXT2 – a Linux-specific file system used in most Linux distributions </li></ul><ul><li>JFS, ReiserFS, EXT3 – next-generation advance file systems available as an option on some UNIX systems today. (actually, all are available for Linux) </li></ul>
  6. 6. Selecting a File System Type <ul><li>Linux is unusual, as it allows you to choose the file system type of a partition during setup. </li></ul><ul><li>Most UNIX’s use their default file system type during install (usually UFS). </li></ul><ul><li>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) </li></ul>
  7. 7. Partitions and File Systems: A Recap <ul><li>(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. </li></ul><ul><li>There’s several reasons why we partition disks: </li></ul><ul><ul><li>Performance </li></ul></ul><ul><ul><li>Ease of storage management </li></ul></ul><ul><ul><li>Security </li></ul></ul>
  8. 8. Disk Partitioning in UNIX <ul><li>In UNIX, a physical disk partition is associated with a directory path, sometimes referred to as a mount point . </li></ul><ul><li>All files that are in directories associated with a mount point are stored on the mount point’s physical partition. </li></ul><ul><li>If a directory path is not explicitly associated with a physical disk partition, its files are stored under the root ( “/” ) partition. </li></ul>
  9. 9. UNIX Partition Example /usr 2GB / (root) 1.5GB /home 4GB swap Example Partitioning Scheme: Total Hard Drive Space: 8GB Contains all files under the /usr directory (I.e. /usr/local/bin/pico, /usr/bin/vi, etc.) 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. [HARD DRIVE]
  10. 10. Disk Partitioning: Rules to Live By <ul><li>Making disk partitions is easy; Changing them can be hard. </li></ul><ul><li>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. </li></ul><ul><li>You can always create partitions from new hard drive. </li></ul><ul><li>You can always create partitions from un-partitioned space on existing, in-use hard drives. </li></ul>
  11. 11. Example: Adding a Partition Using Un-partitioned Space /dev/hda1 Mounted on /home (Unused) /dev/hda1 Mounted on /home /dev/hda2 Mounted on /home2 You can easily take unused hard disk space, format it, partition it and mount is as a new file system.
  12. 12. Steps Required Make a New Partition <ul><li>Partition empty space on the hard drive </li></ul><ul><li>Format the newly created partition </li></ul><ul><li>Create a mount point for the partition </li></ul><ul><li>Mount the partition </li></ul>
  13. 13. Partitioning Empty Hard Drive Space <ul><li>Empty hard drive space can be partitioned using a utility called fdisk. </li></ul><ul><ul><li>Fdisk allows you to create, delete and modify partitions, as well as to set their partition types. </li></ul></ul><ul><ul><li>Allows you to print the partition table for a particular hard drive. </li></ul></ul><ul><li>Can be started with: /sbin/fdisk <hard drive to edit> </li></ul><ul><ul><li>e.g. /sbin/fdisk /dev/hda </li></ul></ul>
  14. 14. Fdisk: Sample of Help Menu <ul><li># /sbin/fdisk /dev/hda </li></ul><ul><li>Command (m for help): m </li></ul><ul><li>Command action </li></ul><ul><li>a toggle a bootable flag </li></ul><ul><li>b edit bsd disklabel </li></ul><ul><li>c toggle the dos compatibility flag </li></ul><ul><li>d delete a partition </li></ul><ul><li>l list known partition types </li></ul><ul><li>m print this menu </li></ul><ul><li>n add a new partition </li></ul><ul><li>o create a new empty DOS partition table </li></ul><ul><li>p print the partition table </li></ul><ul><li>q quit without saving changes </li></ul><ul><li>s create a new empty Sun disklabel </li></ul><ul><li>t change a partition's system id </li></ul><ul><li>u change display/entry units </li></ul><ul><li>v verify the partition table </li></ul><ul><li>w write table to disk and exit </li></ul><ul><li>x extra functionality (experts only) </li></ul>
  15. 15. Example: Creating a New Partition with Fdisk <ul><li>Launch fdisk – edit hard disk /dev/hda: > /sbin/fdisk /dev/had </li></ul><ul><li>Type “p” to print the current partition table. </li></ul><ul><li>You can now create a new partition, specify the size of the partition and then specify its file system type. </li></ul><ul><li>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. </li></ul><ul><li>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. </li></ul>
  16. 16. Creating Partitions, con’t <ul><li>You will then be asked to specify the starting cylinder – simply choose the default. </li></ul><ul><li>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). </li></ul><ul><li>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. </li></ul><ul><li>Finally, type “w” to write the new partition table and exit – you may have to reboot. </li></ul>
  17. 17. Step 2: Formatting the new File System <ul><li>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. </li></ul><ul><li>Partitions are formatted using the mkfs command. There is a special mkfs, called /sbin/mkfs.ext2 , used to format Linux EXT2 file systems. </li></ul><ul><ul><li>Usage: /sbin/mkfs.ext2 <partition to format> </li></ul></ul><ul><ul><li>e.g. /sbin/mkfs.ext2 /dev/hdb3 </li></ul></ul>
  18. 18. Step 3: Choosing and Creating a Mount Point <ul><li>Now that you have a fresh chunk of useable disk space, you need to decide how you will access it. </li></ul><ul><li>You must choose a unique and empty directory path to be associated with your partition – this is referred to its mount point. </li></ul><ul><li>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. </li></ul>
  19. 19. Step 4: Mounting the New Partition <ul><li>After choosing and creating a mount point, you can mount the partition using the UNIX mount command: </li></ul><ul><ul><li>mount [options] <partition> <mount point> For example: mount –t ext2 /dev/hdb3 /newdisk </li></ul></ul><ul><ul><li>( -t specifies file system type) </li></ul></ul><ul><li>After mounting the file system, you are now ready to use it! </li></ul>
  20. 20. Viewing Mounted File Systems <ul><li>You can view mounted file systems using the “df –k” command: </li></ul><ul><li>Filesystem 1k-blocks Used Available Use% Mounted on </li></ul><ul><li>/dev/hda5 3309736 913788 2227820 29% / </li></ul><ul><li>/dev/hdb1 495204 13 469623 0% /home </li></ul>
  21. 21. Unmounting File Systems <ul><li>File systems are unmounted with the umount command: </li></ul><ul><ul><li>umount <mount point> </li></ul></ul><ul><ul><li>For example: umount /newdisk </li></ul></ul><ul><li>File systems should only be unmounted when they are not in use. </li></ul>
  22. 22. Typical Directory Structure <ul><li>Note: Not all directory paths have their own partitions – in fact, a system may only have 1 partition! </li></ul><ul><li>/ - begins the file system structure (root) </li></ul><ul><li>/boot - kernel files </li></ul><ul><li>/usr – scripts and binary applications </li></ul><ul><li>/sbin – basic system tools </li></ul><ul><li>/home – user home directories </li></ul><ul><li>/var – log files and other time sensitive data </li></ul><ul><li>/etc – configuration files </li></ul><ul><li>/dev – device drivers </li></ul><ul><li>/opt – typical install location for some commercial software </li></ul><ul><li>/tmp – temporary storage </li></ul><ul><li>/mnt – mount points for floppy disks and CD-ROMS </li></ul><ul><li>swap – swap space </li></ul>
  23. 23. Sample Directory Tree with Mount Points
  24. 24. /etc/fstab <ul><li>Specifies what partitions to mount automatically during boot time. </li></ul><ul><li>Entry format: < partition> <mount point> <fs type> <parameters*> <fs_freq*> <fs_passno*> Sample entry: /dev/hda3 /newdisk ext2 defaults 1 2 </li></ul><ul><ul><li>*These fields are usually set to defaults, 1 and 2, respectively. </li></ul></ul><ul><li>For entries in /etc/fstab, you can run mount command with just mount point: > mount /tmp To mount all file systems in /etc/fstab: > mount -a </li></ul>
  25. 25. Exercises/Problems <ul><li>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?) </li></ul><ul><li>What do you do if you’re running out of disk space on a new partition? </li></ul><ul><li>What do you need to do after you’ve added a new hard drive? </li></ul>
  26. 26. Homework <ul><li>As Assigned in class… </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.