Common disk management commands

1.dd action is a copy of the file with the specified block size, and the designated conversion simultaneous copies.

    Usage: dd [option]

              if = input file (or device name)

              of = output file (or device name)

              ibs = bytes bytes bytes once read, i.e. the number of bytes read into the buffer area

               obs = bytes bytes bytes of the write-once, i.e. number of bytes written in the buffer

                bs = bytes and set the read / write buffer of bytes (and is also set ibs obs)

                 count = blocks copy only blocks block input

   例:dd if=/dev/zero of=/dev/new bs=1M count=128

2.fdisk disk partition management tool (less than 2T)

   Usage: fdisk [option] device names

          -l to check the partitions

         fdisk into the interactive interface parameters when not in use

           h View Help

           n Create a new partition

               e extended partition (at most only one extended partition)

               p primary partition (may have to do more than four)

           d delete a partition

           l View all disk format type

           p View partitioning

           t modify the format of the disk

           q exit without saving

           w Save and Exit

 Example: fdisk / dev / sda

           n

           e

           4

           Enter

           + 4G

           p

           w

3.parted partition tool (greater than 2T)

   Usage: parted [option] device names

  例:Parted  /dev/sdb      

         help view commands

         mklabel gpt to GPT partition type (modified partition format)

         yes

         mkpart primary 0 10 divided primary partition (unit: M)

         ignore

         mkpart primary linux-swap 11 21 divided swap

         ignore

         mkpart logical ext4 22 32 logically divided partitions

         ignore

         p View

         rm delete

Changes 4.partprobe modify the partition table to notify the kernel

    Usage: partprobe device name

        Linux7 or Linux5 and 5 with the following versions partprobe

        Linux6 renamed partx

   例:psrtprobe/partx  /dev/sda

5.mkfs format to create a file system (created after the partition, you need to write formatted data)

   Usage: mkfs [option] device names

             -b specifies the block

             -t Specify the file system

Example: mkfs -t ext4 (equivalent to mkfs.ext4) -b 1M

6.mkswap Formatting swap partition

Usage: mkswap device name

The method of creating the swap partition: usually create a common partition, and then use the swap partition mkswap format formatted

例:mkswap   /dev/sda

7.swapon / swapoff or switching off the swap swap

Usage: swapon / swapoff device name

例: swapon / swapoff / dev / sda

8.mount mount a file system

Usage: mount [option] device names

例:mount  /dev/sr0 /mnt/

9.umount Uninstall

Usage: umount [option] device names

例:umount  /dev/sr0 /mnt

10.df View disk information

Usage: df [option] [Device Name]

          -i 查看 inode

          -T view the file system type

          -h human readable

Example: df -iTh / dev / sda

11.dumpe2fs view information ext file system

Usage: dumpe2fs [option] device names

                -o superblock see super fast information

                -o blocksize block the view information

例:dumpe2fs  /dev/sda

12.fsck (e2fsck) check and repair disk

Note: Do not use a good disk

Usage: fsck [option] device names

            -t: Given the type of file system, or kernel itself has been defined support if the / etc / fstab of this parameter plus you do not need

            -s: a sequentially executed a  fsck  command to check

           -A: on / etc fstab the partition / do all the checks listed

           -C: display a complete check progress

            -d: Print e2 fsck  of debug results

            -p: -A while when conditions while a plurality  fsck  check performed together with

           -R: -A while when conditions are omitted / not checked

           -V: detailed display mode

            -y: pre-set problems when checking all were answered [is]

            -a: If the check is wrong then automatically fix

            -r: If the check is wrong by the user to answer whether repair

Example: fsck -t ext4 / dev / sda

Guess you like

Origin www.cnblogs.com/shandong123/p/11517028.html