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

Fdisk disk partitioning, formatting and auto-mounting on boot

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

First, check the disk status before the partition

] # fdisk-l

Disk / dev/vda:107.4 GB, 107374182400 bytes, 209715200 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: 0x000b4a3a

Device Boot Start End Blocks Id System

/ dev/vda1 * 2048 1026047 512000 83 Linux

/ dev/vda2 1026048 209715199 104344576 8e Linux LVM

Disk / dev/vdb:214.7 GB, 214748364800 bytes, 419430400 sectors

Units = sector of 1 * 512 = 512 bytes

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

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

2. Fdisk format disk / sev/sdb as one disk

] # fdisk / dev/vdb

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.

Device does not contain a recognized partition table

Create a new DOS disk label using the disk identifier 0x8a058557.

Command (enter m for help): M

Command operation

A toggle a bootable flag

B edit bsd disklabel

C toggle the dos compatibility flag

D delete a partition

G create a new empty GPT partition table

G create an IRIX (SGI) partition table

L list known partition types

M print this menu

N add a new partition

O create a new empty DOS partition table

P print the partition table

Q quit without saving changes

S create a new empty Sun disklabel

T change a partition's system id

U change display/entry units

V verify the partition table

W write table to disk and exit

X extra functionality (experts only)

Command (enter m for help): n

Partition type:

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

E extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

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

The default value of 2048 will be used

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

The default value of 419430399 will be used

Partition 1 has been set to type Linux with a size of 200GiB

Command (enter m for help): P

Disk / dev/vdb:214.7 GB, 214748364800 bytes, 419430400 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: 0x8a058557

Device Boot Start End Blocks Id System

/ dev/vdb1 2048 419430399 209714176 83 Linux

Command (enter m for help): W

The partition table has been altered!

Calling ioctl () to re-read partition table.

Synchronizing disks.

3. Check the disk status after partition

] # fdisk-l

Disk / dev/vda:107.4 GB, 107374182400 bytes, 209715200 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: 0x000b4a3a

Device Boot Start End Blocks Id System

/ dev/vda1 * 2048 1026047 512000 83 Linux

/ dev/vda2 1026048 209715199 104344576 8e Linux LVM

Disk / dev/vdb:214.7 GB, 214748364800 bytes, 419430400 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: 0x8a058557

Device Boot Start End Blocks Id System

/ dev/vdb1 2048 419430399 209714176 83 Linux

Format disk to ext4 file format disk

] # mkfs.ext4 / dev/vdb1

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

13107200 inodes, 52428544 blocks

2621427 blocks (5.00%) reserved for the super user

First data block = 0

Maximum filesystem blocks=2199912448

1600 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, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done

Writing inode table: complete

Creating journal (32768 blocks): complete

Writing superblocks and filesystem accounting information: done

5. Mount / dev/vdb1 to / data

] # cd /

/] # mkdir data

/] # mount / dev/vdb1 / data

] # df-h

File system capacity used available used% mount point

/ dev/mapper/cl-root 92G 6.0G 86G 7% /

Devtmpfs 16G 0 16G 0% / dev

Tmpfs 16G 84K 16G 1% / dev/shm

Tmpfs 16G 9.3m 16G 1% / run

Tmpfs 16G 0 16G 0% / sys/fs/cgroup

/ dev/vda1 497m 195m 303m 40% / boot

Tmpfs 3.2G 16K 3.2G 1% / run/user/989

Tmpfs 3.2G 0 3.2G 0% / run/user/0

/ dev/vdb1 197G 61m 187G 1% / data

6. Set up automatic mount on boot.

] # blkid / dev/vdb1

/ dev/vdb1: UUID= "bc972244-2f68-4ba9-af62-6f257c8d2d4a" TYPE= "ext4"

] # vi / etc/fstab (description: edit the file / etc/fstab and insert the line "UUID=bc972244-2f68-4ba9-af62-6f257c8d2d4a / data ext4 defaults 00" at the end of the file)

7. Restart to check whether the auto mount is successful

] # reboot

] #

] #

] #

] #

] # df-h

File system capacity used available used% mount point

/ dev/mapper/cl-root 92G 6.0G 86G 7% /

Devtmpfs 16G 0 16G 0% / dev

Tmpfs 16G 84K 16G 1% / dev/shm

Tmpfs 16G 9.3m 16G 1% / run

Tmpfs 16G 0 16G 0% / sys/fs/cgroup

/ dev/vdb1 197G 61m 187G 1% / data

/ dev/vda1 497m 195m 303m 40% / boot

Tmpfs 3.2G 16K 3.2G 1% / run/user/989

Tmpfs 3.2G 0 3.2G 0% / run/user/0

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