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

Three-step operation of centos7 hard disk (partition, format, mount)

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

Share

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

One: partition using fdisk partition MBR format using parted partition GPT format fdisk commonly used commands n (new): create new partition d (delete): delete existing partition t (type): modify partition type l (list): view all supported types p (print): display existing partition information W (write): save and exit Q (quit): do not save and exit 1. View hard disk partition information # fdisk-L2. Use fdisk to specify the new hard disk format (/ dev/sdb), MBR format hard disk can only have up to 4 primary partitions # fdisk / dev/sdb 2.1. Create the primary partition [cqs@centos7 ~] $sudo fdisk / dev/sdb Welcome to fdisk (util-linux 2.23.2). The changes remain in memory until you decide to write them to disk. Think twice before using the write command.

Command (enter m for help): n

Partition type:

P primary (0 primary, 0 extended, 4 free)

E extended

Select (default p): P

Partition number (1-4, default 1): 1

Start sector (2048-104857599, default is 2048):

The default value of 2048 will be used

Last sector, + sector or + size {K Magne M Magi G} (2048-104857599, default is 104857599): + 25G

Partition 1 has been set to type Linux and the size is set to 25 GiB

Command (enter m for help): P

Disk / dev/sdb:53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sector of 1 * 512 = 512 bytes

Sector size (logical / physical): 512 bytes / 512 bytes

Igamo size (minimum / best): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x8c7d553d

Device Boot Start End Blocks Id System

/ dev/sdb1 2048 52430847 26214400 83 Linux

2.2 create an extended partition

Command (enter m for help): n

Partition type: P primary (1 primary, 0 extended, 3 free) e extended

Select (default p): e

Partition number (2-4, default 2): start sector (52430848-104857599, default is 52430848): the default value 52430848Last sector will be used, + sector or + size {K Magne M ·G} (52430848-104857599, default is 104857599): will use the default value 104857599 partition 2 has been set to Extended type and the size is set to 25 GiB

Command (enter m for help): P

Disk / dev/sdb:53.7 GB, 53687091200 bytes, 104857600 sector Units = sector of 1 * 512 = 512bytes sector size (logical / physical): 512byte / 512byte I size O (min / best): 512byte / 512byte disk label type: dos disk identifier: 0x8c7d553d device Boot Start End Blocks Id System/dev/sdb1 2048 52430847 26214400 83 Linux

/ dev/sdb2 52430848 104857599 26213376 5 Extended

2.3 create logical Partition command (enter m for help): n

Partition type:

P primary (1 primary, 1 extended, 2 free)

L logical (numbered from 5)

Select (default p): l

Add logical Partition 5

Start sector (52432896-104857599, default is 52432896):

The default value of 52432896 will be used

Last sector, + sector or + size {K _ Magne _ M _ G} (52432896-104857599, default is 104857599):

The default value of 104857599 will be used

Partition 5 has been set to type Linux and the size is set to 25 GiB

Command (enter m for help): P

Disk / dev/sdb:53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sector of 1 * 512 = 512 bytes

Sector size (logical / physical): 512 bytes / 512 bytes

Igamo size (minimum / best): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x8c7d553d

Device Boot Start End Blocks Id System/dev/sdb1 2048 52430847 26214400 83 Linux/dev/sdb2 52430848 104857599 26213376 5 Extended/dev/sdb5 52432896 104857599 26212352 83 Linux command (enter m for help): W

The partition table has been altered!

Calling ioctl () to re-read partition table.

Synchronizing disks.

Note: finally, you must save and exit (w), otherwise the partition will become invalid.

Two: formatting

Format the hard disk as ext4 [cqs@centos7 ~] $sudo mkfs.ext4 / dev/sdb1

Mke2fs 1.42.9 (28-Dec-2013)

File system label =

OS type: Linux

Block size = 4096 (log=2)

Chunk size = 4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

1638400 inodes, 6553600 blocks

327680 blocks (5.00%) reserved for the super user

First data block = 0

Maximum filesystem blocks=2155872256

200 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

4096000

Allocating group tables: done

Writing inode table: complete

Creating journal (32768 blocks): complete

Writing superblocks and filesystem accounting information: done

Three: mounting

1. Create a new mount point [cqs@centos7 ~] $mkdir-p / home/cqs/data [cqs@centos7 ~] $mkdir-p / home/cqs/soft2. Select a partition to the specified mount point (temporarily mounted, it will fail after the machine is rebooted) [cqs@centos7 ~] $sudo mount / dev/sdb1 / home/cqs/data [cqs@centos7 ~] $sudo mount / dev/sdb5 / home/cqs/soft to check whether the hard disk can use [cqs@centos7 ~] $df

File system 1K-Block used available used% mount point

/ dev/sda3 18555904 13630632 4925272 74%

Devtmpfs 747064 0 747064 / dev

Tmpfs 763176 0 763176 / dev/shm

Tmpfs 763176 10828 752348 2% / run

Tmpfs 763176 0 763176 / sys/fs/cgroup

/ dev/sda1 303788 229948 73840 76% / boot

Tmpfs 152636 8 152628 1% / run/user/42

Tmpfs 152636 32 152604 1% / run/user/1001

Tmpfs 152636 0 152636 / run/user/0

/ dev/sdb1 25671908 45080 24299724 1% / home/cqs/data

/ dev/sdb5 25669860 45080 24297780 1% / home/cqs/soft

Check whether the mount point is successful [cqs@centos7 ~] $mount | grep "sdb" / dev/sdb1 on / home/cqs/data type ext4 (rw,relatime,seclabel,data=ordered) / dev/sdb5 on / home/cqs/soft type ext4 (rw,relatime,seclabel,data=ordered)

Test the mount point for errors

# mount-a

Don't restart yet, use mount-a to test whether it can be mounted properly and then restart.

Take effect permanently

# echo "/ dev/sdb1 / home/cqs/data ext4 defaults 0" > > / etc/fstab

# echo "/ dev/sdb5 / home/cqs/soft ext4 defaults 0" > > / etc/fstab

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