How CentOS mounts a hard drive

CentOS mount hard disk

  1. View currently unmounted hard disks

    # fdisk -l

  2. Create hard disk partitions

    # fdisk /dev/sdb

    
    根据提示,依次输入"n","p" "1",两次回车,"wq",分区就开始了,很快就会完成。
    
  3. format the hard drive

    # mkfs.ext4 /dev/sdb

  4. Create a mount directory

    # mkdir /data
  5. mount hard disk

     
    # mount /dev/sdb /data
  6. Set up auto mount at startup

    # vi /etc/fstab
     
    在vi中输入i进入INERT模式,将光标移至文件结尾处并回车,将下面的内容复制/粘贴,然后按Esc键,输入":wq"(不含双引号)保存并退出
    
    /dev/sdb    /data    ext4    defaults    0 0
    
  7. restart the server

    # shutdown -r now

 

 

 

 

 

//------ linux(centos) save and exit vi editing method-----

save command

Press ESC to jump to command mode, then:



:w save the file without exiting vi

:w file Save the changes to file separately without exiting vi

:w! Force save, do not launch vi

:wq save the file and exit vi

:wq! Force save the file and exit vi

q: quit vi without saving the file

:q! Force quit vi without saving the file

:e! Abandon all changes and start editing from the last time the file was saved

Guess you like

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