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

Implementation of Centos7 formatting Partition and mounting

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

Share

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

Linux can often encounter situations such as adding a hard disk or remounting a partition. This article briefly records the mounting of a new partition. Since the disk partition has been processed before, the recording begins with the steps such as formatting the partition and subsequent mounting.

1. View the current disk situation

[root@pgtest59 ~] # df-lh File system capacity available available mount point / dev/sdb3 50G 994M 50G 2% / devtmpfs 47G 047G 0% / devtmpfs 47G 047G 0% / dev/shmtmpfs 47G 11G 1% / runtmpfs 47G 047G 0 0% / sys/fs/cgroup/dev/sdb1 1014M 134M 881M 14% / boot/dev/sdb5 392G 33M 392G 1% / hometmpfs 9.3G 0 9.3G 0% / run/user/0tmpfs 9.3G 0% / run/user/1001

This new hard disk is ready to be mounted to / data, so create a mount point first.

[root@pgtest59 ~] # mkdir / data

two。 View partition information

[root@pgtest59] # fdisk-l disk / dev/sda:17997.3 GB, 17997255147520 bytes, 35150888960 sector Units = sector of 1 * 512 = 512bytes sector size (logical / physical): 512byte / 4096byte I size O (minimum / optimal): 4096byte / 4096byte disk / dev/sdb:480.0 GB, 480036847616 bytes 937571968 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512byte / 4096 byte I size O (min / best): 4096 byte / 4096 byte disk label type: dos disk identifier: 0x000b3fc7 device Boot Start End Blocks Id System/dev/sdb1 * 2048 2099199 1048576 83 Linux/dev/sdb2 2099200 10487807 419430482 Linux swap / Solaris/dev/sdb3 10487808 115345407 52428800 83 Linux/dev/sdb4 115345408 937570303 411112448 5 Extended/dev/sdb5 115347456 937570303 411111424 83 Linux

Note: the fdisk-l command can only see the device information that can perform partition operations (for example, the CD will not be displayed), and it will be displayed regardless of whether the partition is mounted or not.

Because the current disk is not formatted, mounting it directly will cause an error, for example:

/ * Mount without formatting * / [root@pgtest59 ~] # mount / dev/sda / data/mount: / dev/sda write protection, mount: unknown file system type "(null)" will be mounted read-only

3. Format Partition

[root@pgtest59 ~] # mkfs.xfs / dev/sda meta-data=/dev/sda isize=512 agcount=17, agsize=268435455 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0data = bsize=4096 blocks=4393861120, imaxpct=5 = sunit=0 swidth=0 blksnaming = version 2 bsize=4096 ascii-ci=0 ftype=1log = internal log bsize=4096 blocks=521728, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1realtime = none extsz=4096 blocks=0, rtextents=0

Note: this time the format is xfs format, or it can be formatted into ext4 or ext3 and other required formats.

4. Mount partition

/ * Mount partition * / [root@pgtest59 ~] # mount / dev/sda / data//* View results * / [root@pgtest59 ~] # df-Th File system Type capacity available available mount point / dev/sdb3 xfs 50G 1.6G 49G 4% / devtmpfs devtmpfs 47G 047G 0% / devtmpfs tmpfs 47G 047G 0% / dev/shmtmpfs tmpfs 47G 11m 47G 1% / runtmpfs tmpfs 47G 0 47G 0% / sys/fs/cgroup/dev/sdb1 xfs 1014M 134M 881M 14% / boot/dev/sdb5 xfs 392G 33M 392G 1% / home/dev/sda xfs 17T 33M 17T 1% / datatmpfs tmpfs 9.3G 0 9.3G 0% / run/user/1001

5. Set the boot to start the automatic mount

This step is easy to miss. In many cases, after processing the previous steps, the partition has been mounted successfully, but if the machine is rebooted, the directory will not be used directly (the df command cannot be seen), so it needs to be set to boot to start automatic mount.

Vim / etc/fstab/* add the following information * / / dev/sda / data xfs defaults 0 0

Note: the device to be mounted can be one of the following:

Names of device files, such as pseudo file systems such as sysfs, proc, tmpfs, etc., are commonly used in UUID,CentOS 7 of LABEL devices of / dev/sda devices.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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