Network Administration
SCMP 3852
      Part2:              SYSTEM ADMINISTRATION
Atumbe Jules Baruani, Network Administration@Unam 2010   1
             Administering File Systems
• File systems provide the structures in which files, directories,
  devices, and other elements of the system are accessed from
  Linux.
• Linux supports many different types of file systems (ext3, VFAT,
• ISO9660, NTFS, and so on) as well as many different types of
  media on which file systems can exist (hard disks, CDs, USB
  flash drives, ZIP drives, and so on).
• Creating and managing disk partitions and the file systems on
  those partitions are among the most critical jobs in
  administering a Linux system.
• That’s because if you mess up your file system, you might very
  well lose the critical data stored on your computer’s hard disk
  or removable media.
      Atumbe Jules Baruani, Computer Networks@Unam 2010         2
      File System Types Supported in Linux
• ext3: Most commonly used file system with Linux. Contains
   journaling features for safer data and fast reboots after
   unintended shutdowns.
Journaling can improve data integrity and recovery, especially
after unclean system shutdowns.
Time-consuming file system checks are avoided during the next
reboot after an unclean shutdown, because the changes that
occurred since the most recent write to disk are saved and ready to
be restored.
• ext2: Predecessor of ext3, but doesn’t contain journaling
• Iso9660: Evolved from the High Sierra file system (which was the
   original standard used on CD-ROM). May contain Rock Ridge
   extensions to allow iso9660 file systems to support long file names
   and other information (file permissions, ownership, and links). 3
• Jffs2: Journaling Flash File System version 2 (JFFS2) that is
  designed for efficient operations on USB flash drives. Successor to
  JFFS.
• Jfs: JFS file system that IBM used for OS/2 Warp. Tuned for large
  file systems and high-performance environments.
• msdos: MS-DOS file system. Can be used to mount older MS-DOS
  file systems, such as those on old floppy disks.
• ntfs: Microsoft New Technology File System (NTFS). Useful when
  file systems need to share files with newer Windows systems (as
  with dual booting or removable drives).
• reiserfs: Journaling file system that used to be used by default on
  some SUSE, Slackware, and other Linux systems. Reiserfs is not
  well-supported in Ubuntu.
• squashfs: Compressed, read-only file system used on many Linux
  live CDs.
      Atumbe Jules Baruani, network Administration@Unam 2010      4
• swap: Used on swap partitions to hold data temporarily when
  RAM is not currently available.
• ufs: Popular file system on Solaris and SunOS operating systems
  from Sun Microsystems.
• zfs : zetabyote file system Solaris and SunOS operating systems
  from Sun Microsystems.
• Ext4: or fourth extended file system is a journaling file system for
  Linux, developed as the successor to ext3.
• vfat: Extended FAT (VFAT) file system. Useful when file systems
  need to share files with older Windows systems (as with dual
  booting or removable drives).
• xfs: Journaling file system for high-performance environments.
  Can scale up to systems that include multiple terabytes of data
  that transfer data at multiple gigabytes per second.
       Atumbe Jules Baruani, network Administration@Unam 2010       5
                    Network File systems
• Besides the file system types listed in the table, there are also
   what are referred to as network shared file systems. Locally, a
   network shared file system may be an ext3, ntfs, or other normal
   file system type. However, all or part of those file systems can
   be shared with network protocols such as Samba (smbfs or cifs file
system type), NFS (nfs), and NetWare (ncpfs).
      Atumbe Jules Baruani, network Administration@Unam 2010      6
        Changing Disk Partitions with fdisk
• The fdisk command is a useful Linux tool for listing and changing
   disk partitions.
• Keep in mind that modifying or deleting partitions can cause
   valuable data to be removed, so be sure of your changes before
   writing them to disk.
• To use the fdisk command to list information about the partitions
   on your hard disk, type the following command as root user
$ sudo fdisk -l List disk partitions for every disk
  Disk /dev/sda: 82.3 GB, 82348277760 bytes
  255 heads, 63 sectors/track, 10011 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
      Atumbe Jules Baruani, network Administration@Unam 2010     7
Device    Boot             Start End          Blocks  Id        System
/dev/sda1 *                  1    13          104391 83         Linux
/dev/sda2                   14    9881        79264710 83        Linux
/dev/sda3                  9882 10011         1044225 82        Linux swap
• This example is for an 80GB hard disk that is divided into three
  partitions.
• The first (/dev/sda1) is a small /boot partition that is configured as
  a Linux ext3 file system (Id 83).
• Note the asterisk (*), indicating that the first partition is bootable.
• The next partition is assigned to the root file system and is also
  ext3.
• The final partition is Linux swap.
       Atumbe Jules Baruani, network Administration@Unam 2010            8
• fdisk -l /dev/sdb List disk partitions for a specific disk
• To work with a specific disk with the fdisk command, simply
  indicate the disk you want with no other options
• fdisk /dev/sda Start interactive fdisk session with disk 1
• We can also work with file system using the tool gparted, which is
  a graphical interface tool.
• Parted is a command line version of gparted
      Atumbe Jules Baruani, network Administration@Unam 2010      9
          Working with File System Labels
• The term label, in regards to disk partitions, can refer to two
  different things.
• A disk label can be used as another name for a partition table, as
  seen in parted output.
• A partition label can also be the name of an individual partition. To
  see a partition’s label, use the e2label command:
• To set the label on a partition:
• e2label /dev/sda2 mypartition
• To find a partition when you know only the label, type the
  following: sudo findfs LABEL=mypartition
• The /etc/fstab sometimes uses the partition label to mount the
  partition as in the following example. Changing this label may
  render   the system unbootable.
       Atumbe Jules Baruani, network Administration@Unam 2010      10
                 Formatting a File System
• Commands for formatting and checking file systems are mkfs and
  fsck, respectively.
• The mkfs command serves as the front end for many different
  commands aimed at formatting particular file system types, such
  as mkfs.ext2, mkfs.ext3, mkfs.cramfs,mkfs.msdos, mkfs.ntfs, and
  mkfs.vfat
• Use each command directly (as in mkfs.vfat /dev/sdb1) or via the
  mkfs command (as in mkfs -t vfat /dev/sdb1).
      Atumbe Jules Baruani, network Administration@Unam 2010    11
     Creating a File System on a Hard Disk
                     Partition
  mkfs -t ext3 /dev/sdb1 Create ext3 file system on sba1
 mkfs -t ext3 -v -c /dev/sdb1 More verbose and scan for bad blocks
 mkfs.ext3 -c /dev/sdb1 Same result as previous command
• If you would like to add a partition label to the new partition, use
  the -L option:
• mkfs.ext3 -c -L mypartition /dev/sdb1 Add mypartition label
      Atumbe Jules Baruani, network Administration@Unam 2010      12
Viewing and Changing File System Attributes
• Using the tune2fs or dumpe2fs commands, you can view
   attributes of ext2 and ext3 file systems. The tune2fs command can
   also be used to change file system attributes.
• Use the swapfs command to create a swap partition.
• Here are examples (both commands produce the same output):
• tune2fs -l /dev/sda1 View tunable file system attributes
• dumpe2fs -h /dev/sda1 Same as tune2fs output
dumpe2fs 1.39 (29-May-2006)
Filesystem volume name: /
Last mounted on: <not available>
Filesystem UUID: f5f261d3-3879-41d6-8245-f2153b003204
Filesystem magic number: 0xEF53
(output truncated)
      Atumbe Jules Baruani, network Administration@Unam 2010    13
• To change settings on an existing ext2 or ext3 or ext4 file system,
  you can use the tune2fs command. The following command
  changes the number of mounts before a forced file system check:
• tune2fs -c 31 /dev/sda1 Sets # of mounts before check is forced
tune2fs 1.39 (29-May-2006)
Setting maximal mount count to 31
• If you’d like to switch to forced file system checks based on time
  interval rather than number of mounts, disable mount-count
  checking by setting it to negative 1 (-1):
• sudo tune2fs -c -1 /dev/sda1
tune2fs 1.39 (29-May-2006)
Setting maximal mount count to -1
• Use the -i option to enable time-dependent checking. Here are some examples:
• tune2fs -i 10 /dev/sda1 Check after 10 days
• tune2fs -i 1d /dev/sda1 Check after 1 day
• tune2fs -i 3w /dev/sda1 Check after 3 weeks
• tune2fs -i 6m /dev/sda1 Check after 6 months
• tune2fs -i 0 /dev/sda1 Disable time-dependent checking                         14
• Be sure you always have either mount-count or time-dependent
  checking turned on.
• Use the -j option to turn an ext2 file system into ext3 (by adding a
  journal):
• tune2fs -j /dev/sda1 Add journaling to change ext2 to ext3
       Atumbe Jules Baruani, network Administration@Unam 2010      15
         Creating and Using Swap Partitions
• Swap partitions are needed in Linux systems to hold data that
  overflows from your system’s RAM.
• If you didn’t create a swap partition when you installed Linux, you
  can create it later using the mkswap command.
• You can create your swap partition either on a regular disk
  partition or in a file formatted as a swap partition.
• Here are some examples:
• mkswap /dev/sda1 Format sda1 as a swap partition
Setting up swapspace version 1, size = 205594 kB
To check your swap area for bad blocks, use the -c option to mkswap:
• mkswap -c /dev/sda1
If you don’t have a spare partition, you can create a swap area within
a file:
        Atumbe Jules Baruani, network Administration@Unam 2010    16
• sudo dd if=/dev/zero of=/tmp/swapfile count=65536
65536+0 records in
65536+0 records out
33554432 bytes (34 MB) copied, 1.56578 s, 21.4 MB/s
• chmod 600 /tmp/swapfile
• mkswap /tmp/swapfile
Setting up swapspace version 1, size = 67104 kB
• The dd command above creates a 32MB file named swapfile. The
  chmod command locks down the permissions on the file, to avoid
  getting a warning from the swapon command down the road.
• The mkswap command formats the /tmp/swapfile file to be a
  swap partition.
         Atumbe Jules Baruani, network Administration@Unam 2010   17
• After you have created a swap partition or swap file, you need to
  tell the system to use the swap area you made using the swapon
  command.
• This is similar to what happens at boot time. Here are examples:
• swapon /dev/sda1 Turn swap on for /dev/sda1 partition
• swapon -v /dev/sda1 Increase verbosity as swap is turned on
swapon on /dev/sda1
• swapon -v /tmp/swapfile Turn swap on for the /tmp/swapfile file
swapon on /tmp/swapfile
You can also use the swapon command to see a list of your swaps
files and partitions: swapon –s
• To turn off a swap area, you can use the swapoff command:
• swapoff -v /tmp/swapfile
swapoff on /tmp/swapfile
        Atumbe Jules Baruani, network Administration@Unam 2010    18
• Swap areas are prioritized. The kernel will swap first to areas of
  high priorities, and then go down the list.
• Areas of the same priority get striped between. You can specify
  the priority of your swap area as you enable it using the -p option:
• swapon -v -p 1 /dev/sda1 Assign top swap priority to sda1
      Atumbe Jules Baruani, network Administration@Unam 2010      19
Mounting and Unmounting File Systems
 Atumbe Jules Baruani, network Administration@Unam 2010   20