1 / 58

Lecture 3: Unix installation&testing

Lecture 3: Unix installation&testing. Guntis Barzdins Girts Folkmanis Juris Krumins. Mājas darbs #1:. Katram instalēt atšķirīgu* Unix paveidu Pētījumā (aptuveni 5-10 lpp) aprakstīt gūto pieredzi: Ar ko šī Unix versija atšķiras no citām, kāpēc to izvēlējāties Unix instalācijas process

lisle
Download Presentation

Lecture 3: Unix installation&testing

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. Lecture 3: Unix installation&testing Guntis Barzdins Girts Folkmanis Juris Krumins

  2. Mājas darbs #1: • Katram instalēt atšķirīgu* Unix paveidu • Pētījumā (aptuveni 5-10 lpp) aprakstīt gūto pieredzi: • Ar ko šī Unix versija atšķiras no citām, kāpēc to izvēlējāties • Unix instalācijas process • Galveno soļu screenshoti • Svarīgākās konfigurācijas opcijas, jūsu izvēle • Izveidot lietotāju “lapsa”, pārbaudīt ka var pieslēgties • Aplikācijas “toyshell” kompilācija, uzlabošana • Nokompilēt un pārbaudīt “toyshell” darbību • Papildināt “toyshell” funkcionalitāti (help, cd, ctrl/D, setenv,...)** • Panākt lai lietotājs “lapsa” pieslēdzoties nonāk jūsu “toyshell” un var tajā veikt sakarīgas darbības * - vairāku vienādu Unix paveidu gadījumā, vērtējums būs stingrāks ** - vairāk signāli, systemcall vērtējumu uzlabos

  3. toyshell.c int main (void){ char cmd[MAXLINE]; char *cmdp; char *av[MAXARG]; int i; while(1){ printf("$toyshell$> "); fgets(cmd,sizeof(cmd),stdin); if(strcmp(cmd,"env\n")==0){ env(); } else if(strcmp(cmd,"exit\n")==0){ exitsh(0); } else { cmdp=cmd; for(i=0;i<MAXARG;i++){ av[i]=strtok(cmdp," \t\n"); cmdp=NULL; } execute(av); } } return(0); } #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <signal.h> #define MAXLINE 200 #define MAXARG 20 extern char **environ; void env(void){ int i; for(i=0;environ[i]!=NULL;i++){ printf("%s\n",environ[i]); } } void exitsh(int status){ _exit(status); } void execute(char *arg[]){ pid_t pid; int status; pid=fork(); if(pid>0){ wait(&status); } else if (pid==0) { execvp(arg[0],arg); printf("Komanda nav atrasta\n"); exitsh(0); } else { printf("Kluda fork() sistemas izsaukuma\n"); } }

  4. “toyshell” palaišana # /usr/bin/gcc toyshell.c # cc toyshell.c # ./a.out $toyshell$> env USER=root HOME=/root TERM=vt100 PATH=/root/bin:/usr/local/bin:/bin:/usr/bin SHELL=/bin/sh $toyshell$> ps PID TTY TIME CMD 126 co 0:00 -sh 95 c1 0:00 getty 435 p1 0:00 ./a.out 436 p1 0:00 ps $toyshell$> exit #

  5. passwd, shadow, group files unix etc # ls -l passwd shadow group -rw-r--r-- 1 root root 705 Sep 23 15:36 group -rw-r--r-- 1 root root 1895 Sep 24 18:20 passwd -rw------- 1 root root 634 Sep 24 18:22 shadow unix etc # unix root # more /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/bin/false daemon:x:2:2:daemon:/sbin:/bin/false adm:x:3:4:adm:/var/adm:/bin/false lp:x:4:7:lp:/var/spool/lpd:/bin/false sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt ... guest:x:405:100:guest:/dev/null:/dev/null nobody:x:65534:65534:nobody:/:/bin/false girtsf:x:1000:100::/home/girtsf:/bin/bash dima:x:1001:100::/home/dima:/bin/bash guntis:x:1002:100::/home/guntis:/bin/bash students:x:1003:100::/home/students:/bin/bash unix root # unix root # more /etc/group root::0:root bin::1:root,bin,daemon daemon::2:root,bin,daemon sys::3:root,bin,adm adm::4:root,adm,daemon tty::5:girtsf disk::6:root,adm lp::7:lp mem::8: kmem::9: wheel::10:root,girtsf floppy::11:root mail::12:mail ... users::100:games,girtsf nofiles:x:200: qmail:x:201: postfix:x:207: postdrop:x:208: smmsp:x:209:smmsp slocate::245: portage::250:portage utmp:x:406: nogroup::65533: nobody::65534: unix root # unix root # more /etc/shadow root:$1$VlYbWsrd$GUs2cptio.rKlGHgAMBzr.:12684:0::::: halt:*:9797:0::::: ... guest:*:9797:0::::: nobody:*:9797:0::::: girtsf:$1$u6UEWKT2$w5K28n2iAB2wNWtyPLycP1:12684:0:99999:7::: dima:$1$BQCdIBdV$xzzlj4s8XT6L9cLAmcoV50:12684:0:99999:7::: guntis:$1$fiJF/0BT$Py9JiQQL6icajjQVyMZ7//:12684:0:99999:7::: students:$1$wueon8yh$nLpUpNOKr8yTYaEnEK6OJ1:12685:0:99999:7::: unix root #

  6. Security in UNIX cp a.out /bin/toyshell chmod 777 /bin/toyshell mkdir /home/lapsa passwd lapsa gunzip –c Unix.tar.gz | tar –xvf -

  7. Hard Drive Construction • Master Boot Record (MBR): Track 0, Sector 1 • Number of partitions and their location (max 4 primary partitions or 3 primary + 1 Extended + 12 Logical) • Pointer to partition with bootloader

  8. HD identification Partition identification: • IDE drives • dev/hda • dev/hdb • ... • SCSI • dev/sda • dev/sdb • ... Note that /dev is not a real directory for accessing the contents of disks – it is rather a naming space for all hardware devices (and their drivers) present in the system, including keyboard, screen etc. The contents of disks is made available in other part of root / hierarchy.

  9. File System Layout Bootloader can be installed in different locations (if bootloader not in MBR, the BIOS interprets MBR to find boot partition)

  10. Boot Block The system’s primary disk unit contains a boot block that contains the bootstrapping program that loads the OS to memory. This program is invoked by the computer’s minimal bootstrap program in ROM. This boot block is often called the Master Boot Record (MBR). Different operating systems treat the MBR in very different ways. Some are flexible enough to install a boot loader in the MBR, so that the disk can contain different OS in different disk partitions. The loader for each OS is then stored at the beginning of its own partition. Examples: Windows NT/2000/xp boot loader, Linux lilo and grub. A “bootable” disk is one on which a boot block has been installed.

  11. Mandatory partitions • root • /dev/hda1 (recommended) • This is partition for the actual root / of the UNIX filesystem • swap • /dev/hda2 (recommended) • 4GB (max with 32bit x86 CPU) • RAM SIZE * 2 (recommended) • This partition is not visible in root / and is used only by kernel for virtual memory page swapping (“raw” sectors, no structure) • Theoretically swap partition is optional, if enough RAM

  12. Optional partitions or separate HD • Typically on separate partitions • /home, /boot, /tmp, /var, /usr • Reasons for separate partitions • logical or physical damage • reinstallation (affects only some partitions) • limit overflow effects • better performance • shared via network

  13. File System Types • VFS Virtual File System • UFS / FFSUNIX File System – used interchangeably with FFS (Fast File System) • NFS Network File System – developed by Sun • RFS Remote File System – developed by AT&T • S5FS Original System V file system • VxFS Veritas Journaling File System • JFS Journaled File System – AIX • CFS Cluster file system – Tru64 • EXT2/EXT3 2nd/3rd Extended File System – Linux systems • GFS Global File System – Linux • ReiserFS Journaling file system – Linux • XFS Extended File System – SGI and others • CXFS Clustered Extended File System – SGI • QFS 64-bit very large file system – Sun Solaris • HFS Hierarchical File System – S/390 UNIX, OS/2, MacOS X • NTFS Windows NT/2000/2003 • FAT16/ FAT32 Windows – several versions

  14. Linux can interpret many file system types, including; EXT2, EXT3, UFS/FFS, FAT16, FAT32 NTFS (read-only), HPFS ISO9660, UDF, UFS, etc. Win32 can interpret a few file system types,including; FAT16, FAT32 NTFS File System Support

  15. Creating Partitions: GNU Parted Notes: • For ext2, ext3 and reiserfs: the start of the partition must stay fixed. • For ext2, ext3: the partition you copy to must be bigger or exactly the same size as the partition you copy from. • For ext2 and ext3: the checking is limited to ensuring the resize and copy commands will be ok. • For fat: the size of the new partition after resizing or copying is restricted by the cluster size. Parted can shrink the cluster size, so you can always shrink your partition. However, if you can't use FAT32 for some reason, you may not be able to grow your partition. • Parted supports both FAT16 and FAT32. Parted can convert file systems between FAT16 and FAT32, if necessary. • Reiserfs support is enabled if you install libreiserfs, available at http://reiserfs.osdn.org.ua. (It is likely to be available soon from http://www.namesys.com)

  16. BSD Versions • FreeBSD - Focusing on features and ease of use • Darwin (OS X) - Focusing on the desktop and multimedia with use of the Apple's Aqua Interface • NetBSD - Focusing on portability • OpenBSD - Focusing on security • PicoBSD - Focusing on size (extremely small) • DragonflyBSD - Focusing on new computing paradigms

  17. Linux Distributions • Debian GNU/Linux (Xandros, Knopix,...) • a free operating system that provides almost 4000 software packages for six architectures (Intel, Motorola, Alpha, SPARC, PowerPC, ARM) and is developed entirely by volunteers over the Internet • Fedora/RedHat • a Red-Hat-sponsored and community-supported open source project. The goal of The Fedora Project is to work with the Linux community to build a complete, general purpose operating system exclusively from free software. Development will be done in a public forum • Mandrake Linux • a friendly Linux Operating System which specializes in ease-of-use for both servers and the home/office. It is freely available in many languages throughout the world • Slackware • a long running Linux distribution that descends from the SLS Distribution • SuSE Linux • an extremely popular distro that features excellent documentation, thousands of applications on a DVD/CD-ROM set • Gentoo Linux • an optimized GNU/Linux distribution featuring 5 different pgcc-optimized builds, including Intel Pentium, Pentium Pro/II/III and AMD K6 optimized

  18. Citi brīvi pieejami Unix • Solaris 10 • x64/x86 • % isainfo -v • 64-bit amd64 applications • 32-bit i386 applications • SPARC • Darwin • Minix

  19. Unix Instalacijano CD/DVD

  20. Installing NetBSD Installation you should decide the installation media thatyou will use; you can choose between: • FTP • NFS • CD-ROM/DVD • floppy disc • unmounted filesystem • local directory

  21. Installing NetBSD • Geometries The installation program mentions two types of hard disk geometries; you should understand what they mean: • real geometry • BIOS geometry • real geometry is the real geometry of the hard disk, detected by the system. • BIOS geometry is the geometry used by the BIOS and it could be different from the real one (for example, BIOS could remap the disk using LBA). • Example real: 6232 cyl, 16 heads, 63 sec • Example BIOS: 779 cyl, 128 heads, 63 sec (LBA) • As you can see the BIOS remaps the disk using LBA, effectively reducing the number of cylinders and increasing the number of tracks (but the result is the same: 6232 * 16 = 779 * 128 = 99712). A sector contains 512 bytes, which means that the disk size is 6232 * 16 * 63 * 512 = 3 GB. NetBSD does not need to remap the disk geometry (and in fact won't do it). During the installation it is possible to change manually the geometry if sysinst got it wrong.

  22. Installing NetBSD Partitions

  23. Installing NetBSD Hard disk space requirements • The space required by a NetBSD installation depends on the planned use (e.g. server or workstation). For example, consider a home desktop system with a 420 MB hard disk (rather small by today's standards) with X, the kernel sources and some applications (Netscape, ...). The swap partition is 32 MB.

  24. Installing NetBSD  Creating the installation floppy • If you create the boot floppy in a Unix environment, you can use the dd command. For example: # cd i386/installation/floppy # dd if=boot.fs of=/dev/fd0a bs=36b

  25. Installing NetBSD Beginning the installation

  26. Installing NetBSD The main menu of the installation program

  27. Installing NetBSD Confirming you want to install NetBSD

  28. Installing NetBSD Choosing a hard disk

  29. Installing NetBSD Full or custom installation

  30. Installing NetBSD Selecting distribution sets

  31. Installing NetBSD Choosing the partitioning scheme

  32. Installing NetBSD fdisk

  33. Installing NetBSD Installing the boot selector

  34. Installing NetBSD The disklabel editor

  35. Installing NetBSD Installation media

  36. Installing NetBSD System configuration

  37. Installing NetBSD Reboot the system to finish installation

  38. Linux Devices In Linux, partitions are represented by device files. These are phoney files located in /dev. Here are a few entries: brw-rw---- 1 root disk 3, 0 May 5 1998 hda brw-rw---- 1 root disk 8, 0 May 5 1998 sda crw------- 1 root tty 4, 64 May 5 1998 ttyS0

  39. Linux Device names • IDE controller naming convention

  40. Linux partition names

  41. Linux Logical Partitions

  42. Linux Partition Types • Foreign Partition Types • Primary Partitions • Logical Partitions • Swap Partitions

  43. Linux Partitioning requirements For the Boot Drive: If you want to boot your operating system from the drive you are about to partition, you will need: • A primary partition • One or more swap partitions • Zero or more primary/logical partitions For any other drive: • One or more primary/logical partitions • Zero or more swap partitions

  44. Linux File Systems Everything in your linux file system can go in the same (single) partition. However, there are circumstances when you may want to restrict the growth of certain file systems. For example, if your mail spool was in the same partition as your root fs and it filled the remaining space in the partition, your computer would basically hang. • /var- This fs contains spool directories such as those for mail and printing. In addition, it contains the error log directory. If your machine is a server and develops a chronic error, those msgs can fill the partition. Server computers ought to have /var in a different partition than /. • /usr - This is where most executable binaries go. In addition, the kernel source tree goes here, and much documentation. • /tmp - Some programs write temporary data files here. Usually, they are quite small. However, if you run computationally intensive jobs, like science or engineering applications, hundreds of megabytes could be required for brief periods of time. In this case, keep /tmp in a different partition than /. • /home- This is where users home directories go. If you do not impose quotas on your users, this ought to be in its own partition. • /boot - This is where your kernel images go. See discussion above for placement on old systems.

  45. Linux Swap Partitions • Split the swap space across multiple drives, or at least on the drive you write to least. • Put each swap partition on the outer tracks.

  46. Resources 1. http://www.netbsd.org/guide/en/ 2. http://www.tldp.org/HOWTO/Partition/ 3.ftp://ftp.slackbook.org/pub/slackbook/ slackbook-2.0.pdf

  47. Environment variables #include <stdlib.h> extern char **environ; int main(int argc,char *argv[]) { int i; for (i=0;environ[i]!=NULL;i++){ printf("%s\n",environ[i]); } return(0); }

  48. Environment variables #include <stdlib.h> int main(int argc,char *argv[]){ if (argc==1){ printf("Nav neviena argumenta\n"); return(1); } else if (argc>2) { printf("argc > 2\n"); return(1); } else { printf("%s=%s",argv[1],getenv(argv[1])); } return(0); }

  49. Environment variables #include <stdlib.h> extern char **environ; int main(int argc,char *argv[]){ int i; if (argc==1){ printf("Nav neviena argumenta\n"); return(1); } else if (argc>2) { printf("argc > 2\n"); return(1); } else { putenv(argv[1]); } for (i=0;environ[i]!=NULL;i++){ printf("%s\n",environ[i]); } return(0); }

  50. Environment variables #include <stdlib.h> extern char **environ; int main(int argc,char *argv[]){ int i; if (argc==1){ printf("Nav neviena argumenta\n"); return(1); } else if (argc>2) { printf("argc > 2\n"); return(1); } else { unsetenv(argv[1]); } for (i=0;environ[i]!=NULL;i++){ printf("%s\n",environ[i]); } return(0); }

More Related