Weight: 2
Description: Candidates should be able to design a disk partitioning scheme for a Linux system.
Key Knowledge Areas:
- Allocate filesystems and swap space to separate partitions or disks
- Tailor the design to the intended use of the system
- Ensure the /boot partition conforms to the hardware architecture requirements for booting
- Knowledge of basic features of LVM
Terms and Utilities:
/ (root) filesystem /var filesystem /home filesystem /boot filesystem swap space mount points partitions
HD interface
Three different hard disk interfaces are common on modern computers:
Parallel Advanced Technology Attachment (PATA), aka ATA
Serial Advanced Technology Attachment (SATA)
and Small Computer System Interface (SCSI)
PATA
- PATA disks use a parallel interface, meaning that several bits of data are transferred over the cable at once
- connect up to two devices to each PATA connector on a motherboard or plug-in PATA controller, have three connectors—one for the motherboard and two for disks
- configured as masters(end) or as slaves(middle)
- PATA disks have traditionally been identified as /dev/hda, /dev/hdb, /dev/hda being the master drive on the first controller
- Most modern Linux distributions favor newer PATA drivers that treat PATA disks as if they were SCSI disks.
SATA
- host four or more SATA interfaces
- SATA disks connect to their motherboards or controllers on a one-to-one basis
- SATA is a serial bus—only one bit of data can be transferred at a time
- SATA is faster than PATA (1.5–6.0Gbps for SATA vs. 128–1064Mbps for PATA
- Most Linux SATA drivers treat SATA disks as if they were SCSI disks
SCSI
- SCSI is traditionally a parallel bus, like PATA, although the latest variant, Serial Attached SCSI (SAS), is a serial bus like SATA
- SCSI supports up to 8 or 16 devices per bus
- The SCSI bus is logically one-dimensional—that is, every device on the bus falls along a single line. This bus must not fork or branch in any way.
- Each end of the SCSI bus must be terminated.
lshw
lshw lshw -c storage
MBR
master boot record until 2010
- first sector of the disk
- limited to partitions and partition placement of 2 TB
- only four partitions
- 3 types of partitions
■ Primary partitions, which are the same as the original partition types, range of 1–4
■ Extended partitions, which are a special type of primary partition that serves as a placeholder for the next type, numbered 5 and up
■ Logical partitions, which reside within an extended partition - type code
0x0f (a newer type of extended partition)
0x82 (Linux swap)
0x83 (Linux filesystem).
GUID
Partition Table (GPT)
- part of Intel’s EFI specification
- disks bigger than 2TiB
- employs a protective MBR
- define up to 128 partitions by default
- GPT’s main drawback is that support for it is relatively immature
- GPT type codes are 16-byte GUID values
LVM
logical volume management
- assign them MBR partition type codes of 0x8e (or an equivalent on GPT disks)
- utilities, such as pvcreate, vgcreate, lvcreate, and lvscan
- easily resize your logical volumes
- LVM adds complexity
- LVM can complicate disaster recovery, and if your LVM configuration spans
multiple disks, a failure of one disk will put all files in your volume group at risklvm lvm pvscan lvm vgscan lsm lvscan vgcreate demo-vg /dev/sde7 /dev/sde8 lvcreate -l 200G -n demo-lv demo-vg mkfs -t ext4 /dev/demo-vg/demo-lv mkdir /mnt/lvdemo mount /dev/demo-vg/demo-lv /mnt/lvdemo df -h /mnt/lvdemo
partition
fdisk
u default unit is sectors, can toggle between sector and cylinder
parted
parted /dev/sda u s p
parted /dev/sda u cyl p u chs p
gdisk -l /dev/sda
display partition table on /dev/sda
dd if=/dev/sda bs=510 count=1 2> /dev/null |tail -c 64 | hexdump -C
/boot within 1024 cylinders
Older BIOS machines struggle to access data beyond cylinder 1024.
To avoid this problem, create a boot partition, around 16Mb to 32Mb large which is entirely below the 1024 cylinder point.
fs type
Ext2fs The Second Extended File System (ext2fs or ext2) is the traditional Linux-native filesystem, type code is ext2
Ext3fs The Third Extended File System (ext3fs or ext3) is basically ext2fs with a journal added. The result is a filesystem that’s as reliable as ext2fs but that recovers from power outages and system crashes much more quickly. The ext3 filesystem type code is ext3.
Ext4fs The Fourth Extended File System (ext4fs or ext4) is the next-generation version of this filesystem family. It adds the ability to work with very large disks (those over 16TiB, the limit for ext2fs and ext3fs) or very large files (those over 2TiB), as well as extensions intended to improve performance. Its filesystem type code is ext4.
ReiserFS This fi lesystem was designed from scratch as a journaling filesystem for Linux.
It’s particularly good at handling large numbers of small files (say, smaller than about 32KB) because ReiserFS uses various tricks to squeeze the ends of files into each other’s unused spaces. type code reiserfs
JFS IBM developed the Journaled File System (JFS) for its AIX OS and later re-implemented it on OS/2. The OS/2 version was subsequently donated to Linux. type code is jfs.
XFS Silicon Graphics (SGI) created its Extents File System (XFS) for its IRIX OS and,
like IBM, later donated the code to Linux. type code xfs
Btrfs This filesystem (pronounced “butter eff ess” or “bee tree eff ess”) is an advanced
filesystem with features inspired by those of Sun’s Zettabyte File System (ZFS). Like ext4fs,
JFS, and XFS, Btrfs is a fast performer and is able to handle very large disks and files.
FAT The File Allocation Table (FAT) filesystem is old and primitive—but ubiquitous.
It’s the only hard disk filesystem supported by DOS and Windows 9x/Me.
msdos 8.3 filenames
vfat Windows-style long filenames
umsdos Linux-only long filename
HFS and HFS+ Apple has long used the Hierarchical File System (HFS) with its Mac OS,
and Linux provides full read/write HFS support.
ISO-9660 The standard fi lesystem for CD-ROMs has long been ISO-9660
UDF The Universal Disc Format (UDF) is the next-generation filesystem for optical discs.
It’s commonly used on DVD-ROMs and recordable optical discs.
make FS
mkfs -t ext3 /dev/sda6
swap
swapon -s Filename Type Size Used Priority /dev/sda5 partition 1045500 0 -1 /etc/fstab # swap was on /dev/sda5 during installation UUID=dbc82d1f-d7eb-4afc-b1de-22f31f9dfd74 none swap sw 0 0 add new swap filesystem 1GB dd if=/dev/zero of=/swapfile bs=1024 count=1048576 mkswap /swapfile add to /etc/fstab /swapfile none swap sw 0 0 mount -a root@dclab-u1504s:~# swapon -s Filename Type Size Used Priority /dev/sda5 partition 1045500 40 -1 root@dclab-u1504s:~# cat /proc/swaps Filename Type Size Used Priority /dev/sda5 partition 1045500 40 -1 swapon /swapfile root@dclab-u1504s:~# free -mh total used free shared buffers cached Mem: 480M 474M 6.3M 4.8M 3.9M 365M -/+ buffers/cache: 104M 376M Swap: 2.0G 40K 2.0G root@dclab-u1504s:~# swapon -s Filename Type Size Used Priority /dev/sda5 partition 1045500 40 -1 /swapfile file 1048572 0 -2 You need to use the swapoff command: # swapoff /swapfile
Quiz questions
1. Which /dev/ file represents the secondary master IDE disk. 2. Name 2 advantages of using a swap partition over a swap file. 3. When is it necessary to have a separate /boot partition, and how should it be installed?
Answers to quiz questions
1. /dev/hdc 2. It is faster, and it can be used without a filesystem being mounted beforehand. 3. When you have an old or buggy BIOS. It should end before cylinder 1024.