– General Linux 1 – Design Hard Disk Layout [2] (Linux Professional Institute Certification) a .˜. /V\ // \\ @._.@ by: geoffrey robertson geoffrey@zip.com.au $Id: gl1.102.1.slides.tex,v 1.2 2003/05/30 05:00:47 waratah Exp $ c 2002 Geoffrey Robertson. Permission is granted to make and distribute verbatim copies or modified versions of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation—either version 2 of the License or (at your option) any later version. a Copyright 1 (2.2) 102 Installation & Package Mgt. [24] 1.102.1 Design hard disk layout [2] 1.102.2 Install a boot manager [3] 1.102.3 Make and install programs from source [5] 1.102.4 Manage shared libraries [3] 1.102.5 Use Debian package management [5] 1.102.6 Use Red Hat Package Manager (RPM) [6] 2 Design hard disk layout [2] Objective Candidates should be able to design a disk partitioning scheme for a Linux system. This objective includes allocating filesystems or swap space to separate partitions or disks, and tailoring the design to the intended use of the system. It also includes placing /boot on a partition that conforms with the BIOS’ requirements for booting. 3 Design hard disk layout [2] Key files, terms, and utilities / (root) filesystem /var filesystem /home filesystem swap space mount points partitions cylinder 1024 Resources of interest Linux Partitioning Mini-FAQ http://pw1.netcom.com/˜kmself/Linux/FAQs/partition.html 4 IA32 Disk Partitions Primary Partitions On i386 systems disks may be sliced up into to 15 partitions. (It may be possible to have 63 or more partitions in IDE disk drives) • The disk must have at least 1 primary partition. /dev/hda1 • There may be up to 4 primary partitions. /dev/hda1 /dev/hda2 /dev/hda3 /dev/hda4 (primary) (primary) (primary) (primary) 5 IA32 Disk Partitions Logical Partitions On i386 systems disks may be sliced up into to 15 partitions. • One of the 4 primary partitions may be made into an extended partition. • The one extended partition must hold between 1 and 12 logical partitions. /dev/hda1 /dev/hda2 /dev/hda5 /dev/hda6 ... /dev/hda16 (primary) (extended) (logical) (logical) (logical) 6 Linux Partitioning mini-FAQ Basic Recommendation / /tmp /var /usr /usr/local /home 50 - 100 MB 50 - 100 MB 200 - 500 MB 1 - 2+ GB 1 - 2+ GB remainder 7 Linux Partitioning mini-FAQ Swap • Linux currently has a maximum of 2GB 8 Linux Partitioning mini-FAQ Swap • Linux currently has a maximum of 2GB • VA Linux configures its servers with 1x physical RAM 8-a Linux Partitioning mini-FAQ Swap • Linux currently has a maximum of 2GB • VA Linux configures its servers with 1x physical RAM • Traditional recommendation is 2x physical RAM 8-b Linux Partitioning mini-FAQ Swap • Linux currently has a maximum of 2GB • VA Linux configures its servers with 1x physical RAM • Traditional recommendation is 2x physical RAM • Karsten M. Self uses 3x physical RAM 8-c Linux Partitioning mini-FAQ Swap • Linux currently has a maximum of 2GB • VA Linux configures its servers with 1x physical RAM • Traditional recommendation is 2x physical RAM • Karsten M. Self uses 3x physical RAM • Large amounts of swap should be divided across several partitions and preferably across several spindles. 8-d Linux Partitioning mini-FAQ Root partition The root partition must have: • /bin • /dev • /etc • /initrd • /lib • /root • /sbin Other directory trees may be distributed on other partitions/spindles. 9 Linux Partitioning mini-FAQ Directories on separate partitions /tmp highly variable. Don’t risk your root partition, isolate this content. Mount noexec and/or nosuid for added protection. 10 Linux Partitioning mini-FAQ Directories on separate partitions /tmp highly variable. Don’t risk your root partition, isolate this content. Mount noexec and/or nosuid for added protection. /var likewise, highly variable. Mount noexec and/or nosuid for added protection. 10-a Linux Partitioning mini-FAQ Directories on separate partitions /tmp highly variable. Don’t risk your root partition, isolate this content. Mount noexec and/or nosuid for added protection. /var likewise, highly variable. Mount noexec and/or nosuid for added protection. /usr Largely stable. Can be mounted read-only except for package upgrades. 10-b Linux Partitioning mini-FAQ Directories on separate partitions /tmp highly variable. Don’t risk your root partition, isolate this content. Mount noexec and/or nosuid for added protection. /var likewise, highly variable. Mount noexec and/or nosuid for added protection. /usr Largely stable. Can be mounted read-only except for package upgrades. /usr/local Largely stable, and not part of the packaging system. Can be mounted read-only, possibly nosuid. 10-c Linux Partitioning mini-FAQ Directories on separate partitions /tmp highly variable. Don’t risk your root partition, isolate this content. Mount noexec and/or nosuid for added protection. /var likewise, highly variable. Mount noexec and/or nosuid for added protection. /usr Largely stable. Can be mounted read-only except for package upgrades. /usr/local Largely stable, and not part of the packaging system. Can be mounted read-only, possibly nosuid. /home Variable content, usually most sensitive data both in terms of security and integrity. Can be mounted nosuid. 10-d Linux Partitioning mini-FAQ Typical Desktop Filesystem 1k-blocks Used Available Use% Mounted on /dev/hda3 152247 33526 110859 24% / /dev/hda6 249871 2004 234967 1% /tmp /dev/sda7 585008 457456 97836 83% /var /dev/hda5 495960 87588 382772 19% /var/spool/news /dev/sdb2 1929100 1518288 312816 83% /usr /dev/sda5 1209572 574152 573976 51% /usr/local /dev/hda7 378711 213496 145662 60% /usr/local/data /dev/hda2 1007992 584132 372656 62% /home /dev/hda1 157044 119252 37792 76% /mnt/dos 11 Linux Partitioning mini-FAQ Typical Desktop fdisk /dev/hda Disk /dev/hda: 128 heads, 63 sectors, 620 cylinders Units = cylinders of 8064 * 512 bytes Device Boot /dev/hda1 /dev/hda2 /dev/hda3 * /dev/hda4 /dev/hda5 /dev/hda6 /dev/hda7 Start 1 40 294 333 333 460 524 End 39 293 332 620 459 523 620 Blocks 157216+ 1024128 157248 1161216 512032+ 258016+ 391072+ Id 6 83 83 5 83 83 83 System FAT16 Linux Linux Extended Linux Linux Linux 12 Linux Partitioning mini-FAQ Typical Desktop fdisk /dev/sda Disk /dev/sda: 255 heads, 63 sectors, 261 cylinders Units = cylinders of 16065 * 512 bytes Device Boot /dev/sda1 /dev/sda2 /dev/sda5 /dev/sda6 /dev/sda7 Start 1 18 18 171 188 End 17 261 170 187 261 Blocks 136521 1959930 1228941 136521 594373+ Id 82 5 83 82 83 System Linux swap Extended Linux Linux swap Linux 13 Linux Partitioning mini-FAQ Typical Desktop fdisk /dev/sdb Disk /dev/sdb: 255 heads, 63 sectors, 261 cylinders Units = cylinders of 16065 * 512 bytes Device Boot /dev/sdb1 /dev/sdb2 Start 1 18 End 17 261 Blocks 136521 1959930 Id 82 83 System Linux swap Linux 14 Linux Partitioning mini-FAQ Typical Desktop /etc/fstab /dev/hda3 proc /dev/hda6 /dev/sda7 /dev/hda5 /dev/sdb2 /dev/sda5 /dev/hda7 /dev/hda2 /dev/hdc /dev/fd0 /dev/hda1 /dev/sda1 /dev/sdb1 /dev/sda6 / /proc /tmp /var /var/spool/news /usr /usr/local /usr/local/data /home ext2 proc ext2 ext2 ext2 ext2 ext2 ext2 ext2 defaults,errors=remount-ro defaults defaults,nosuid,nodev defaults,nosuid,nodev defaults,nosuid,noexec,nodev defaults,rw,nodev defaults,rw,nosuid,nodev defaults,nosuid,nodev defaults,nosuid,nodev 0 0 0 0 0 0 0 2 0 1 0 2 2 2 2 2 2 2 /mnt/cdrom iso9660 noauto,user,ro,nodev,nosuid 22 /mnt/floppy auto noauto,gid=disk,umask=007,rw,user 2 2 /mnt/dos vfat auto,user,nosuid,nodev,gid=6,umask=002 2 2 none none none swap swap swap sw sw sw 0 0 0 0 0 0 15 The End 16