You are on page 1of 14

Knowledge is Power

As a dog returns to its vomit, so a fool


repeats his folly.
(Proverbs 26:11)

Linux Filesystem Management


Jeong Chul
tland12.wordpress.com
www.youtube.com/user/tland12

Computer Science
ITC and RUPP in Cambodia

Linux Filesystem Management


Part 1 Filesystem Management

Chapter 1
Chapter 2
Chapter 3
Chapter 4

Filesystem Management Process


Device Recognition
Disk Partitions
Making Filesystems

Part 2 How to use new filesystem

Chapter 5
Chapter 6
Chapter 7
Chapter 8

Filesystem Labels
Mount points & /etc/fstab
Mount & Umount
Handing Swap files and Partitions

Chapter 1 Filesystem Management Process


1.Objectives
Upon completion of this unit, you should be able to:
Manage virtual memory
Add new drives and partitions
Mount filesystems
How to use new filesystem

2. Overview: Adding new Filesystems to the Filesystem tree


1)
2)
3)
4)
5)
6)

Identify Device : /dev/hda or /dev/sda


Partition Device : fdisk, sfdisk, GNU parted, partprobe
Make filesystem : mkfs, mkfs.ext3, mkfs.ext4, mkfs.vfat
Label filesystem : e2label, tune2fs
Create entry in /etc/fstab : mount points, mount, fsck
Mount new filesystem : mount, umount

Chapter 2 Device Recognition


1. BIOS a list of device to start Operating System (CD, hard disk)
2. First sector of the first cylinder at hard disk Master Boot
Record
3.Master Boot Record (MBR) contains:
a. Executable code to load operating system Boot Loader
b. GRUB Grand Unified Boot Loader in Linux systems
c. Space for partition table information, including:

Hard Disk type IDE (hda, hdb), SCSI or Sata (sda, sdb)
Partition id Linux swap, Linux, Linux LVM, RAID, DOS
Partition type Primary, Extended and Logical
Partition has each size sectors, blocks or cylinders
Starting cylinder for partition - 1 cylinder is about 8 MB
Number of cylinders for partition

Chapter 3 Disk Partitions


1.Types of partitions
a. Primary partitions : support only 4 partitions per drive
b. Extended Partitions : one of Primary, includes all Logical partitions
c. Logical partitions : permits the definition of more than four partitions

2.Total maximum number of partitions supported by the kernel:


a. 63 for IDE drives
b.15 for SCSI or SATA drives

3.Why partition drives?


a. containment: security breach, user demand
b. performance: keeping data together which reduce disk head seek
c. quotas: using specific file partition
d. recovery: ease backup and recovery

Chapter 3 Disk Partitions


4. Managing Partitions
1) Create partitions using:
a. fdisk most commonly used partitioning program
# fdisk /dev/sda
b. Sfdisk more accurate and flexible than fdisk
# sfdisk l /dev/sda
c.GNU parted - advanced partition manipulation (create, copy, resize, etc.)
# parted l /dev/sda
# yum install gparted y ; gparted &
2) Partprobe - /proc/partitions
Need to reboot after creating new partition so that kernel reads
new partition table
Reinitializes the kernel's in-memory version of the partition table
without rebooting again

# partprobe
# kpartx a /dev/sda ; kpartx l /dev/sda

Chapter 4 Making Filesystems


1. mkfs Creating file system
mkfs.ext2, mkfs.ext3, mkfs.ext4, mkfs.msdos
Specific filesystem utilities can be called directly
# mkfs t ext4 /dev/sda8
# msfs.ext4 /dev/sda8

2. mke2fs [options] device


# mke2fs -j -L data -b 2048 -i 4096 /dev/sda8
-L: filesystem label
-j: journaling
-b: block size
-i: inode per every 4 kb of disk space

Chapter 5 Filesystem Labels


1. e2label filesystem label
a. E2label special_dev_file
# e2label /dev/sda8 data ; e2label /dev/sda8
b. Mount label=fslabel mount_point
# mount LABEL=data /data
c. see lables and filesystem type of all devices
# blkid
2. Tune2fs - Adjust filesystem parameters
reserved blocks, default mount options, fsck frequency
a. View current settings
# dumpe2fs /dev/sda8
b. Modify the percentage of reserved blocks
# tune2fs m 10 /dev/sda8
c. Set the default mount options
# tune2fs o acl,user_xattr /dev/sda1
d. Disable mandatory filesystem checks
# tune2fs i0 c0 /dev/sda8

Chapter 6 Mount points & /etc/fstab


1.Configuration of the filesystem - /etc/fstab
# device
mount_point
FS_TYPE options dump_freq fsck_order
LABEL=/data /data
ext3
defaults
0
0

device: special device file name or filesystem label

mount_point: the path used to access the filesystem

FS_type: filesystem type

options: a comma-separated list of options

dump_freq: dump frequence: 1=daily, 2=every other day, 0=never dump

fsck_order: 0=ignore ,1=first, 2-9: second third

2. Used by mount, fsck and other programs


3. May use filesystem volume labels in the device field
4. # mount a can be used to mount all filesystems listed in the
/etc/fstab
5. # mount /dev/hda5
# mount L /data
# mount LABEL=/data

Chapter 7 Mount & Umount


1.Mount options device mount_point
mount [-o options] [-t fs_type] device mount_point
a. Denying permission to execute files
# mount t ext3 o noexec /dev/hda7 /home
b. Mount CD-Rom image file
# mount t iso9660 o loop /iso/documents.iso /mnt/cdimage
c. Each file is owned by a specific UID and GID
# mount t vfat o uid=500,gid=510 /dev/hdc /mnt/windows
d. Mount filesystem to increase I/O performance by reducing disk access
# mount t ext3 o noatime /dev/hd7 /data

2. Unmounting filesystems
umount [options] device | mount_point
# umount /data
a. cannot unmount a filesystem that is in use
b. Use the remount option to change a mounted filesystem's options
atomically
# mount -o remount,ro /data

Chapter 8 Handing Swap files & Partitions


1. Swap space is a supplement to system RAM
2. Process to create swap file and partitions
a. create swap partition using fdisk
# fdisk /dev/sda
# mkswap /dev/sda9
# vi /etc/fstab
/dev/sda9
swap swap defaults
0 0
# swapon a; swapon s ; free
b. create swap file
# dd if=/dev/zero of=/swapfile bs=1024 count=100000 (100Mb)
# mkswap /swapfile
# vi /etc/fstab
/swapfile
swap swap defaults 0 0
# swapon a
# swapon s ; free

Summary
Five steps to control linux filesystems
1. Bios recognition
2. Creating partitions fdisk, gparted, sfdisk
3. Making filesystem for new partition - mkfs
4. Labeling new partitions e2label
5. Mounting and using new filesystem mount,
/etc/fstab

Linux Filesystem Management

Thank you & God bless you


tland12.wordpress.com
www.youtube.com/user/tland12

You might also like