Network Administration SCMP 3852



Atumbe Jules Baruani, Network Administration@Unam 2010


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

May contain Rock Ridge extensions to allow iso9660 file systems to support long file names and other information (file permissions. Journaling can improve data integrity and recovery. ownership. but doesn’t contain journaling • Iso9660: Evolved from the High Sierra file system (which was the original standard used on CD-ROM). Contains journaling features for safer data and fast reboots after unintended shutdowns. because the changes that occurred since the most recent write to disk are saved and ready to be restored. Time-consuming file system checks are avoided during the next reboot after an unclean shutdown. • ext2: Predecessor of ext3.File System Types Supported in Linux • ext3: Most commonly used file system with Linux. especially after unclean system shutdowns. and links). 3 .

read-only file system used on many Linux live CDs. Can be used to mount older MS-DOS file systems. Atumbe Jules Baruani. such as those on old floppy disks. network Administration@Unam 2010 4 . Successor to JFFS.• Jffs2: Journaling Flash File System version 2 (JFFS2) that is designed for efficient operations on USB flash drives. • squashfs: Compressed. • reiserfs: Journaling file system that used to be used by default on some SUSE. Useful when file systems need to share files with newer Windows systems (as with dual booting or removable drives). and other Linux systems. Slackware. Tuned for large file systems and high-performance environments. • msdos: MS-DOS file system. • ntfs: Microsoft New Technology File System (NTFS). Reiserfs is not well-supported in Ubuntu. • Jfs: JFS file system that IBM used for OS/2 Warp.

• swap: Used on swap partitions to hold data temporarily when RAM is not currently available. developed as the successor to ext3. • 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. Atumbe Jules Baruani. • vfat: Extended FAT (VFAT) file system. network Administration@Unam 2010 5 . • 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. Useful when file systems need to share files with older Windows systems (as with dual booting or removable drives).

a network shared file system may be an ext3. all or part of those file systems can be shared with network protocols such as Samba (smbfs or cifs file system type). network Administration@Unam 2010 6 . Locally. or other normal file system type.Network File systems • Besides the file system types listed in the table. However. there are also what are referred to as network shared file systems. Atumbe Jules Baruani. and NetWare (ncpfs). NFS (nfs). ntfs.

10011 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Atumbe Jules Baruani.3 GB. network Administration@Unam 2010 7 . • Keep in mind that modifying or deleting partitions can cause valuable data to be removed. 82348277760 bytes 255 heads. so be sure of your changes before writing them to disk.Changing Disk Partitions with fdisk • The fdisk command is a useful Linux tool for listing and changing disk partitions. • To use the fdisk command to list information about the partitions on your hard disk. 63 sectors/track. type the following command as root user $ sudo fdisk -l List disk partitions for every disk Disk /dev/sda: 82.

Atumbe Jules Baruani. • The next partition is assigned to the root file system and is also ext3. indicating that the first partition is bootable. • Note the asterisk (*).Device Boot /dev/sda1 * /dev/sda2 /dev/sda3 Start End 1 13 14 9881 9882 10011 Blocks Id 104391 83 79264710 83 1044225 82 System Linux Linux Linux swap • This example is for an 80GB hard disk that is divided into three partitions. network Administration@Unam 2010 8 . • The final partition is Linux swap. • The first (/dev/sda1) is a small /boot partition that is configured as a Linux ext3 file system (Id 83).

which is a graphical interface tool.• fdisk -l /dev/sdb List disk partitions for a specific disk • To work with a specific disk with the fdisk command. • Parted is a command line version of gparted Atumbe Jules Baruani. 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. network Administration@Unam 2010 9 .

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. network Administration@Unam 2010 10 . in regards to disk partitions.Working with File System Labels • The term label. • A disk label can be used as another name for a partition table. Atumbe Jules Baruani. 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. • A partition label can also be the name of an individual partition. can refer to two different things. To see a partition’s label. as seen in parted output.

mkfs.cramfs. mkfs. mkfs. Atumbe Jules Baruani.msdos.vfat /dev/sdb1) or via the mkfs command (as in mkfs -t vfat /dev/sdb1).Formatting a File System • Commands for formatting and checking file systems are mkfs and fsck.mkfs. network Administration@Unam 2010 11 . respectively.ntfs.vfat • Use each command directly (as in mkfs. and mkfs. such as mkfs.ext3. • The mkfs command serves as the front end for many different commands aimed at formatting particular file system types.ext2.

network Administration@Unam 2010 12 .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. use the -L option: • mkfs.ext3 -c /dev/sdb1 Same result as previous command If you would like to add a partition label to the new partition.ext3 -c -L mypartition /dev/sdb1 Add mypartition label Atumbe Jules Baruani.

network Administration@Unam 2010 13 .Viewing and Changing File System Attributes • Using the tune2fs or dumpe2fs commands. • 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. 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.

you can use the tune2fs command.39 (29-May-2006) Setting maximal mount count to -1 • Use the -i option to enable time-dependent checking.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. 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. 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 .• To change settings on an existing ext2 or ext3 or ext4 file system.

network Administration@Unam 2010 15 . • 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.• Be sure you always have either mount-count or time-dependent checking turned on.

size = 205594 kB To check your swap area for bad blocks. • You can create your swap partition either on a regular disk partition or in a file formatted as a swap partition.Creating and Using Swap Partitions • Swap partitions are needed in Linux systems to hold data that overflows from your system’s RAM. network Administration@Unam 2010 16 . • If you didn’t create a swap partition when you installed Linux. you can create a swap area within a file: Atumbe Jules Baruani. • Here are some examples: • mkswap /dev/sda1 Format sda1 as a swap partition Setting up swapspace version 1. you can create it later using the mkswap command. use the -c option to mkswap: • mkswap -c /dev/sda1 If you don’t have a spare partition.

to avoid getting a warning from the swapon command down the road. size = 67104 kB • The dd command above creates a 32MB file named swapfile. • The mkswap command formats the /tmp/swapfile file to be a swap partition. The chmod command locks down the permissions on the file. network Administration@Unam 2010 17 . 21.• 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.4 MB/s • chmod 600 /tmp/swapfile • mkswap /tmp/swapfile Setting up swapspace version 1. Atumbe Jules Baruani.

you need to tell the system to use the swap area you made using the swapon command. network Administration@Unam 2010 18 . • 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.• After you have created a swap partition or swap file.

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. The kernel will swap first to areas of high priorities.• Swap areas are prioritized. network Administration@Unam 2010 19 .

Mounting and Unmounting File Systems Atumbe Jules Baruani. network Administration@Unam 2010 20 .

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.