Partitions of storage devices in the Linux File System

Source: Internet
Author: User

Do you want to know the truth about the Linux File System? Do you want to know what is inherent in the Linux File System, if you want to load a partitioned Linux File System, you must first confirm the type of the Linux File System before mounting and using it.

For example, mount the disk or modify/etc/fstab to automatically load the disk. If you want to add a new partition or add a new hard disk, you need to use the partition tool to add a partition, and then create a Linux File System for the partition, And then mount the Linux file system. For example, by mount, you can also modify/etc/fstab to automatically load the file at startup;

This document describes what you want. For example, how to create a Linux File System on a new partition, how to mount it, and how to detach a Linux file system or a device such as cdrom; I suggest you read this article and perform selective practices based on your own needs;

A small Linux file system involves many aspects of knowledge, and sometimes it is difficult to clarify a document; I want to explain every process as much as possible, therefore, separating partitioning tools, creating Linux File System Tools, and viewing Linux file systems mainly makes it easier for beginners to understand. I hope you can understand my heart. It is said that the length of North and South is ugly, but the heart is still kind ...... I will not use some junk documents to harm you ...... haha ...... let's get down to the truth and start the article ~~~~

1. Partitioning of storage devices;

The storage devices we refer to here are mainly local hard disks, mobile hard disks such as USB and 1394 Interface hard disks). Because the disks are large and in order to meet our various needs, therefore, the hard disk is divided into several partitions. For example, we can use this partition to install the Linux file system, which is used to install the Windows system ......; everyone understands this little thing;

As for how to perform hard disk Partitioning in the Linux File System, we recommend that you use fdisk, which seems to be the best partitioning tool. Other tools such as parted and cfdisk have some advantages in one aspect, however, these advantages may bring you some convenience, such as the data backup feature in parted. This feature may be an advantage for veterans, but it is indeed risky for new users; therefore, we recommend that you use the fdisk partitioning tool;

Fdisk usage instructions: refer to: fdisk usage instructions for instances

2. storage devices are formatted to create a Linux File System;

1. Introduction to the Linux File System

Partitions on storage devices are far from enough. We need to format these new partitions. A partition can only be used after a Linux file system is created; the process of setting up a Linux File System is to format the partition with a corresponding formatting tool. This process is similar to formatting a partition in Windows as an NTFS partition. There is nothing advanced about it, only the tools used are different;

In the Linux File System Operating System, it currently supports almost mainstream Linux file systems, such as NTFS read-only), FAT readable and writable), ext2, ext3, reiserfs, hfs (Linux File System of MAC operating system), swap partition ...... there are also some Linux file systems that we are not familiar;

In a Linux File System, the common Linux File System is nothing more than the above example. If you add a hard disk, you may want to format it into a Linux File System, the best choice is reiserfs or ext3. ext2 has been replaced by ext3. We do not recommend ext2Linux file system. ext2 is highly risky;

The fastest Linux File System, which belongs to reiserfs; reiserfs, has many advantages, such as higher security; ext3 is the best Linux File System that Redhat considers, so during the installation of Fedora 4.0, this is especially difficult for reiserfs selection; reiserfs is relatively better than ext3; if you want to learn more about the Linux file system, you can go to the official forum to find relevant information, best practices;

2. introduction and use of the formatting tool;

Taking fedora 4.0 as an example, our commonly used tool mkfs. ext3 mkfs. reiserfs mkfs. ext2 mkfs. msdos mkfs. vfat mkswap prompt: if you cannot create a reiserfs Linux file system, that is, there is no mkfs. the reiserfs or mkreiserfs command is because you have not installed the reiserfs-utils toolkit. For details, see instructions on enabling Fedora to support the creation of reiserfs Linux file systems and reiserfsLinux file systems.

1) Use of mkfs;


Usage: [root @ localhost beinan] # mkfs-t Linux File System storage device note: the Linux File System must be specified here, such as ext3; reiserfs; ext2; fat32; msdos ...... the device, for example, is a hard disk partition, floppy disk, or optical drive .. before formatting a partition, you must know how to view the partition information of a hard disk and format it accordingly. For example, you can use fdisk-l to view the partition information;

For details, refer to: Introduction to Linux File System disk partition, Linux File System, usage commands, and related tools. For example, if I want to format a partition in a mobile USB flash drive, the panorama should be:

 
 
  1. [Root @ localhost beinan] # fdisk-l
  2.  
  3. Disk/dev/hda: 80.0 GB, 80026361856 bytes
  4. 255 heads, 63 sectors/track, 9729 cylinders
  5. Units=CylindersOf 16065 *512=8225280Bytes
  6. Device Boot Start End Blocks Id System
  7. /Dev/hda1*1 765 6144831 7 HPFS/NTFS
  8. /Dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
  9. /Dev/hda3 2806 9729 55617030 5 Extended
  10. /Dev/hda5 2806 3825 8193118 + 83 Linux File System
  11. /Dev/hda6 3826 5100 10241406 83 Linux File System
  12. /Dev/hda7 5101 5198 787153 + 82 Linux File System swap/Solaris
  13. /Dev/hda8 5199 6657 11719386 83 Linux File System
  14. /Dev/hda9 6658 7751 8787523 + 83 Linux File System
  15. /Dev/hda10 7752 9729 15888253 + 83 Linux File System
 
 
  1. Disk/dev/sda: 1035 MB, 1035730944 bytes
  2. 256 heads, 63 sectors/track, 125 cylinders
  3. Units=CylindersOf 16128 *512=8257536Bytes
  4. Device Boot Start End Blocks Id System
  5. /Dev/sda1 1 25 201568 + 83 Linux File System
  6. /Dev/sda2 26 125 806400 5 Extended
  7. /Dev/sda5 26 50 201568 + 83 Linux File System
  8. /Dev/sda6 51 76 200781 83 Linux File System

We can see the sda device, so we can use fdisk-l/dev/sda to display its partition information. For example, I want to format/dev/sda6 to ext3Linux file system, then:

 
 
  1. [Root @ localhost beinan] # mkfs-t ext3/dev/sda6
  2. Mke2fs 1.37 (21-mar-2005)
  3. FilesystemLabel=
  4. OSType: Linux File System
  5. BlockSize=1024(Log=0)
  6. FragmentSize=1024(Log=0)
  7. 50200 inodes, 200780 blocks
  8. 10039 blocks (5.00%) reserved for the super user
  9. First dataBlock=1 
  10. Maximum filesystemBlocks=67371008 
  11. 25 block groups
  12. 8192 blocks per group, 8192 fragments per group
  13. 2008 inodes per group
  14. Superblock backups stored on blocks:
  15. 8193,245 77, 40961,573 45, 73729
  16.  
 
 
  1. Writing inode tables: done
  2. Creating journal (4096 blocks): done
  3. Writing superblocks and filesystem accounting information: Note: Press enter here;
  4. Done
  5.  
  6. This filesystem will be automatically checked every 26 mounts or
  7. 180 days, whichever comes first. Use tune2fs-c or-I to override.

In this way, the format is ready. sda6 is now the ext3Linux file system. We can use mount to load the partition and then use the Linux File System;

 
 
  1. [root@localhost beinan]# mkdir /mnt/sda6   
  2. [root@localhost beinan]# chmod 777 /mnt/sda6   
  3. [root@localhost beinan]# mount /dev/sda6   /mnt/sda6  

Of course, you can also format partitions into other Linux file systems. For example, you can format/dev/sda6 as an ext3, ext2, reiserfs, fat32, or msdos Linux File System. The command format is as follows;

 
 
  1. [root@localhost beinan]# mkfs -t ext3  /dev/sda6   
  2. [root@localhost beinan]# mkfs -t ext2  /dev/sda6  
  3. [root@localhost beinan]# mkfs -t reiserfs  /dev/sda6  
  4. [root@localhost beinan]# mkfs -t fat32   /dev/sda6  
  5. [root@localhost beinan]# mkfs -t msdos   /dev/sda6  
  6. ... ...  

2) Introduction to mkfs. ext3 mkfs. reiserfs mkfs. ext2 mkfs. msdos mkfs. vfat mke2fs;


After talking about a mkfs tool, let's introduce mkfs. ext3 mkfs. reiserfs mkfs. ext2 mkdosfs mkfs. msdos mkfs. vfat is actually the tool called when mkfs executes the command. This is also the main reason why I first introduced mkfs; by file name, we know what Linux file systems these tools support. These commands provide us with more convenience;

 
 
  1. [Root @ localhost beinan] # mkfs. ext3/dev/sda6 Note: format the device into an ext3Linux file system.
  2. [Root @ localhost beinan] # mke2fs-j/dev/sda6 Note: format the device into an ext3Linux File System
  3. [Root @ localhost beinan] # mkfs. ext2/dev/sda6 Note: format the device into an ext2Linux File System
  4. Root @ localhost beinan] # mke2fs/dev/sda6 Note: format the device into an ext2Linux file system.
  5. [Root @ localhost beinan] # mkfs. reiserfs/dev/sda6 Note: format the device as a reiserfsLinux File System
  6. [Root @ localhost beinan] # mkfs. vfat/dev/sda6 Note: format the device as a fat32Linux File System
  7. [Root @ localhost beinan] # mkfs. msdos/dev/sda6 Note: format the device into a fat16Linux file system. The msdosLinux file system is fat16;
  8. [Root @ localhost beinan] # mkdosfs/dev/sda6 Note: format the device into a fat16Linux file system, which is the same as mkfs. msdos.
  9. ......

2) mkswap format a partition into a swap zone;

 
 
  1. [Root @ localhost beinan] # mkswap/dev/sda6 Note: create this partition as a swap Partition
  2. [Root @ localhost beinan] # swapon/dev/sda6 Note: Load swap partitions;
  3. [Root @ localhost beinan] # swapoff/dev/sda6 Note: Disable swap partition;

Check the swap partition that has been loaded by the system;

 
 
  1. [Root @ localhost beinan] # swapon/dev/sda6 Note: Load swap partitions;
  2. [Root @ localhost beinan] # swapon-s
  3. Filename Type Size Used Priority
  4. /Dev/hda7 partition 787144 0-1
  5. /Dev/sda6 partition 225144 0-3
  6. <Code> 

Why does my system have two swap partitions? Because the experiment I did with a mobile USB flash drive is mainly used for writing tutorials; sda6 is the swap partition I created on the USB flash drive; If swap is loaded upon startup, change the/etc/fstab file and add a line similar to the following;

 
 
  1. <code> 
  2. /dev/sda6         swap     
  3.  swap    defaults        0 0   

Note: Change/dev/hda7 in this row to your swap partition, or directly write the command line to/etc/rc. d/rc. this is also done in local; swapon/dev/sda6 if your hard disk cannot be partitioned, you can create a swap file [root @ localhost beinan] # dd if =/dev/zero of =/tmp/swap bs = 1024 count = 524288 note: create a 512 M swap file in the/tmp directory. You can create a swap file based on your needs;

Read 524288 + 0 blocks and output 524288 + 0 blocks [root @ localhost beinan] # mkswap/tmp/swap Note: Put the/tmp/swap file, create swap zone Setting up swapspace version 1, size = 536866 kBno label, UUID = d9d8645d-92cb-4d33-b36e-075bb0a2e278 [root @ localhost beinan] # swapon/tmp/swap Note: Mount swap

 
 
  1. [root@localhost beinan]# swapon -s  
  2. Filename Type Size Used Priority  
  3. /dev/hda7 partition 787144 888 -1  
  4. /tmp/swap file 524280 0 -2 

Note: In fact, we have already divided swap partitions when installing the system; view/etc/fstab, which should be the line of swap; if you did not add swap when installing the system, you can add them in this way;

  1. Linux File System directory structure
  2. Partitioning and formatting Linux USB flash disks and creating Linux File Systems
  3. How to detach a linux File System from a computer
  4. Briefly describe the organizational structure of the Linux File System
  5. How to delete a Linux File System

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.