Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Disk formatting and mounting

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

In the windows operating system, the hard disk has a variety of formats such as fat32 and ntfs. The same is true in linux. Before CentOS 6, it was mainly in ext4, ext3, and ext2 formats. Since the CentOS 7 release, the default disk format has been changed to xfs format.

[root@server02 ~] # cat / etc/filesystemsxfsext4ext3ext2nodev procnodev devptsiso9660vfathfshfsplus* [root@server02 ~] # mount / / View the file system type of the partition Need to mount to see sysfs on / sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel) proc on / proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on / dev type devtmpfs (rw,nosuid,seclabel,size=494380k,nr_inodes=123595,mode=755) securityfs on / sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on / dev/shm type tmpfs (rw,nosuid,nodev,seclabel) devpts on / dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620 Ptmxmode=000) tmpfs on / run type tmpfs (rw,nosuid,nodev,seclabel,mode=755) tmpfs on / sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755) cgroup on / sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on / sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on / sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime Freezer) cgroup on / sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu) cgroup on / sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids) cgroup on / sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on / sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio Net_cls) cgroup on / sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) cgroup on / sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on / sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on / sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) cgroup on / sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime Blkio) configfs on / sys/kernel/config type configfs (rw,relatime) / dev/sda3 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota) selinuxfs on / sys/fs/selinux type selinuxfs (rw,relatime) systemd-1 on / proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) debugfs on / sys/kernel/debug type debugfs (rw,relatime) hugetlbfs on / dev/hugepages type hugetlbfs (rw,relatime,seclabel) mqueue on / dev/mqueue type mqueue (rw,relatime Seclabel) / dev/sda1 on / boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota) tmpfs on / run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=100840k,mode=700)

I. disk formatting

Meaning of command parameters

Mke2fs

-t

Specified format, xfs is not supported

Mkfs.ext4 = mke2fs-t ext4

-b specify block size-m specify reserved space ratio (default 5% reserved for superuser)-I specify the number of inode for each group, default 4 blocks correspond to 1 inodemkfs.xfs

Formatted into xfs

Test example:

[root@server02 ~] # mke2fs-t xfs / dev/sdb2mke2fs 1.42.9 (28-Dec-2013) Your mke2fs.conf file does not define the xfs filesystem type.Aborting... [root@server02 ~] # mkfs.xfs / dev/sdb2meta-data=/dev/sdb2 isize=512 agcount=4, agsize=131072 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 Sparse=0data = bsize=4096 blocks=524288, imaxpct=25 = sunit=0 swidth=0 blksnaming = version 2 bsize=4096 ascii-ci=0 ftype=1log = internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime = none extsz=4096 blocks=0 Rtextents=0 [root@server02 ~] # blkid / dev/sdb2 / dev/sdb2: UUID= "d1873a00-ba11-4635-81af-a1e9bd697f70" TYPE= "xfs"

2. Disk mounting

Only formatted partitions can be mounted. Mount uses the mount command, and uninstall uses the umount command. Use "- o" to follow a variety of options. The default options are rw,suid,dev,exec,auto,nouser, and async.

[root@server02 ~] # mount / dev/sdb2 / mnt/ [root@server02 ~] # mount / dev/sdb3 / mnt/mount: / dev/sdb3 write protection Mount will be mounted read-only: unknown file system type "(null)" [root@server02 ~] # df-h File system capacity used used mount point / dev/sda3 28G 1016M 27G 4% / devtmpfs 483M 0483M 0% / devtmpfs 493M 0493M 0% / dev/shmtmpfs 493M 6.8m 486m 2 % / runtmpfs 493M 0493M 0% / sys/fs/cgroup/dev/sda1 197m 109M 88M 56% / boottmpfs 99m 099m 0% / run/user/0/dev/sdb2 2.0G 33M 2.0G 2% / mnt [root@server02 ~] # umount / dev/sdb2 [root@server02 ~] # df-h file system capacity is available With% mount point used / dev/sda3 28G 1016M 27G 4% / devtmpfs 483M 0 483M 0% / devtmpfs 493M 0 493M 0% / dev/shmtmpfs 493M 6.8M 486m 0% / runtmpfs 493M 0493M 0% / sys/fs/cgroup/dev/sda1 197M 109M 88M 56% / boottmpfs 99m 099M 0% / run/user/0

Partitions mounted by the mount command are only currently valid and will disappear when the system is rebooted. Unmount the partition in the / etc/fstab file so that the system can be mounted by default at startup. You can use the mount-a command to automatically load the configuration in the configuration file.

[root@server02 ~] # cat / etc/fstab## / etc/fstab# Created by anaconda on Sat May 27 06:10:33 2017 December # Accessible filesystems, by reference, are maintained under'/ dev/disk'# See man pages fstab (5), findfs (8) Mount (8) and/or blkid (8) for more info#UUID=de480d95-018b-4e0b-a874-083a13d8412d / xfs defaults 0 0UUID=82044aec-23c6-4e7f-8f05-51a24c0c956a / boot xfs defaults 0 0UUID=be771427-d6c1-4d01-a8ab-a473e8df8ac5 swap swap defaults 0 [root@server02] # man fstab.DESCRIPTION The file fstab contains descriptive information about the various file systems. Fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file. Each filesystem is described on a separate line; fields on each line are separated by tabs or spaces. Lines starting with'# 'are comments, blank lines are ignored. The order of records in fstab is important because fsck (8), mount (8), and umount (8) sequentially iterate through fstab doing their thing.The first field (fs_spec). / / UUID or LABEL This field describes the block special device or remote filesystem to be mounted.The second field (fs_file). / / Mount point This field describes the mount point for the filesystem. For swap partitions, this field should be specified as `none'. If the name of the mount point contains spaces these can be escaped as `\ 040'.The third field (fs_vfstype). / / Partition format This field describes the type of the filesystem. Linux supports lots of filesystem types, such as adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, ext2, ext3, hfs,hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs, and possibly others. For more details, see mount (8). The fourth field (fs_mntops). / / optional This field describes the mount options associated with the filesystem.The fifth field (fs_freq). / / whether to back up This field is used for these filesystems by the dump (8) command to determine which filesystems need to be dumped. If the fifth field is not present, a value of zero is returned and dump will assume that the filesystem does not need to be dumped.The sixth field (fs_passno). / / whether to turn on the test, no check is 0, check is 2 This field is used by the fsck (8) program to determine the order in which filesystem checks are done at reboot time. The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. If the sixth field is not present or zero, a value of zero is returned and fsck will assume that the filesystem does not need to be checked.

Another way to boot and mount automatically is to write the mount command in / etc/rc.local, and the boot automatically executes the mount command to achieve the mount effect.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report