Upload
stefan
View
50
Download
0
Tags:
Embed Size (px)
DESCRIPTION
CIS 191 – Lesson 2. Lesson Module Status Slides - draft Flash cards – 16 No-stress quiz – done Web Calendar summary – done Web book pages – done Commands – done Course skills pacing - done Lab – Jim's Classroom PC's – rh9 isos done. CIS 191 - Lesson 2. Quiz. - PowerPoint PPT Presentation
Citation preview
CIS 191 – Lesson 2
Lesson Module Status• Slides - draft• Flash cards – 16• No-stress quiz – done• Web Calendar summary – done• Web book pages – done• Commands – done• Course skills pacing - done• Lab – Jim's• Classroom PC's – rh9 isos done
CIS 191 - Lesson 2
Quiz
Please book close your books, turn off your monitor, take out a piece of paper and answer the following questions:
• In a long listing (ls –l) what code letter is used for a symbolic link?
• Where in the file directory tree is the kernel and how do you recognize it?
• What command and option shows how the drives are partitioned?
CIS 191 – Lesson 2
Objectives Agenda
• Red Hat 9 installation• High level storage overview• Partitioning and making file
systems.• Mounting file systems manually and
automatically.• Making a simple root file system.• Add VMware tools and second hard
drive to a VM.
• Quiz
• Questions from last week
• Storage hardware
• Recognizing storage devices
• Geometry
• Exercise: RH9 install
• Disk partitions • Exercise: Partitioning
• Making file systems • Mounting
• File types
• Exercise: Putting it all together
• Wrap up
= hands on exercise for topic
Storage and File Systems
CIS 191A
Lesson 1
VMware ServerUbuntu 8.04
Lesson 2
PartitioningMake file systemsRH9
Lesson 3
BootingDual bootFedora 9/DOS
Lesson 6
RPM, apt-getTarballsCustom Distro
Lesson 5
TroubleshootingopenSUSE 11
Lesson 4
RootingCentOS Install
Lesson 7
X windowsDebian InstallReview
Final
Course Skills Pacing
CIS 191 - Lesson 2
Last weeks Assignment
1. Student surveys due today
2. Questions from previous week?• vmware?• ubuntu install?• course syllabus?
CIS 191 – Lesson 2
Review ExerciseBecoming Root on Ubuntu
• Howto set the password for root on ubuntu:sudo passwd root[see white board][see white board]
• Switch to root user: su -
} Only need to do this once to enable root on Ubuntu
The - gives you root's path and environment
CIS 191 – Lesson 2
• Show network configuration:ifconfigroute –ncat /etc/resolv.conf
• Show hostname: hostname
• Show disk partitions: fdisk –l• Mounts: mount• Show disk space usage: du –s /*
• Show CPU info: cat /proc/cpuinfo• Show RAM size and usage: free –m or top
• Show installed packages: dpkg -l • Find the kernel version: uname –r• Default runlevel: runlevel
Review Exercise (continued) Exploring Ubuntu 8.04 Desktop Virtual Machine
Tip:man command and google are great ways to get information on commands
CIS 191 – Lesson 2
Review Exercise (continued) Team Process
• Each table is one team• CIS 81, 82, 83 alumni identify themselves to the class• Each team picks a pilot and a scribe• Make introductions and share:
• High school you attended• Longest job held
• Team helps the pilot issue each of the quick inventory commands on previous slide.• Team answers their 3 questions on the next slide.• When finished, scribe writes answers on the white board.• Reports – when all teams are done, we will go around the room, each scribe will introduce the members of his or her team. Each pilot will explain how they got their answers.
CIS 191 – Lesson 2
Table 1-4• What network (n.n.n.n /n) are we on in 2501?• Where is the kernel and what is its name?• What IP addresses are configured for the gateway and DNS server?
Review Exercise (continued) Teams
Table 5-8• What linux command would print a list of top level directories sorted by size? • What are the top 3 largest level directories?• What version is the kernel?
Table 9-12• What partition is / mounted on?• What partition is used for swap space?• What happens if your run fdisk –l as a non-root user?
Table 13-16• What processor (model and speed) is the VM using and what is the cache size?• What is the name of one of the Common UNIX Printing System (CUPS) packages that have been installed?• Is CUPS running now?
Table 9-12• What is the default runlevel for the VM.• What does runlevel N mean?• What is the hostname and IP address?
Table 13-16• How much RAM does your VM have?• How much memory is being used and how much is free?• What are the –m and –k options for the free command?
CIS 191 - Lesson 2
Housekeeping
CIS 191 - Lesson 2
• Call roll• Final surveys• Fix TBA signup sheet• Opus accounts• lllllfff/lllllffff1
CIS 191 - Lesson 2
StorageDevices
CIS 191 - Lesson 2
Floppy drive and diskettes
Hard drive (IDE and SCSI)
USB flash drive (aka pen drive)
Storage Devices
CIS 191 - Lesson 2
DAS – Direct Attached StorageNAS – Network Attached StorageSAN – Storage Area Networks
Storage Devices
CIS 191 - Lesson 2
IDE drives: Primary master (/dev/hda)Primary slave (/dev/hdb)Secondary master (/dev/hca)Secondary slave (/dev/hdd)
SCSI drives: Each SCSI disk has a target id (1-7) or (1-14). (/dev/sda, /dev/sdb, ...)
Recognizing and specifying storage devices
CIS 191 - Lesson 2
USB Flash (pen) drives: Same device naming as SCSI drives (can use dmesg to distinguish)
Floppies: First drive (/dev/fd0)Second drive (/dev/fd1)…
Recognizing and specifying storage devices
CIS 191 - Lesson 2
RecognizingStorageDevices
CIS 191 - Lesson 2
Master IDE drive on primary
One IDE drive
Recognizing and specifying storage devices
CIS 191 - Lesson 2
Master IDE drive on Secondary
Two IDE drives
Recognizing and specifying storage devices
Master IDE drive on primary
CIS 191 - Lesson 2
USB flash (pen) drive
IDE hard drive
Floppy drive
Recognizing and specifying storage devices
CIS 191 - Lesson 2
First SCSI drive
First SCSI drive, first partition
First SCSI drive, second partition
Used for LVM
fdisk doesn’t like LVM yet, so we will suppress bogus errors
SCSI drive (with LVM)
Recognizing and specifying storage devices
CIS 191 - Lesson 2
SCSI hard drive
USB flash drive
SCSI and USB Flash (pen) drive
Recognizing and specifying storage devices
CIS 191 - Lesson 2
dmsg command output
Plugging in USB flash drive starts here
Device identification (/dev/sdb) shows here
and log ends here
CIS 191 - Lesson 2
Geometry
14 tracks8 sectors per
track
CIS 191 - Lesson 2
Example Physical CHS Disk Drive Geometry
One sectorOne track
3 platters6 heads
14 cylinders
One imaginary cylinder
One head on each side of platter
size = cylinders x heads x sectors per track x 512 bytessize = 14 x 6 x 8 x 512 = 344,064 bytes
CIS 191 - Lesson 2
Disk Drive Geometry
Times have changed!
•Disk drives are no longer limited to 1024 cylinders (old BIOS restriction)
•Modern track density has hit over tens of thousands of tracks per inch (the old 3.5”diskette had 80 per side)
•Zone bit recording places more sectors per track on outside tracks. E.g. A IBM 34.2 GB Deskstar has 272 to 452 sectors per track.
•NOTE: The OS uses logical disk geometry which does not match physical disk geometry.
•Modern drives use Logical Block Addressing (LBA) rather than the old CHS addressing.
CIS 191 - Lesson 2
Disk Drive Geometryphysical ≠ logical
Modern drives have variable number of sectors per track. It is not possible to represent their full capacity using the old CHS method.
The BIOS shows 16 logical heads and 63 logical sectors per track and adjust the number of logical cylinders to approximate the full capacity.
The OS fdisk shows 255 logical heads and 63 logical sectors per track and then adjusts logical cylinders accordingly.
Disk /dev/hda: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
CIS 191 - Lesson 2
Disk sizes (fdisk command)5GB VMWare Drive
5 x 1024 x 1024 x 1024 = 5,368,709,120 bytes
255 heads x 63 sectors/track x 652 cylinders x 512 bytes
= 5,362,882,560 bytesNOTE
This is logical (not physical) disk geometry
Cylinders Blocks(1 block = 1024 bytes)
CIS 191 - Lesson 2
Disk sizes (df command)
3,5266,204 x 1000 x (1000/1024) = 3,443,558,594 bytes
= 3.4 GB
101,107 x 1000 x (1000/1024)= 98,737,304 bytes
= 99 MB
NOTE: 1 computer KB = 1,024 bytes (2 to the 10th power)
1 human KB = 1,000 bytes
CIS 191 - Lesson 2
Exercise: Partitioning During Installation
1. Create new VM• Configuration: Typical• Guest OS: Linux, Version: Red Hat Linux• VM name: rh9, Location: See whiteboard• Network connection: Bridged• Disk size: 5GB, don’t allocate space now
2. CD: Use ISO image: rh9-shrike-cd1.iso
3. Install Red Hat• Installation type: Workstation
CIS 191 - Lesson 2
Exercise: Partitioning During Installation(continued)
4. Disk Partitioning Setup: • Manually
partition with Disk Druid
• /boot (100 MB) force primary
• / (2500 MB) force primary
• swap (256 MB) force primary
• /home (1000 MB) extended
CIS 191 - Lesson 2
Exercise: Partitioning During Installation(continued)
5. Network Devices: • DHCP• Hostname: rh9
CIS 191 - Lesson 2
Exercise: Partitioning During Installation(continued)
5. Firewall: • Medium• Trusted: eth0 (checked)• Allow incoming: SSH (checked), DHCP (checked)
6. Time zone: Los Angeles
7. Set root password: see whiteboard
8. Customize the set of packages:• Text-based Internet: remove check• Office/Productivity: remove check• Sound and Video: remove check• Graphics: remove check• Games and Entertainment: remove check
9. Don't make emergency floppy
CIS 191 - Lesson 2
Exercise: Partitioning During Installation(continued)
10. Normal user: cis191 and password: see whiteboard
11. Don’t register the system
12. Log in and Install VMware Tools• Install RPM• vmware-config-tools.pl
• 800 x 600
11. Shut down VM
12. Snapshot VM
13. Add a floppy drive (if necessary)
14. Add a second SCSI drive (2 GB, don't allocate space now)
CIS 191 - Lesson 2
DiskPartitions
CIS 191 - Lesson 2
Free Space
Setting up Hard DrivesStep 1 – Add hard drive to computer
Add the hard drive:
•Low-level formatting has already been done at the factory (lays out the physical tracks and sectors).
•There are no partitions yet.
•There are no file systems yet.
Note: Floppies, unlike hard drives, can be low-level formatted with the fdformat command
CIS 191 - Lesson 2
Partition Boot Sector
Data
Master Boot Record (MBR)
Free Space
Setting up Hard DrivesStep 2 - Partition the hard drive
Partition Boot Sector
Data
Partition the hard drive:
•The MBR is on the very first sector and is 512 bytes long.
•The first 446 bytes of the MBR gets system boot code.
•The next 64 bytes of the MBR gets the partition table.
•The last 2 bytes are marked 0xAA55.
CIS 191 - Lesson 2
Partition Boot Sector
Data
Master Boot Record (MBR)
Free Space
Setting up Hard DrivesStep 2 - Partition the hard drive
Partition Boot Sector
Data
Primarypartition
Primarypartition
The MBR partition table records the location, status and type of each primary partition.
Each added partition has its own boot sector at the beginning.
CIS 191 - Lesson 2
Setting up Hard DrivesStep 2 - Partition the hard drive
Partition Boot Sector
Data
Master Boot Record (MBR)
Partition Boot Sector
Data
Partition Boot Sector
Data
Partition Boot Sector
Data
Primarypartition
Primarypartition
Primarypartition
Primarypartition
The maximum number of primary partitions is four.
CIS 191 - Lesson 2
Partition Boot Sector
Data
Master Boot Record (MBR)
Partition Boot Sector
Data
Partition Boot Sector
Data
Partition Boot Sector
Data
Primarypartition
Primarypartition
Primarypartition
Extendedpartition
One of the four primary partitions can be an extended partition
An extended may contain an arbitrary number of logical partitions
Unused Boot Sector
Data
Unused Boot Sector
Logicalpartition
Logicalpartition
Setting up Hard DrivesStep 2 - Partition the hard drive
CIS 191 - Lesson 2
Partition Boot Sector
Data
Master Boot Record (MBR)
Partition Boot Sector
Data
Partition Boot Sector
Data
Partition Boot Sector
Data
Unused Boot Sector
Data
Unused Boot Sector
Setting up Hard DrivesStep 3 – Add file systems to partitions
Superblock
Inode Table
ext2 file system
Data Blocks
CIS 191 - Lesson 2
fdisk and mountShow current partitions and their usage
Partition Boot Sector
/boot
Master Boot Record (MBR)
Partition Boot Sector
/
Partition Boot Sector
swap
Partition Boot Sector
/home
Unused Boot Sector
Free Space
/dev/sda1
/dev/sda2
/dev/sda3
/dev/sda4 /dev/sda5
CIS 191 - Lesson 2
Specifying partitions
Partitions are labeled by Linux as the drive name following by a number. The numbers 1-4 are reserved for the first four primary partitions. 5 or higher indicates it is a logical partition.
Examples:
/dev/hda1 = first partition (primary) on the primary master IDE drive.
/dev/sdb3 = third partition (primary) on the second SCSI drive.
/dev/sda5 = fifth partition (logical partition) on the first SCSI drive.
CIS 191 – Lesson 2
[root@rh9 root]# fdisk -l
Disk /dev/sda: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 332 2562367+ 83 Linux/dev/sda3 333 365 265072+ 82 Linux swap/dev/sda4 366 652 2305327+ 5 Extended/dev/sda5 366 492 1020096 83 Linux/dev/sda6 493 505 104391 83 Linux
Disk /dev/sdb: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table[root@rh9 root]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help):
Specifying partitionsAdd 1 primary and 1 extended to new drive
/dev/sda has been partitioned already.
/dev/sdb has not been partitioned yet.
CIS 191 – Lesson 2
Command (m for help): nCommand action e extended p primary partition (1-4)ePartition number (1-4): 1First cylinder (1-261, default 1): 1Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): 50
Command (m for help): nCommand action l logical (5 or over) p primary partition (1-4)lFirst cylinder (1-50, default 1):Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-50, default 50): 10
Command (m for help): p
Disk /dev/sdb: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System/dev/sdb1 1 50 401593+ 5 Extended/dev/sdb5 1 10 80262 83 Linux
Command (m for help):
MBR
Boot Sector
Unused
Free
/dev/s
db1
/dev
/sdb
5
Specifying partitionsAdd 1 primary and 1 extended to new drive
Note: The second partition added is number 5 because it is in an extended partition. Numbers 1-4 are reserved for the four primary partitions.
CIS 191 - Lesson 2
fdiskPartition Utility – (n)ew and (p)rint
[root@rh9 root]# fdisk /dev/sda
Command (m for help): nFirst cylinder (493-652, default 493):Using default value 493Last cylinder or +size or +sizeM or +sizeK (493-652, default 652): +100MCommand (m for help): p
Disk /dev/sda: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 332 2562367+ 83 Linux/dev/sda3 333 365 265072+ 82 Linux swap/dev/sda4 366 652 2305327+ 5 Extended/dev/sda5 366 492 1020096 83 Linux/dev/sda6 493 505 104391 83 Linux
Command (m for help):
Boot Sector
/boot
MBR
Boot Sector
/
Boot Sector
swap
Boot Sector
/home
Unused
Free Space
Unused
/dev
/sda
5
/dev
/sda
6
/dev
/sda
2
/dev
/sda
3
/dev
/sda
1
/dev/s
da4
CIS 191 - Lesson 2
fdiskPartition Utility – (m)enu of commands
Command (m for help): mCommand 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)
Command (m for help):
Boot Sector
/boot
MBR
Boot Sector
/
Boot Sector
swap
Boot Sector
/home
Unused
Free Space
Unused
/dev
/sda
5
/dev
/sda
6
/dev
/sda
2
/dev
/sda
3
/dev
/sda
1
/dev/s
da4
CIS 191 - Lesson 2
fdiskPartition Utility – (w)rite out partition table
Command (m for help): wThe partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table.The new table will be used at the next reboot.Syncing disks.[root@rh9 root]# partprobe
Boot Sector
/boot
MBR
Boot Sector
/
Boot Sector
swap
Boot Sector
/home
Unused
Free Space
Unused
/dev
/sda
5
/dev
/sda
6
/dev
/sda
2
/dev
/sda
3
/dev
/sda
1
/dev/s
da4
Use partprobe to update the kernel without rebooting. This is required if you want to mount a new partition.
CIS 191 - Lesson 2
fdiskPartition Utility – the l option
[root@rh9 root]# fdisk -l
Disk /dev/sda: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 332 2562367+ 83 Linux/dev/sda3 333 365 265072+ 82 Linux swap/dev/sda4 366 652 2305327+ 5 Extended/dev/sda5 366 492 1020096 83 Linux/dev/sda6 493 505 104391 83 Linux
Boot Sector
/boot
MBR
Boot Sector
/
Boot Sector
swap
Boot Sector
/home
Unused
Free Space
Unused
/dev
/sda
5
/dev
/sda
6
/dev
/sda
2
/dev
/sda
3
/dev
/sda
1
/dev/s
da4
CIS 191 - Lesson 2
Exercise: Partitioning with fdisk
1. On the rh9 VM, use fdisk –l to show your hard drive and the current partitions.
2. Now run fdisk on your hard drive3. Add a new 100M partition to /dev/sda.4. Type p to verify.5. Delete the partition you just added and verify.6. Add the partition back in again and verify.7. Change the system ID of the new partition to Amoeba
and verify.8. Change it back to Linux and verify.9. Type W to write out partition table and exit.10. Type partprobe to update the kernel without rebooting.11. Run fdisk –l to show your hard drive and the updated
partitions.12. Check: Your new partition should be /dev/sda6
CIS 191 - Lesson 2
Making File
Systems
CIS 191 - Lesson 2
[root@rh9 root]# fdisk -l
Disk /dev/sda: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 332 2562367+ 83 Linux/dev/sda3 333 365 265072+ 82 Linux swap/dev/sda4 366 652 2305327+ 5 Extended/dev/sda5 366 492 1020096 83 Linux/dev/sda6 493 505 104391 83 Linux
Disk /dev/sdb: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table[root@rh9 root]# echo "Rich was here" > /dev/sdb[root@rh9 root]# xxd /dev/sdb | more0000000: 5269 6368 2077 6173 2068 6572 650a 0000 Rich was here...0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................ < snipped >................0000150: 0000 0000 0000 0000 0000 0000 0000 0000 ................[root@rh9 root]#
/dev/sdb is a newly added un-partitioned drive
You can write and read to the drive however it is very clumsy compared to using a file system*
dd command (continued)Reading and writing directly to a drive
*Never do this to a drive containing important data
[root@rh9 root]# echo "Rich was here too" > test[root@rh9 root]# wc -c test 18 test[root@rh9 root]#[root@rh9 root]# dd if=test of=/dev/sda6 bs=1 count=1818+0 records in18+0 records out[root@rh9 root]# dd if=/dev/sda6 bs=1 count=18Rich was here too18+0 records in18+0 records out[root@rh9 root]#[root@rh9 root]# xxd /dev/sda6 | more0000000: 5269 6368 2077 6173 2068 6572 6520 746f Rich was here to0000010: 6f0a 0000 0000 0000 0000 0000 0000 0000 o...............0000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................< snipped >[root@rh9 root]# dd if=/dev/zero of=/dev/sda6 bs=1 count=1818+0 records in18+0 records out[root@rh9 root]# xxd /dev/sda6 | more0000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................< snipped >
CIS 191 - Lesson 2
/dev/sdb6 is a newly added, un-mounted partition on /dev/sda
/dev/zero has an unlimited numbers of binary zeros. Can be used to zero out a partition or drive.*
dd command (continued)Reading and writing directly to a partition
We can also write and read directly to the partition.*
*Never do this to a partition containing important data
CIS 191 - Lesson 2
Adding File Systems
Superblock
Inode Table
Data Blocks
Analogy: making a file system on an empty partition is like painting the stripes on a parking lot. It organizes the space and makes it efficient.
ext2 file system
CIS 191 - Lesson 2
Adding File Systems
Superblock
Inode Table
mkfs –t ext2 /dev/sda6
Data Blocks
Boot Sector
/boot
MBR
Boot Sector
/
Boot Sector
swap
Boot Sector
/home
Unused
Free Space
Unused
/dev
/sda
5
/dev
/sda
6
/dev
/sda
2
/dev
/sda
3
/dev
/sda
1
/dev/s
da4
CIS 191 - Lesson 2
mkfs –t type device -t ext2 –t ext3 (has journaling) -t vfat (compatible with Windows) -t jfs (IBM’s journaled file system) -t reiserfs
For ext2 or ext3 use: -N option to specify number of inodes-m option to specify % blocks reserved for superuser (default 5%)-L option to set the volume label for the file system
Example: mkfs –t ext3 /dev/sda6(puts ext3 file system on 6th partition of 1st SCSI drive)
Example: mkfs –t ext2 –m 0 –N 1000 –L myfiles /dev/sda6(puts ext2 file system with 1000 inodes, no space reserved for superuser, volume label “myfiles” on 6th partition of 1st SCSI drive, )
Note: mkfs is actually a front end for various file systems builders.
[root@rh9 root]# ls /sbin/mkfs*/sbin/mkfs /sbin/mkfs.ext2 /sbin/mkfs.jfs /sbin/mkfs.reiserfs/sbin/mkfs.cramfs /sbin/mkfs.ext3 /sbin/mkfs.msdos /sbin/mkfs.vfat
mkfs command
[root@partide root]# fdisk -l /dev/sda
Disk /dev/sda: 999 MB, 999816704 bytes4 heads, 8 sectors/track, 61023 cylindersUnits = cylinders of 32 * 512 = 16384 bytes
Device Boot Start End Blocks Id System/dev/sda1 * 1 61024 976379+ b Win95 FAT32[root@partide root]#[root@partide root]# umount /mnt[root@partide root]# mount /dev/sda1 /mnt[root@partide root]# ls -l /mnttotal 713064-rwxr-xr-x 1 root root 730177536 Mar 23 23:18 KNOPPIX_V5.1.1CD-2007-01-04-EN.iso[root@partide root]#
CIS 191 - Lesson 2
This pen drive works with Windows or Linux
File SystemsFAT32 file system
CIS 191 - Lesson 2
Superblock
Inode Table
Data Blocks
ext2 file system
ext2 file system
Superblock has:• File system type, label, inode count, block
count, etc. about entire file system.• Redundant copies are maintained.• Use: dumpe2fs –h /dev/sda2 to see / superblock info on rh9 VM
inodes have:• file type, permissions, link count, owner,
group, size, major and minor numbers, creation date, modification date, access date, pointers to data blocks.
• Does not contain filenames which are kept in directories.
• Use stat command to see inode information
Data blocks have actual file and directory data.
CIS 191 - Lesson 2
Superblock
Inode Table
ext2 file system
Data Blocks
[simmsben@opus ~]$ls -il letter102609 -rw-r--r-- 1 simmsben cis90 1044 Jul 20 2001 letter
Hello Mother! Hello Father!
Here I am at Camp Granada. Things are very entertaining,and they say we'll have some fun when it stops raining.
All the counselors hate the waiters, and the lake hasalligators. You remember Leonard Skinner? He gotptomaine poisoning last night after dinner.
Now I don't want this to scare you, but my bunk mate hasmalaria. You remember Jeffrey Hardy? Their about toorganize a searching party.
Take me home, oh Mother, Father, take me home! I hate Granada.Don't leave me out in the forest where I might get eatenby a bear! Take me home, I promise that I won't make noise,or mess the house with other boys, oh please don't make mestay -- I've been here one whole day.
Dearest Father, darling Mother, how's my precious littlebrother? I will come home if you miss me. I will evenlet Aunt Bertha hug and kiss me!
Wait a minute! It's stopped hailing! Guys are swimming!Guys are sailing! Playing baseball, gee that's better!Mother, Father, kindly disregard this letter.
Alan Sherman
bigfile 102574bin 102575letter 102609
bigfile 102574bin 102575letter 102609
102609
-
1
simmsben
cis90
1044
2001-07-20
2008-08-08
2008-06-20
Pointer(s) to data blocks
inode number
Type
Number of links
User
Group
Size
Modification time
Access Time
Change time
Pointer(s) to data blocks
rw-r—r-- Permissions
CIS 191 - Lesson 2
ext2 file systemUsing dumpe2fs –h to show superblock information
[root@rh9 root]# dumpe2fs -h /dev/sda2dumpe2fs 1.32 (09-Nov-2002)Filesystem volume name: /Last mounted on: <not available>Filesystem UUID: b552eed8-4c9d-4f8f-9edf-dd76037f82bdFilesystem magic number: 0xEF53Filesystem revision #: 1 (dynamic)Filesystem features: has_journal filetype needs_recovery sparse_superDefault mount options: (none)Filesystem state: cleanErrors behavior: ContinueFilesystem OS type: LinuxInode count: 320640Block count: 640591Reserved block count: 32029Free blocks: 228375Free inodes: 220820First block: 0Block size: 4096Fragment size: 4096Blocks per group: 32768Fragments per group: 32768Inodes per group: 16032Inode blocks per group: 501Filesystem created: Fri Jul 18 09:37:33 2008Last mount time: Fri Jul 18 17:06:16 2008Last write time: Fri Jul 18 17:06:16 2008Mount count: 3Maximum mount count: -1Last checked: Fri Jul 18 09:37:33 2008Check interval: 0 (<none>)Reserved blocks uid: 0 (user root)Reserved blocks gid: 0 (group root)First inode: 11Inode size: 128Journal UUID: <none>Journal inode: 8Journal device: 0x0000First orphan inode: 229443
[root@rh9 root]#
If you leave off the –h option you will also see the data block status as well.
CIS 191 - Lesson 2
ext2 file systemUsing stat command to show Inode details
[root@rh9 root]# lsanaconda-ks.cfg install.log install.log.syslog test testdir[root@rh9 root]# ls -ltotal 36-rw-r--r-- 1 root root 1220 Jul 18 16:57 anaconda-ks.cfg-rw-r--r-- 1 root root 19626 Jul 18 16:51 install.log-rw-r--r-- 1 root root 2895 Jul 18 16:51 install.log.syslog-rw-r--r-- 1 root root 18 Jul 18 17:24 testdrwxr-xr-x 2 root root 4096 Jul 20 18:41 testdir[root@rh9 root]# stat test testdir File: `test' Size: 18 Blocks: 8 IO Block: 4096 Regular FileDevice: 802h/2050d Inode: 37058 Links: 1Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)Access: 2008-07-20 18:40:47.000000000 -0700Modify: 2008-07-18 17:24:47.000000000 -0700Change: 2008-07-18 17:24:47.000000000 -0700
File: `testdir' Size: 4096 Blocks: 8 IO Block: 4096 DirectoryDevice: 802h/2050d Inode: 20964 Links: 2Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)Access: 2008-07-20 18:41:08.000000000 -0700Modify: 2008-07-20 18:41:08.000000000 -0700Change: 2008-07-20 18:41:08.000000000 -0700
[root@rh9 root]#
Note: The name of the file is not kept in the Inode. It is kept as data in a directory file.
CIS 191 - Lesson 2
ext2 file systemlost+found directory
[root@rh9 root]# mkfs -t ext2 /dev/sda6mke2fs 1.32 (09-Nov-2002)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)26104 inodes, 104391 blocks5219 blocks (5.00%) reserved for the super userFirst data block=113 block groups8192 blocks per group, 8192 fragments per group2008 inodes per groupSuperblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729
Writing inode tables: doneWriting superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@rh9 root]# mount /dev/sda6 /mnt[root@rh9 root]# ls /mntlost+found[root@rh9 root]# ls -l /mnttotal 12drwx------ 2 root root 12288 Jul 21 08:22 lost+found[root@rh9 root]#
Note: The lost+found directory is created when you make a ext2 or ext3 file system. This is where the fsck utility will place any recovered data it finds when checking a file system. Don’t delete it!
CIS 191 - Lesson 2
Exercise: Make some file systems
1. On the rh9 VM, use fdisk –l to show your hard drive and the current partitions.
2. Make and re-make file systems on /dev/sda6:
mkfs –t ext2 /dev/sda6mkfs –t ext3 /dev/sda6mkfs –t jfs /dev/sda6mkfs –t vfat /dev/sda6mkfs –t reiserfs /dev/sda6mkfs –t ext3 –N 9000 dev/sda6mkfs –t ext3 –N 9000 –m 10 dev/sda6mkfs –t ext3 –N 9000 –m 10 –L /myfiles /dev/sda6
CIS 191 - Lesson 2
Mounting File
Systems
CIS 191 - Lesson 2
Mounting and Un-mounting file systems • mount [device-file] [directory] • umount [device-file | directory]
Mount information1./etc/fstab (what to mount at boot time)2./etc/mtab (current mount status)
Mounting File Systems
CIS 191 - Lesson 2
/
/bin
/etc
/mnt
/cdrom
On the rh9 VM
[root@rh9 root]# mount/dev/sda2 on / type ext3 (rw)none on /proc type proc (rw)/dev/sda1 on /boot type ext2 (rw)none on /dev/pts type devpts (rw,gid=5,mode=620)/dev/sda5 on /home type ext3 (rw)none on /dev/shm type tmpfs (rw)
[root@rh9 root]# cat /etc/mtab/dev/sda2 / ext3 rw 0 0none /proc proc rw 0 0/dev/sda1 /boot ext2 rw 0 0none /dev/pts devpts rw,gid=5,mode=620 0 0/dev/sda5 /home ext3 rw 0 0none /dev/shm tmpfs rw 0 0[root@rh9 root]#
[root@rh9 root]# ls -F /home /boot /mnt/boot:boot.b kernel.h module-info-2.4.20-6 [email protected] lost+found/ os2_d.b vmlinuz-2.4.20-6config-2.4.20-6 message System.map@grub/ message.ja System.map-2.4.20-6initrd-2.4.20-6.img module-info@ vmlinux-2.4.20-6
/home:lost+found/ rsimms/
/mnt:cdrom/ floppy/ hgfs/[root@rh9 root]#
/dev
/boot
/home
/rsimms
/grub
/lost+found
/lost+found
/dev/sda1
/dev/sda2
/dev/sda5
/dev/sda6
/floppy
/hgfs
mount command with no arguments shows current mount status in /etc/mtab
Showing current mount status
CIS 191 - Lesson 2
/
/bin
/etc
/mnt
/dir1
On the rh9 VM
[root@rh9 root]# mkfs -t ext3 /dev/sda6mke2fs 1.32 (09-Nov-2002)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)26104 inodes, 104391 blocks5219 blocks (5.00%) reserved for the super userFirst data block=113 block groups8192 blocks per group, 8192 fragments per group2008 inodes per groupSuperblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729
Writing inode tables: doneCreating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@rh9 root]# mount /dev/sda6 /mnt[root@rh9 root]# cd /mnt[root@rh9 mnt]# mkdir dir1 dir2[root@rh9 mnt]# lsdir1 dir2 lost+found[root@rh9 mnt]# cd[root@rh9 root]# ls /mntdir1 dir2 lost+found[root@rh9 root]# umount /mnt[root@rh9 root]# ls /mntcdrom floppy hgfs[root@rh9 root]#
/dev
/boot
/home
/rsimms
/grub
/lost+found
/lost+found
/fdir2
/lost+found
/dev/sda1
/dev/sda2
/dev/sda5
/dev/sda6
mount will overlay the new files ystem on a directory in the current file hierarchy. The old directory is no longer accessible until the new one is un-mounted
Making a file system and mounting it
/dir1
/fdir2
/lost+found
/
/bin /etc /mnt
/cdrom
/dev/boot /home
/rsimms
/grub
/lost+found
/lost+found
/floppy
/hgfs
/lib
/dev/sda6
/dev/sda1
/dev/sda5
Mounting File SystemsLike pinning the tail on the donkey
mount /dev/sda6 /mnt
/
/bin /etc /mnt
/dir1
/dev/boot /home
/rsimms
/grub
/lost+found
/lost+found
/dir2
/lost+found
/lib
/dev/sda1
/dev/sda5
Mounting File SystemsLike pinning the tail on the donkey
/dev/sda6
mount /dev/sda6 /mnt
Mounting File SystemsCaveats
• Don’t mount a file system to a directory you are in.
• You can’t un-mount a file system you have cd’ed into:
[root@rh9 mnt]# umount /mntumount: /mnt: device is busy[root@rh9 mnt]# cd[root@rh9 root]# umount /mnt[root@rh9 root]#
CIS 191 - Lesson 2
[root@rh9 root]# mount/dev/sda2 on / type ext3 (rw)none on /proc type proc (rw)/dev/sda1 on /boot type ext2 (rw)none on /dev/pts type devpts (rw,gid=5,mode=620)/dev/sda5 on /home type ext3 (rw)none on /dev/shm type tmpfs (rw)
[root@rh9 root]# cat /etc/mtab/dev/sda2 / ext3 rw 0 0none /proc proc rw 0 0/dev/sda1 /boot ext2 rw 0 0none /dev/pts devpts rw,gid=5,mode=620 0 0/dev/sda5 /home ext3 rw 0 0none /dev/shm tmpfs rw 0 0[root@rh9 root]#
devicemount point
file system type
mount options
dump frequency
fsckpass
Note: spaces added to output above for readability
Mounting File Systemsmount command and /etc/mtab
CIS 191 - Lesson 2
[root@rh9 root]# cat /etc/fstab
LABEL=/ / ext3 defaults 1 1LABEL=/boot /boot ext2 defaults 1 2none /dev/pts devpts gid=5,mode=620 0 0LABEL=/home /home ext3 defaults 1 2none /proc proc defaults 0 0none /dev/shm tmpfs defaults 0 0/dev/sda3 swap swap defaults 0 0/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
devicemount point
file system type
mount options
dump frequency
fsckpass
Note: spacing modified in output above for readability
Mounting File Systems/etc/fstab
/etc/fstab is used to automatically mount file systems at boot time
CIS 191 - Lesson 2
[root@rh9 root]# cat /etc/fstab
LABEL=/ / ext3 defaults 1 1LABEL=/boot /boot ext2 defaults 1 2none /dev/pts devpts gid=5,mode=620 0 0LABEL=/home /home ext3 defaults 1 2none /proc proc defaults 0 0none /dev/shm tmpfs defaults 0 0/dev/sda3 swap swap defaults 0 0/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
devicemount point
file system type
mount options
dump frequency
fsckpass
Note: spacing modified in output above for readability
Swap Space/etc/fstab
/etc/fstab is used to automatically mount file systems at boot time
CIS 191 - Lesson 2
File Types
CIS 191 – Lesson 2
File Types and Commands
Note: Other files types includes sockets (s) and named piped (p)
Note: Leverage existing device files when making new special files to get correct major and minor numbers.
Long listing code (ls –l)
Type How to make one
d directory mkdir
- regular touch
l symbolic link ln -s
c special (character, unbuffered) mknod
b special (block, buffered) mknod
CIS 191 – Lesson 2
File Types and Commands
Long listing code (ls –l)
Type How to make one
d directory mkdir
- regular touch
l symbolic link ln -s
c special (character, unbuffered) mknod
b special (block, buffered) mknod
CIS 191 - Lesson 2
Exercise: Putting it all together:
•Add a partition to the new second drive on the rh9 VM.
•Make a ext3 file system on it.
•Make a starter root file system.
CIS 191 - Lesson 2
Everything nowShow current drives and partitions
[root@rh9 root]# fdisk -l
Disk /dev/sda: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 332 2562367+ 83 Linux/dev/sda3 333 365 265072+ 82 Linux swap/dev/sda4 366 652 2305327+ 5 Extended/dev/sda5 366 492 1020096 83 Linux/dev/sda6 493 505 104391 83 Linux
Disk /dev/sdb: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table[root@rh9 root]#
CIS 191 - Lesson 2
Everything nowAdd a partition to the new drive
[root@rh9 root]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-261, default 1):Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): 50
Command (m for help):
CIS 191 - Lesson 2
Everything nowUpdate partition table and kernel
Command (m for help): p
Disk /dev/sdb: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System/dev/sdb1 1 50 401593+ 83 Linux
Command (m for help): wThe partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table.The new table will be used at the next reboot.Syncing disks.[root@rh9 root]# partprobe
CIS 191 - Lesson 2
Everything nowMake a ext3 filesystem on the new partition
[root@rh9 root]# mkfs -t ext3 /dev/sdb1mke2fs 1.32 (09-Nov-2002)warning: 184 blocks unused.
Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)100744 inodes, 401409 blocks20079 blocks (5.00%) reserved for the super userFirst data block=149 block groups8192 blocks per group, 8192 fragments per group2056 inodes per groupSuperblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: doneCreating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 26 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@rh9 root
CIS 191 - Lesson 2
[root@rh9 root]# mount /dev/sdb1 /mnt[root@rh9 root]# ls /mntlost+found[root@rh9 root]# cd /mnt[root@rh9 mnt]# mkdir bin dev lib[root@rh9 mnt]# cd bin[root@rh9 bin]# cp /bin/bash .[root@rh9 bin]# ln -s bash sh[root@rh9 bin]# cd ../lib[root@rh9 lib]# ldd /bin/bash libtermcap.so.2 => /lib/libtermcap.so.2 (0x40025000) libdl.so.2 => /lib/libdl.so.2 (0x40029000) libc.so.6 => /lib/tls/libc.so.6 (0x42000000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)[root@rh9 lib]# cp /lib/libtermcap.so.2 .[root@rh9 lib]# cp /lib/libdl.so.2 .[root@rh9 lib]# cp /lib/tls/libc.so.6 .[root@rh9 lib]# cp /lib/ld-linux.so.2 .[root@rh9 lib]# cd ../dev[root@rh9 dev]# ls -l /dev/consolecrw------- 1 root root 5, 1 Jul 21 07:00 /dev/console/dev/console[root@rh9 dev]# mknod console c 5 1[root@rh9 dev]# ls -l /dev/sda /dev/sda1brw-rw---- 1 root disk 8, 0 Jan 30 2003 /dev/sda/dev/sdabrw-rw---- 1 root disk 8, 1 Jan 30 2003 /dev/sda1/dev/sda1[root@rh9 dev]# mknod sda b 8 0[root@rh9 dev]# mknod sda1 b 8 1
Everything nowMake a starter root file system
CIS 191 - Lesson 2
[root@rh9 mnt]# ls -lR.:total 15drwxr-xr-x 2 root root 1024 Jul 21 15:24 bindrwxr-xr-x 2 root root 1024 Jul 21 15:27 devdrwxr-xr-x 2 root root 1024 Jul 21 15:25 libdrwx------ 2 root root 12288 Jul 21 15:12 lost+found
./bin:total 616-rwxr-xr-x 1 root root 626028 Jul 21 15:24 bashlrwxrwxrwx 1 root root 4 Jul 21 16:13 sh -> bash
./dev:total 0crw-r--r-- 1 root root 5, 1 Jul 21 15:26 consoleconsolebrw-r--r-- 1 root root 8, 0 Jul 21 15:27 sdasdabrw-r--r-- 1 root root 8, 1 Jul 21 15:27 sda1sda1
./lib:total 1651-rwxr-xr-x 1 root root 105300 Jul 21 15:25 ld-linux.so.2-rwxr-xr-x 1 root root 1547996 Jul 21 15:25 libc.so.6-rwxr-xr-x 1 root root 14952 Jul 21 15:25 libdl.so.2-rwxr-xr-x 1 root root 11784 Jul 21 15:25 libtermcap.so.2
./lost+found:total 0[root@rh9 mnt]#
Everything nowMake a root filesystem on /dev/sdb1
CIS 191 - Lesson 2
New Commands
and files
CIS 191 - Lesson 2
New commands:dumpe2fs - show overall file system informationfdisk - hard drive partition utilitymknod - creates special device filesldd - show libraries used by a binary programln –s - creates symbolic (soft) linksfdformat - formats a floppy diskmkfs - makes file systemsmount - mounts file systemsstat - shows file informationumount - un-mounts file systemsxxd - displays binary data in hexadecimal format
New Files and Directories:/dev/etc/fstab/etc/mtab
VMware:vmware-config-tools.pl - must be run to finish installing
these tools
CIS 191 – Lesson 2
Next Class
Assignment: Check Calendar Page on web site to see what is due next week.
Quiz questions for next class:
• What device name would you use to specify the fifth partition on the second SCSI drive?
• What command could be used to put a ext3 file system on /dev/sda6?
• What is the maximum number of primary partitions a drive can have?
CIS 191 – Lesson 2
Backup
Some commands
Add ssh server access to Ubuntu:sudo aptitude update sudo aptitude install openssh-server
List of top level directories sorted by size:du –s /* 2> /dev/null | sort -g