Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
boostr.in questions - Question:hot create linu/unix Create partitions and filesystems?
Our article, "Learn Linux 101: Learn Linux, 101: Hard disk layout," introduced you to hard drive layouts, partitions, and some basic use of the fdisk and gdisk commands to view partition information. You learned about the Master Boot Record (MBR), partition tables, partitions, including primary, extended, and logical partitions. You were also introduced to GUID Partition Tables (GPT), a new format used to address the size limitations inherent in the MBR layout. Finally, you learned that a Linux filesystem contains files that are arranged on a disk or other block storage device in directories. As with many other systems, directories on a Linux system may contain other directories called subdirectories. That article also discussed the considerations that guide you in making choices about partitioning.
Note: This article focuses on the LPI requirements related to the fdisk command and partitioning using MB layouts. It includes some gdisk command information in Creating an ext4 filesystem. Refer to the earlier article and its resources for more information on GPT.
We'll start this article with a review of block devices and partitions, and then show you more about the fdisk command, which is used to create, modify, or delete partitions on block devices. You will also learn about the various forms of the mkfs command (mkfs stands for make filesystem); mkfs commands are used to format partitions as a particular filesystem type.
Note: In addition to the tools and filesystems required for the LPI exams, you may encounter or need other tools and filesystems. Find a brief summary of some other available tools in Other tools and filesystems.
A block device is an abstraction layer for any storage device that can be formatted in fixed-size blocks; individual blocks may be accessed independently of access to other blocks. Such access is often called random access.
The abstraction layer of randomly accessible fixed-size blocks allows programs to use these block devices without worrying about whether the underlying device is a hard drive, floppy, CD, solid-state drive, network drive, or some type of virtual device such as an in-memory file system.
Examples of block devices include the first IDE hard drive on your system (/dev/sda or /dev/hda) or the second SCSI, IDE, or USB drive (/dev/sdb). Use the ls -l command to display /dev entries. The first character on each output line is b for a block device, such as floppy, CD drive, IDE hard drive, or SCSI hard drive; and c for a character device, such as a or terminal (tty) or the null device. See the examples in Listing 1.
Listing 1. Linux block and character devices
[ian@echidna ~]$ ls -l /dev/loop1 /dev/null /dev/sd[ab] /dev/sr0 /dev/tty0
brw-rw----. 1 root disk ¬†¬†7, ¬†1 2010-06-14 07:25 /dev/loop1
crw-rw-rw-. 1 root root ¬†¬†1, ¬†3 2010-06-14 07:25 /dev/null
brw-rw----. 1 root disk ¬†¬†8, ¬†0 2010-06-14 07:25 /dev/sda
brw-rw----. 1 root disk ¬†¬†8, 16 2010-06-14 07:25 /dev/sdb
brw-rw----+ 1 root cdrom 11, ¬†0 2010-06-14 07:25 /dev/sr0
crw--w----. 1 root root ¬†¬†4, ¬†0 2010-06-14 07:25 /dev/tty0
For some block devices, such as floppy disks and CD or DVD discs, it is common to use the whole media as a single filesystem. However, with large hard drives, and even with USB memory keys, it is more common to divide, or partition, the available space into several different partitions.
Partitions can be different sizes, and different partitions may have different filesystems on them, so a single disk can be used for many purposes, including sharing it between multiple operating systems. For example, I use test systems with several different Linux distributions and sometimes a Windows¬ģ system, all sharing one or two hard drives.
You will recall from the article, "Learn Linux 101: Learn Linux, 101: Hard disk layout," that hard drives have a geometry, defined in terms of cylinders, heads, and sectors. Even though modern drives use logical block addressing (LBA), which renders geometry largely irrelevant, the fundamental allocation unit for partitioning purposes is usually still the cylinder.
Sep 13, 2013
Sep 12, 2013
to add a comment.
Related Hot Questions
Government Jobs Opening