Linux hard disk format, partition, mount, unmount, delete partition

Linux hard disk format, partition, mount, unmount, delete partition

After the Linux 2.6 kernel, linux will create the corresponding device file under /dev/ for the identified hardware device. For example:

sda means the first SCSI hard disk

hda means the first IDE hard disk (that is, connected to the Master port of the first IDE interface)

scd0 represents the first USB optical drive.

0. Check the mount status

df -hl

It can be seen that the system only mounts 40G /dev/vda1 in the / directory, which are assigned to different folders

1. View hard disk information

fdisk -l

There is a 20G /dev/vdb unpartitioned

2. Create partitions

fdisk /dev/vdb

Enter in ordern , p , 1 , 回车 , 回车 , wq , 回车

n : create a new partition
p : select primary partition
1 : partition number
wq: save and exit

3. View disk information

fdisk -l

see partitioned disks/dev/vdb1

4. Format the partition

mkfs.ext4 /dev/vdb1

If you want to format to other formats, you can also

5. Write the partition information to fstab, and set it to mount automatically at startup

vim /etc/fstabwrite /dev/xvdb1 /data ext4 defaults 0 0save and exit

6. Mount the partition

mount -a

7. View the partition mount status

8. Unmount

umount /dev/vdb1

9. Delete partition

fdisk /dev/vdb

enterd , wq

d : delete partition

10. Check again

Found that it has become an unpartitioned state

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324945612&siteId=291194637