420-N23 Operating Systems - Topic 12 - Linux Storage
420-N23 Operating Systems - Topic 12 - Linux Storage
CONS
◦ If the whole drive dies for any reason, all partitions are lost.
The Boot Record
Boot Process
As a review from the computer Hardware:
https://www.youtube.com/watch?v=aFvkrhAC
caw
The computer boot process is orchestrated by
the BIOS.
The BIOS finds all partitions using a MASTER
BOOT RECORD, and then runs the code from
that partition.
Usually you can choose which partition to boot
from, in the BIOS yourself.
Bios reads the PARTITION TABLE.
A Master Boot Record
The master boot record is read by your BIOS,
by bootstrapping into it.
It is a sector located at the beginning of the
drive.
This sector contains a boot loader for the
installed operating system and information
about the drive’s logical partitions.
Traditional boot records (MBR) vs. GPT
boot recs.
MBR – MASTER BOOT RECORD GPT – GUID PARTITION TABLE
$ ls /dev/sd* -l
brw-rw---- 1 root disk 8, 0 Mar 20 21:33 /dev/sda
brw-rw---- 1 root disk 8, 1 Mar 20 21:33 /dev/sda1
brw-rw---- 1 root disk 8, 16 Mar 20 21:33 /dev/sdb
Note:
◦ sda = The hard drive #1
◦ sda1 = Partition #1 on hard drive #1.
◦ sdb = Hard drive #2 (with no partitions on it).
List Drives with a Disk Utility
Using "parted" (use SUDO to run)
(parted) print devices
/dev/sda (21.5GB)
/dev/sdb (10.7GB)
Make a partition
◦ Start parted with the "-a optimal" to choose optimal alignment automatically.
◦ $ parted --align optimal /dev/sdb
◦ (parted) mkpart primary 0% 100%
◦ (parted) quit
◦ Information: You may need to update /etc/fstab.
Example 2 – parted mkpart
Create 2 primary ext4 partitions and use MBR, taking exactly half the drive each.
Example:
◦ mkfs.ext4 /dev/sdb1
Example mkfs
Make the file systems on the previous drives you created.
sudo mkfs.ext4 /dev/sdb1
Etc…
Example - mount
Once the drive has been partitioned and formatted, you can "mount" the drive on a mountpoint to
save files to it.
The –o option, means "options" – and here we just accept the default options.
The first mount here means, "Mount sdb1 into the mountpoint called /mnt/data_drive_1".
Note: The mount disappears once you reboot, to make it permanent you need to create an "fstab"
entry for it (See next slides)
mkdir /mnt/data_drive_1
mount -o defaults /dev/sdb1 /mnt/data_drive_1
mkdir /mnt/data_drive_2
mount -o defaults /dev/sdb2 /mnt/data_drive_2
FSTAB
FSTAB Means "File System Table"
This table automatically mounts drives at boot up time.
To ensure that the drives are mounted you must do two things:
1. Create a directory as a mountpoint
2. Put an entry in fstab to map the physical drive to the mountpoint.
/etc/fstab Contents
sudo vi /etc/fstab
/dev/sdb1 /mnt/drive1 ext4 defaults 0 0
/dev/sdb2 /mnt/drive2 ext4 defaults 0 0
blkid
◦ Prints the block device (partitions and storage media) attributes like uuid and file system type. Does not
report the space on the partitions.gdisk
◦ Manage partitions for GPT
hwinfo
◦ The hwinfo is a general purpose hardware information tool and can be used to print out the disk and
partition list.
End
LINUX STORAGE