Linux - Hard Drives, Partitions and Filesystems Naming Convention

Linux - Hard Drives, Partitions and Filesystems Naming Convention

Linux - Hard Drives, Partitions and Filesystems Naming Convention IDE drives are referred to as hda for the first drive, hdb for the second etc. Serial ATA and SCSI drives are referenced as sda, sdb etc. Hard drive partitions are represented by an additional number. The partitions on each drive are referred numerically. The first partition on the first drive is referred to as hda1, the second as hda2, the third as hda3 etc. Linux IDE naming conventions: Device Description Configuration /dev/(s)hda 1st (Primary) IDE controller Master /dev/(s)hdb 1st (Primary) IDE controller Slave /dev/(s)hdc 2nd (Secondary) IDE controller Master /dev/(s)hdd 2nd (Secondary) IDE controller Slave Linux SATA/SCSI naming conventions: /dev/sda 1st SATA /dev/sdb 2nd SATA Partitioning A computer system may have multiple drives with primary partitions but only one primary partition may be active on one drive only. The active primary partition is used for booting the system and is referenced by the Master Boot Record (MBR). Each hard drive may only have a maximum of four primary partitions. You must an OS from a primary partition. Extended partitions allow one to place up to 24 partitions on a single drive. The first partition on the first drive is referred to as hda1, the second as hda2, the third as hda3 etc. Use the fdisk command under LINUX to partition a hardrive. Implicit in the fdisk command is the mkdev command that creates the device file for the partition. On sime UNIX systems, the mkdev command is explicitly used to create the device file. fdisk /dev/sda Typical fdisk commands used: a toggle a bootable flag d delete a partition l list known partition types m print this menu n add a new partition p print the partition table q quit without saving changes t change a partition's system id w write table to disk and exit Disk partitioning Disk partitioning creates smaller divisions of a hard disk improving computer performance because smaller filesystems are more efficient. Large drive NTFS filesystem have a very large Master File Table (MFT) and it generally takes more time to read this MFT than the smaller MFTs of smaller partitions. A PC hard disk can contain either as many as four primary partitions, or 1-3 primaries and a single extended partition. Each of these partitions are described by a 16-byte entry in the Partition Table which is located in the Master Boot Record. The "type" of a partition is identified by a 1-byte code found in its partition table entry. Some of these codes (such as 0x05 and 0x0F) may be used to indicate the presence of an extended partition, but most are used by operating systems that examine partition tables to decide if a partition contains a file system they can mount/access for reading or writing data. A partition's type codes can be used to hide a partition's contents from various operating systems. However, if an OS or some partitioning tool has been programmed to also examine the boot sectors of any partition, then its file system may no longer remain hidden. (Note: There are no officially assigned partition types; thus, more than one kind of file system may lay claim to the same code value.) Partition types A primary partition contains one file system. MS-DOS and early Windows version require the first partition (C:) to be a "primary partition". Later operating systems do not share this limitation; depend on the PC's BIOS. The "partition type" code for a primary or logical partition can either correspond to a file system contained within (e.g. 0x07 means either an NTFS or an OS/2 HPFS file system, 0x82 usually indicates a Linux swap partition). FAT16 and FAT32 file systems use a differrent number of partition type codes due to the limits of various DOS and Windows OS versions implemented. Though a Linux operating system may recognize a number of different file systems (ext2, ext3, reiserfs, etc.), they have all consistently used the same partition type code: 0x83 (Linux native). An extended partition is secondary to the primary partition(s). A hard disk may contain only one extended partition; which can then be sub-divided into logical drives, each of which is (under DOS and Windows) assigned additional drive letters: C:, D: and E: (in that order). Partition recovery When a partition is deleted, in general, only its partition table entry is removed from a table; and although the data is no longer accessible, it still remains on the disk until being overwritten. Specialized recovery utilitieslocate lost file systems and recreate a partition table which includes entries for these recovered file systems. A partial alternative is to create a copy of the MBR (see MBR and Boot). Some disk utilities may also overwrite a number of beginning sectors of a partition they delete. Windows Disk Management (Windows 2000/XP, etc.) is used to delete a partition, it will overwrite the first sector (relative sector 0) of the partition before removing it. It may be possible to restore a FAT32 or NTFS partition if a backup boot sector is available. Filesystems The mkfs command creates the file system on the allocated partition, the physical organization of the area on disk media – superblock, inode list, root directory (of the file system). For FFS/JFS filesystems (ext3), also different blocksize, fragment size, blockgroups, multiple superblock copies. mkfs -t ext3 /dev/sda3 tune2fs – is used to modify filesystem parameters after the filesystem has been created. There are specific commands to be used for formatting specific areas. /etc/fstab Permanently mounted filesystems are specified in the /etc/fstab file. Contains information about permanently mounted filesystems. (See MAN page on fstab). - First field is the location – disk/partition, label or UUID - Second field is the mountpoint. - Third field is the filesystem type, - Fourth field are the filesystem options. - Fifth field: The digits "1 2" refer to whether the mount point should be backed up when the dump command is used. The "1" states that it should be backed up when the dump command is issued (0=no). - The sixth field indicates when disk integrity checks using fsck. The "2" refers to the order in which "fsck" should check the mount points. The digit "1" identifies the root ("/") of the filesystem. All others should be "2" or 0 (=no check) which is typically used for non-UNIX, non-local file systems. Sample fstab: LABEL=/ / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 none /dev/pts devpts gid=5,mode=620 0 0 none /proc proc defaults 0 0 none /dev/shm tmpfs defaults 0 0 /dev/sda2 swap swap defaults 0 0 /dev/sda1 /opt2 ext3 defaults 1 2 /dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0 /dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0 Note: The first field in /etc/fstab can be a) a disk device name b) a UUID c) a label specified by the “mkfs –L” option or e2label command. a) and c) are usually listed in /dev/disk. Mountpoints Filesystems are mounted on (usually) empty directories - mountpoints. If the directory was not empty, its files are hidden (ignored) until the filesystem is unmounted. A union mount allows these files to show through. Each existing file from the directory only shows if there is no file in the same place on the mounted filesystem. All new files are made on the mounted filesystem. These are commonly used on “LiveCD” operating systems. Some operating systems provide a mount(8) option -o union for this. Disk Images A filesystem can be stored on a file on another filesystem. Such files are called disk images and they have several applications – CDROM images, swap files, If you have no free space for new partitions on your disk, but some partition has free space, then you can create a disk image if you need a new filesystem. Sometimes this helps in the creation of encrypted filesystems. The mount option -o loop can be used to mount disk images instead of devices. Knoppix uses a cloop to fit more programs to the CD. Linux kernels can mount a cloop (compressed loop), which is a compressed disk image. Such an image must be mounted read-only. Creating a new, empty disk image involves two steps before you mount it and start using it: 1. Use dd to make a new file of zeros with the correct size. 2. Format the disk image with partitions and filesystems. Example. We use dd and /dev/zero, to create a 1440 kilobyte disk image (1440 blocks of 1024 bytes). Then we use mkfs.ext3 to create an unpartitioned ext3 filesystem. Note that mkfs.ext3 does no mounting, so it cares not if it formats a device or a disk image. dd bs=1024 count=1440 if=/dev/zero of=example mkfs.ext3 example mount -o loop /disk/example /mnt/diskimg UNION Mounts UnionFS is an extension of VFS that involves merging the contents of two or more directories/filesystems to present a unified view as a single mountpoint. NOT DEVICES!!! A union file system combines one (or more) R/O base directory(s) and a writable overlay as R/W. Initially, the view contains the base filesystem as R/O. The overlay is added second as R/W. Any updates to the mountpoint are written to the overlay directory. When compiled natively into the kernel, unionfs shows up as a filesystem type under mount: mount –t unionfs -o dirs=/dir1=rw:/dir2=ro none /mountpoint •When installed separately in a product (funionfs under LINUX): funionfs none –o dirs=/dir1=rw:/dir2=ro /mountpoint Metadata Other bookkeeping information is typically associated with each file within a file system.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us