The meaning of creating a file system is to format a hard disk partition and create different file systems in different formats.
Format:
Low-level formatting: Performs before partitioning, mainly partitioning tracks of hard disks, etc.
-
Advanced formatting: partitioned and executed to create a file system
-
What you do when you create a file system: When you create a file on your hard disk, you can use the name of the file to find it later.
The file contains two parts:
-
Metadata (including permissions, ownership/group, timestamp, size, data block pointer, etc.)
Data block pointer: Points to the location of the file contents in the data area (depending on the size of the file contents, there will be multiple locations)
The content of the data itself.
When creating a file system, divide the entire partition into two zones, one large and one small.
-
A small area holds metadata for each file, called a metadata area (also known as an Inode table)
Metadata for each file, called inode (index node)
-
A large area holds the contents of the file itself, called a data area
The data area needs to be divided into a bunch of blocks again, and blocks are typically a multiple of the sector size.One sector is 512bytes.
-
Metadata area and data area legend:
-
What is the ratio of the size of the metadata area to the size of the data area?
If the size of the file is small and there are a large number of files, it will happen that the metadata area is full, but there is still a lot of space in the data area.
If the size of the file is large and the number of files is small, it will happen that the data area is full, but there is still a lot of space in the metadata area.
-
-
General file: The data block pointer area in its metadata, which stores the address of the data area.Occupies storage space in the data area of the partition.
Symbolic link file: The pointer area of the data block in its metadata, which is not the address of the data area, but the path of the actual file.Therefore, it does not take up storage space in the data area of the partition.It only takes up storage space in the metadata area.
Device file: The pointer area of the data block in its metadata, stored not as the address of the data area, but as the primary and secondary device numbers.Therefore, it does not take up storage space in the data area of the partition.It only takes up storage space in the metadata area.
View the inode number of the file.
- Use ls-i files, or stat files
Operating system, how do I know which inode s are not used and which block s are used?
Search the entire data area to be sure you know how block s are being used.
Searching the entire metadata area will certainly tell you how inode is being used, but performance is too slow.
So look for a block of space in the metadata area and store two things called bitmap indexes.
One is the Inode bitmap of the inode.
One is the Block bitmap index.
Each bit of the bitmap index corresponds to an inode/block, where 0 indicates that the inode/block is not used and 1 indicates that the inode/block has been used.
Searching for bitmap indexes is much faster.
super block
If there is only one metadata area and one data area in a partition, even if there are bitmap indexes, there are too many indexes and it takes time to traverse through them. So the actual file system has multiple metadata areas and data areas. As shown below, each metadata area and data area form a separate logical partition, which is independent and autonomous, and in each logical partition, bits are created again.Graph index.With logical partitions, a central government, called a superblock, is needed to manage them.
Supblock: Records information about logical partitions.
If the super block is corrupted, the entire partition is scrapped, so the super block must be redundant, so it is placed in the data area of multiple logical partitions.As follows:
There is no name for the file in inode. Where is the name?It's in the catalog.A directory is also a file, not a folder in windows.
The directory block contains the inode number for the files and files in the directory.
The following diagram shows the metadata area, the data area, and how to find the file/var/log/messages
Once the file on the hard disk is found, it is placed in the memory [buff/cache]. The next time the user accesses the file, it can be read from the memory quickly.
Use the free command to view the memory:
# free -h total used free shared buff/cache available Mem: 3.7G 336M 3.0G 13M 429M 3.1G Swap: 3.9G 0B 3.9G
Differences between hard links and symbolic links
The operating system can find its corresponding inode number based on the strength of the file.
-
Hard link:
- Create Hard Link Command: ln src link_file
- Multiple hard-linked files with the same inode number
- Hard links cannot cross file systems because each file system has a different inode count.
- Creating hard links increases inode's reference count, and removing hard links reduces inode's reference technique, whether the data area corresponds to space when inode's reference count becomes zero.
- Directories do not support hard links to prevent circular references.
-
Symbolic links:
Create Symbolic Link Command: Ln-S SRC link_file
Symbolic link file, with its own independent inode.
Can span file systems
Create or delete symbolic links without affecting inode reference counts
Symbolic links can point to directories
-
The size of a symbolic link is the number of bytes in the path string of the file it specifies
$ ls -l lrwxrwxrwx. 1 ys ys 14 Dec 27 13:25 sl1 -> Symbolic Link 11 -rw-rw-r--. 1 ys ys 0 Dec 27 13:24 Symbolic Link 11
Linux supports most file systems, which one is best?There is no better but better.
Different file systems to suit different scenarios.
Partitions are divided differently for different file systems.For programs that read and write files, it is too difficult to write different code for each file system.So how does linux solve this problem?Use VFS.
VFS: virtual FIle System Virtual File System.
A file reader and writer program that only works with VFS, then VFS works with individual file systems.
VFS gives programmers a unified, concise API interface.
Which file systems are supported by Linux:
- ext2,ext3,ext4: basically eliminated.Limited size of a single file
- xfs: Red Hat 7 seems to be using xfs at first.centos7 seems to use this file system.Features: There is no limit to the size of a single file
- relserfs: It's relatively easy to retrieve files that were deleted by mistake, but the author is in prison, so it's not mainstream.
- btrfs: Feature: There is no limit on the size of a single file.Good performance, but it's still in beta.
- iso9660: File system for optical discs (including dvd and vcd)
- nfs, cifs: Network File System
- gfs2, ocfs2: Cluster File System
- ceph: kernel-level distributed file system
- File system for vfat(fat32), ntfs:windows
- proc, sysfs, tmpfs, hugepagefs: pseudo file system
- UFS (Unix file system), FFS (fast file system), JFS (log file system): File system under Unix.
- Swap: swap file system
- mogilefs, moosefs, glusterfs: User-space distributed file systems.
Logging in File System
A problem has led to logging in the file system.
When writing to the hard disk, first find an idle inode to write metadata information, but size is unknown until all the data has been written to it. While writing to the data area, it suddenly shuts down and writes part of the data. When booting up again, the operating system checks for bad data.
Scanning the hard disk's inode and data areas to find the bad block s makes it too slow to start.How to solve it?journal is on!
Logging function:
- Find an area on the hard disk that is the log area.
- When you create a file, write metadata information to the log area instead of the metadata area.
- The data is then written to the data area, and when all the data is written to the data area, the metadata of the log area is cut to the metadata area.
- When the system starts, just look at the hard disk's log area. If there is data in the log area, this is bad data.The system speed is accelerated.
Disadvantages of logging:
- An IO has been added to the log area because it cuts data from the log area to the metadata area.
Common file systems in Linux: ext2,ext3,ext4, xfs, relserfs, btrfs
Only ext2 is log-free.
File System Components
-
File System Driver: Provided by Kernel Space.
The driver for the file system can choose to compile directly into the kernel space or install into the kernel space as a module.
Using the lsmod command, you can see which file system driver module s are installed in the kernel.
# lsmod Module Size Used by fuse 91880 3 xt_CHECKSUM 12549 1 iptable_mangle 12695 1 xfs 997127 3
If you find that the driver module of the desired file system is not in it, it may also be compiled directly into kernel space.
Drivers for file systems compiled directly into kernel space, not in lsmod results.
File System Management Tools: Provided by User Space Applications
File System Tools
1, Tools for creating file systems
-
Mkfs: mkfs.ext2, mkfs.ext3, mkfs.ext4, mkfs.xfs, mkfs.vfat, etc.
You can use the option: -t to specify the installation instructions file system.Example: mkfs-t ext4= mkfs.ext4
ext4 compatible with ext3, ext3 compatible with ext2.
Here's how to create an ext2 file system:
# fdisk -l /dev/sdb Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x2594e4e1 Device Boot Start End Blocks Id System /dev/sdb1 2048 411647 204800 83 Linux /dev/sdb2 411648 616447 102400 5 Extended /dev/sdb5 413696 516095 51200 83 Linux # mkfs.ext2 /dev/sdb1 #Install file system ext2 in / dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label=Identify the volume label of the device OS type: Linux Block size=1024 (log=0)Block size, no specified size, default is 1 K Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 51200 inodes(51200 created inode), 204800 blocks(204800 created blocks) 10240 blocks (5.00%) reserved for the super user(Reserved 5 for Administrator%Space) First data block=1(The first data is numbered 1 block) Maximum filesystem blocks=67371008 25 block groups(hold block Divided into 25 groups) 8192 blocks per group(8192 per group block), 8192 fragments per group 2048 inodes per group(There are 2048 in each group block) Superblock backups stored on blocks:(super block Blocks stored under block number) 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Writing superblocks and filesystem accounting information: done # Blkid/dev/sdb1 View/dev/sdb1 File System and UUID /dev/sdb1: UUID="4752177b-e026-483d-b166-19229b64e4c3" TYPE="ext2"
Here's how to create an ext3 file system: There's more room for the logs below than in ext2.
Creating journal (4096 blocks): done
# mkfs.ext3 /dev/sdb5 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 12824 inodes, 51200 blocks 2560 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=52428800 7 block groups 8192 blocks per group, 8192 fragments per group 1832 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done # blkid /dev/sdb5 /dev/sdb5: UUID="8f066109-6fcf-4c40-812a-66909b54469e" SEC_TYPE="ext2" TYPE="ext3"
Create an xfs file system:
There are no xfs in centos5 and 6 and they need to be installed.Installation command: yum install xfsprogs
# mkfs.xfs -f /dev/sdb5 meta-data=/dev/sdb5 isize=512 agcount=2, agsize=6400 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=12800, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=855, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@localhost ~]# blkid /dev/sdb5 /dev/sdb5: UUID="d73b8a2c-147d-4322-80a4-812553696c26" TYPE="xfs"
Yum Tip: See what's included in the package installed with yum:
# rpm -ql xfsprogs /usr/lib64/libhandle.so.1 /usr/lib64/libhandle.so.1.0.3 /usr/sbin/fsck.xfs /usr/sbin/mkfs.xfs /usr/sbin/xfs_admin /usr/sbin/xfs_bmap /usr/sbin/xfs_copy /usr/sbin/xfs_db /usr/sbin/xfs_estimate /usr/sbin/xfs_freeze /usr/sbin/xfs_fsr /usr/sbin/xfs_growfs /usr/sbin/xfs_info /usr/sbin/xfs_io /usr/sbin/xfs_logprint /usr/sbin/xfs_mdrestore /usr/sbin/xfs_metadump /usr/sbin/xfs_mkfile /usr/sbin/xfs_ncheck /usr/sbin/xfs_quota /usr/sbin/xfs_repair /usr/sbin/xfs_rtcp ...Later omitted
ext file system special manager: mke2fs
Syntax: mke2fs [options] device
-
Specify file system: -t
mke2fs -t {ext2|ext3|ext4}
-
Specify blocksize:-b {1024|2048|4096}
# mke2fs -t ext4 -b 2048 /dev/sdb5 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=2048 (log=1) Fragment size=2048 (log=1)
-
Specify a volume label: -L
Volume labels are not normally specified because they are easy to repeat.
When you specify a volume label, you can see it with the blkid command.
# mke2fs -t ext4 -L myLabel1 /dev/sdb5 mke2fs 1.42.9 (28-Dec-2013) Filesystem label=myLabel1 # blkid /dev/sdb5 /dev/sdb5: LABEL="myLabel1" UUID="3bd32005-bea7-42bb-969e-3b37de466f3e" TYPE="ext4"
The volume label is repeated, but the UUID is different.
# mke2fs -t ext4 -L myLabel1 /dev/sdb6 mke2fs 1.42.9 (28-Dec-2013) Filesystem label=myLabel1 # blkid /dev/sdb5 /dev/sdb5: LABEL="myLabel1" UUID="3bd32005-bea7-42bb-969e-3b37de466f3e" TYPE="ext4" [root@localhost ~]# blkid /dev/sdb6 /dev/sdb6: LABEL="myLabel1" UUID="7e71e3a9-5075-4b07-97fc-af7eefae27fc" TYPE="ext4"
Change volume labels for ext2,ext3,ext4: e2label
- View the volume label of the partition: e2label device
- Modify partition label: e2label device LABEL
-
Create a log-enabled file system: -j
mke2fs -j=mke2fs -t ext3=mkfs -t ext3=mkfs.ext3
-
Create an inode:-i for every number of bytes
Indicates the ratio of inode to bytes.
-
Specify the number of inode s: -N number
The number of inode s specified directly may be better than the ratio specified with -i.
-
Specify the size of the inode:-I (large i)
The inode-size value must be a power of 2 larger or equal to 128.
-
An enable file system feature: -O feature
Or disable a feature of the file system: -O-featureLater-O ^feature
FeatureOverview: View with man 5 ext4
Mke2fs-O has_journal device: Start logging
-
Specify a percentage of the size of the reserved space (super block): -m number (no need to add, 2 is 2%)
The default is to reserve 5%, but if it is a 100G partition, 5G is too big.
2. Tools to detect and repair file systems
When the system terminates abnormally due to unexpected process termination or system crash (power outage), file damage may occur; at this time, the file system should be checked and repaired.Recommendation: Offline
-
ext File System Series: e2fsck
- -y: Automatically answer yes to all questions
- -f: Force process checking even if the file system is clean.
# e2fsck -f /dev/sdb6 e2fsck 1.42.9 (28-Dec-2013) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information L1: 11/6400 files (0.0% non-contiguous), 2155/25600 blocks
-
All file systems: fsck
# fsck. fsck.btrfs fsck.ext2 fsck.ext4 fsck.minix fsck.vfat fsck.cramfs fsck.ext3 fsck.fat fsck.msdos fsck.xfs
-t: Indicates the file system type
-
-a: All errors do not need to be automatically fixed interactively (not recommended)
If there is a 2G file written to 1.9G, the system will be powered off.If you don't fix it, you can still keep 1.9G. If you fix it with -a, you delete this 1.9G as well.
-r: Interactive repair
3, Tool to view detailed information about the properties and groups of the ext family file system: dumpe2fs
-
View attributes only: -h
# dumpe2fs -h /dev/sdb6 dumpe2fs 1.42.9 (28-Dec-2013) Filesystem volume name: L1 Last mounted on: <not available> Filesystem UUID: c48a5e5a-2ebf-42e6-a191-87496b19e281 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 6400 Block count: 25600 Reserved block count: 1536 Free blocks: 23445 Free inodes: 6389 First block: 1 Block size: 1024 Fragment size: 1024 Reserved GDT blocks: 99 Blocks per group: 8192 Fragments per group: 8192 Inodes per group: 1600 Inode blocks per group: 200 Filesystem created: Fri Dec 27 21:24:40 2019 Last mount time: n/a Last write time: Fri Dec 27 22:19:54 2019 Mount count: 0 Maximum mount count: -1 Last checked: Fri Dec 27 21:24:40 2019 Check interval: 0 (<none>) Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Journal inode: 8 Default directory hash: half_md4 Directory Hash Seed: ea467d23-e9b0-43ca-b762-f6b70ea21180 Journal backup: inode blocks Journal features: (none) Journal size: 1029k Journal length: 1024 Journal sequence: 0x00000001 Journal start: 0
-
Group details: no options
Details of the group include:
- Which block is the super block stored in
- Which blocks are stored in the Reserved GDT blocks
- Which blocks are stored in the Inode bitmap of inode
- Block bitmap blocks
- Which blocks in a group store metadata (Inode table)
- How many block s are available; how many inode s are available; and how many directories are in the group.
- What is the number of block s that can be used and what is the number of inode s that can be used.
# dumpe2fs /dev/sdb6 //head information is omitted here. Group 0: (Blocks 1-8192) Primary superblock at 1, Group descriptors at 2-2 Reserved GDT blocks at 3-101 Block bitmap at 102 (+101), Inode bitmap at 103 (+102) Inode table at 104-303 (+103) 7875 free blocks, 1589 free inodes, 2 directories Free blocks: 318-8192 Free inodes: 12-1600 Group 1: (Blocks 8193-16384) Backup superblock at 8193, Group descriptors at 8194-8194 Reserved GDT blocks at 8195-8293 Block bitmap at 8294 (+101), Inode bitmap at 8295 (+102) Inode table at 8296-8495 (+103) 7889 free blocks, 1600 free inodes, 0 directories Free blocks: 8496-16384 Free inodes: 1601-3200 Group 2: (Blocks 16385-24576) Block bitmap at 16385 (+0), Inode bitmap at 16386 (+1) Inode table at 16387-16586 (+2) 6961 free blocks, 1600 free inodes, 0 directories Free blocks: 17616-24576 Free inodes: 3201-4800 Group 3: (Blocks 24577-25599) Backup superblock at 24577, Group descriptors at 24578-24578 Reserved GDT blocks at 24579-24677 Block bitmap at 24678 (+101), Inode bitmap at 24679 (+102) Inode table at 24680-24879 (+103) 720 free blocks, 1600 free inodes, 0 directories Free blocks: 24880-25599 Free inodes: 4801-6400
4. Adjust the characteristics of the ext filesystem: tune2fs
View/adjust the adjustable attributes of the ext2/ext3/ext4 file system, not all attributes, such as block s, cannot be resized.
-
View the information in the super block / view the layout information of the file system: -l
# tune2fs -l /dev/sdb5 tune2fs 1.42.9 (28-Dec-2013) Filesystem volume name: myLabel1(Volume label) Last mounted on: <not available>(Last mounted, not yet mounted) Filesystem UUID: 3bd32005-bea7-42bb-969e-3b37de466f3e(UUID) Filesystem magic number: 0xEF53(Magic number, identifying the file system) Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize(What is enabled for the file system feature) Filesystem flags: signed_directory_hash Default mount options: user_xattr acl(Mount Options for File System) Filesystem state: clean(File system status. clean: The file system is consistent and there are no corrupted files.If there is a corrupt file dirty Status.) Errors behavior: Continue(Handling in case of errors, continue Processing regardless of error) Filesystem OS type: Linux Inode count: 12824(inode Quantity) Block count: 51200(block Quantity) Reserved block count: 2560(Reserved for super block Quantity) Free blocks: 44440(Idle block Quantity) Free inodes: 12813(Idle inode Quantity) First block: 1(Number of the first block) Block size: 1024(The size of the block in units of byte) Fragment size: 1024 Group descriptor size: 64 Reserved GDT blocks: 256(Reserved for GDT Of block Quantity) Blocks per group: 8192(In each group block Quantity) Fragments per group: 8192 Inodes per group: 1832(In each group inode Quantity) Inode blocks per group: 229(How many pieces per group to store inode) Flex block group size: 16 Filesystem created: Fri Dec 27 16:48:53 2019 Last mount time: n/a Last write time: Fri Dec 27 16:48:53 2019 Mount count: 0 Maximum mount count: -1 Last checked: Fri Dec 27 16:48:53 2019 Check interval: 0 (<none>) Lifetime writes: 4445 kB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128(inode Size) Journal inode: 8 Default directory hash: half_md4 Directory Hash Seed: 05ca7d6b-d6b6-4e15-854f-e9d49f0f3f61 Journal backup: inode blocks
-
Upgrade ext2 to ext3:-j
Lossless upgrade without damaging files in the file system
# blkid /dev/sdb6 /dev/sdb6: UUID="c48a5e5a-2ebf-42e6-a191-87496b19e281" TYPE="ext2" # tune2fs -j /dev/sdb6 tune2fs 1.42.9 (28-Dec-2013) Creating journal inode: done # blkid /dev/sdb6 /dev/sdb6: UUID="c48a5e5a-2ebf-42e6-a191-87496b19e281" SEC_TYPE="ext2" TYPE="ext3"
-
Lossless Modification Volume Label: -L LABEL
# tune2fs -L L1 /dev/sdb6 tune2fs 1.42.9 (28-Dec-2013) [root@localhost ~]# blkid /dev/sdb6 /dev/sdb6: LABEL="L1" UUID="c48a5e5a-2ebf-42e6-a191-87496b19e281" SEC_TYPE="ext2" TYPE="ext3"
-
Percentage of space reserved for super block modified lossless: -m number
# tune2fs -m 6 /dev/sdb6 tune2fs 1.42.9 (28-Dec-2013) Setting reserved blocks percentage to 6% (1536 blocks)
-
An enable file system feature: -O feature
Or disable a feature of the file system: -O-featureLater-O ^feature
After disable logging, the file system type changed from ext3 to ext2; after enable, it changed from ext2 to ext3
FeatureOverview: View with man 5 ext4
# tune2fs -O ^has_journal /dev/sdb6 tune2fs 1.42.9 (28-Dec-2013) # blkid /dev/sdb6 disable After logging, the file system type is changed from ext3 Became ext2 /dev/sdb6: LABEL="L1" UUID="c48a5e5a-2ebf-42e6-a191-87496b19e281" TYPE="ext2" # tune2fs -l /dev/sdb6 feature No more in has_journal Filesystem features: ext_attr resize_inode dir_index filetype sparse_super # tune2fs -O has_journal /dev/sdb6 tune2fs 1.42.9 (28-Dec-2013) Creating journal inode: done # blkid /dev/sdb6 /dev/sdb6: LABEL="L1" UUID="c48a5e5a-2ebf-42e6-a191-87496b19e281" SEC_TYPE="ext2" TYPE="ext3" # tune2fs -l /dev/sdb6 Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super
-
Mount options for enable d file system: -o mount_options
Or disable mount options for the file system: -o-mount_options the latter-o ^mount_options
Specific mount options can be seen in the -o option of man tune2fs.
For example, disable acl (access control list, special permission control for files).
When centos7 creates the file system, acl is started by default.
The getfacl,setfacl commands only work if the acl function is enabled here on the file system.
5, according to the volume label (LABEL), UUID to locate the device: blkid
-
View the device's volume label and UUID
# blkid /dev/sdb6 /dev/sdb6: LABEL="L1" UUID="c48a5e5a-2ebf-42e6-a191-87496b19e281" SEC_TYPE="ext2" TYPE="ext3"
-
Locate device according to volume label: -L
# blkid /dev/sdb6 /dev/sdb6: LABEL="L1" UUID="c48a5e5a-2ebf-42e6-a191-87496b19e281" SEC_TYPE="ext2" TYPE="ext3" # blkid -L L1 /dev/sdb6
-
Locate device according to UUID: -U
# blkid /dev/sdb6 /dev/sdb6: LABEL="L1" UUID="c48a5e5a-2ebf-42e6-a191-87496b19e281" SEC_TYPE="ext2" # blkid -U c48a5e5a-2ebf-42e6-a191-87496b19e281 /dev/sdb6
swap file system
The swap file system on linux must be in a separate partition and the system id must be 82
The swap file system on window s can be partitioned with the operating system, such as on the c drive.
1, create swap file system: mkswap
-
Volume label and UUID are not specified.If there are volume labels and UUIDs on the original/dev/sdb6, after executing mkswap/dev/sdb6, /dev/sdb6's volume labels and UUIDs are deleted and a new UUID is generated.
# mkswap /dev/sdb6 mkswap: /dev/sdb6: warning: wiping old ext3 signature. Setting up swapspace version 1, size = 25596 KiB no label, UUID=c9f3ecb5-d82e-461a-9701-23a364792800
Note: If the original system id of /dev/sdb6 is not 82, then after executing mkswap/dev/sdb6, the system id will not automatically change to 82. You also need to modify the system id manually using the -t option of fdisk.
-
Specify volume label: -L LABEL
# blkid -L L1 [root@localhost ~]# mkswap -L L1 /dev/sdb6 mkswap: /dev/sdb6: warning: wiping old swap signature. Setting up swapspace version 1, size = 25596 KiB LABEL=L1, UUID=3e848623-b82a-4a4f-9c58-53b868260208 [root@localhost ~]# blkid -L L1 /dev/sdb6 [root@localhost ~]# blkid /dev/sdb6 /dev/sdb6: LABEL="L1" UUID="3e848623-b82a-4a4f-9c58-53b868260208" TYPE="swap"
Specify UUID:-U UUID
Vfatfile system
Windows does not recognize Linux's file system, so when storage devices need to be used across two systems, you should use a file system that is supported by both windows and linux: fat32 (vfat).
Create a vfatfile system: mkfs.vfat device
# mkfs.vfat /dev/sdb5 mkfs.fat 3.0.20 (12 Jun 2013)