码迷,mamicode.com
首页 > 系统相关 > 详细

Linux基础操作:磁盘加挂、关闭防火墙、开机开启网络

时间:2020-07-16 12:11:53      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:mon   value   ide   开机   pre   byte   tor   自动   store   

1. 磁盘加挂

//查看磁盘挂载路径和使用情况
[root@localhost ~]# df -l 
Filesystem              1K-blocks    Used Available Use% Mounted on
/dev/mapper/centos-root   9754624 6240060   3514564  64% /
devtmpfs                   917580       0    917580   0% /dev
tmpfs                      933512       4    933508   1% /dev/shm
tmpfs                      933512    9156    924356   1% /run
tmpfs                      933512       0    933512   0% /sys/fs/cgroup
/dev/sda1                 2919424  182412   2737012   7% /boot
/dev/mapper/centos-home   4872192 4872172        20 100% /home
tmpfs                      186704       4    186700   1% /run/user/42
tmpfs                      186704      32    186672   1% /run/user/0
/dev/sr0                  4414592 4414592         0 100% /run/media/root/CentOS 7 x86_64

//查看可用磁盘
[root@localhost ~]# fdisk -l 

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0000aa5b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     5861375     2929664   83  Linux
/dev/sda2         5861376    39096319    16617472   8e  Linux LVM

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

//按步骤加挂磁盘
[root@localhost ~]# fdisk /dev/sdb  
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xe9cd8adf.

Command (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
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

// 格式化磁盘
[root@localhost ~]# mkfs.ext4 /dev/sdb1  
mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242624 blocks
262131 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2153775104
160 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 tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

//新建文件夹
[root@localhost ~]# mkdir /data 

//将磁盘加挂到文件夹
[root@localhost mount /dev/sdb1 /data 
[root@localhost ~]# df -l #检验磁盘加挂情况
Filesystem              1K-blocks    Used Available Use% Mounted on
/dev/mapper/centos-root   9754624 4467432   5287192  46% /
devtmpfs                   917580       0    917580   0% /dev
tmpfs                      933512       0    933512   0% /dev/shm
tmpfs                      933512    9132    924380   1% /run
tmpfs                      933512       0    933512   0% /sys/fs/cgroup
/dev/sda1                 2919424  182412   2737012   7% /boot
/dev/mapper/centos-home   4872192   33188   4839004   1% /home
tmpfs                      186704      12    186692   1% /run/user/42
tmpfs                      186704       0    186704   0% /run/user/0
/dev/sdb1                20510288   45080  19400300   1% /data

//编辑fstab,实现开机自动加挂磁盘
[root@localhost ~]# vi /etc/fstab 
[root@localhost ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Mar  2 08:54:36 2020
#
# Accessible filesystems, by reference, are maintained under /dev/disk
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=d8ab5ea1-5014-4597-86c3-b98fc2f38c4d /boot                   xfs     defaults        0 0
/dev/mapper/centos-home /home                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0

/dev/sdb1 /data ext4 defaults 0 0  //增加这一行

 

2.关闭防火墙和selinux

[root@localhost ~]# systemctl status firewalld //查看当前防火墙状态。 
[root@localhost ~]# systemctl stop firewalld //关闭当前防火墙。 
[root@localhost ~]# systemctl disable firewalld //开机防火墙不启动。


[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# setenforce 0  //关闭selinux
[root@localhost ~]# vi /etc/sysconfig/selinux //编辑实现开机不启动selinux

.....

SELINUX=disabled  

3. 开机自动开启网络

[root@localhost ~]# cd /etc/sysconfig/network-scripts
[root@localhost network-scripts]# ll  //找对应网卡
total 244
-rw-r--r--. 1 root root   279 May 31 19:54 ifcfg-ens32
-rw-r--r--. 1 root root   254 May  3  2017 ifcfg-lo
lrwxrwxrwx. 1 root root    24 May 31 19:46 ifdown -> ../../../usr/sbin/ifdown
-rwxr-xr-x. 1 root root   654 May  3  2017 ifdown-bnep
-rwxr-xr-x. 1 root root  6571 May  3  2017 ifdown-eth
-rwxr-xr-x. 1 root root  6190 Aug  4  2017 ifdown-ib
-rwxr-xr-x. 1 root root   781 May  3  2017 ifdown-ippp
-rwxr-xr-x. 1 root root  4540 May  3  2017 ifdown-ipv6
lrwxrwxrwx. 1 root root    11 May 31 19:46 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root  1768 May  3  2017 ifdown-post
-rwxr-xr-x. 1 root root  1068 May  3  2017 ifdown-ppp
-rwxr-xr-x. 1 root root   870 May  3  2017 ifdown-routes
-rwxr-xr-x. 1 root root  1456 May  3  2017 ifdown-sit
-rwxr-xr-x. 1 root root  1621 Aug  3  2017 ifdown-Team
-rwxr-xr-x. 1 root root  1556 Apr 15  2016 ifdown-TeamPort
-rwxr-xr-x. 1 root root  1462 May  3  2017 ifdown-tunnel
lrwxrwxrwx. 1 root root    22 May 31 19:46 ifup -> ../../../usr/sbin/ifup
-rwxr-xr-x. 1 root root 12312 May  3  2017 ifup-aliases
-rwxr-xr-x. 1 root root   910 May  3  2017 ifup-bnep
-rwxr-xr-x. 1 root root 12680 May  3  2017 ifup-eth
-rwxr-xr-x. 1 root root 10114 Aug  4  2017 ifup-ib
-rwxr-xr-x. 1 root root 12075 May  3  2017 ifup-ippp
-rwxr-xr-x. 1 root root 11893 May  3  2017 ifup-ipv6
lrwxrwxrwx. 1 root root     9 May 31 19:46 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root   650 May  3  2017 ifup-plip
-rwxr-xr-x. 1 root root  1064 May  3  2017 ifup-plusb
-rwxr-xr-x. 1 root root  3433 May  3  2017 ifup-post
-rwxr-xr-x. 1 root root  4154 May  3  2017 ifup-ppp
-rwxr-xr-x. 1 root root  2001 May  3  2017 ifup-routes
-rwxr-xr-x. 1 root root  3303 May  3  2017 ifup-sit
-rwxr-xr-x. 1 root root  1755 Apr 15  2016 ifup-Team
-rwxr-xr-x. 1 root root  1876 Apr 15  2016 ifup-TeamPort
-rwxr-xr-x. 1 root root  2711 May  3  2017 ifup-tunnel
-rwxr-xr-x. 1 root root  1836 May  3  2017 ifup-wireless
-rwxr-xr-x. 1 root root  5419 May  3  2017 init.ipv6-global
-rw-r--r--. 1 root root 18919 May  3  2017 network-functions
-rw-r--r--. 1 root root 31027 May  3  2017 network-functions-ipv6
[root@localhost network-scripts]# vi ifcfg-ens32
[root@localhost network-scripts]# cat ifcfg-ens32
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens32
UUID=968f77f7-3815-492d-8a81-04ca2b4b0047
DEVICE=ens32
ONBOOT=yes  // 改成yes
 

 

Linux基础操作:磁盘加挂、关闭防火墙、开机开启网络

标签:mon   value   ide   开机   pre   byte   tor   自动   store   

原文地址:https://www.cnblogs.com/hawking8su/p/13312506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!