Linux新加磁盘挂载和重启自动挂载
提示两点:
*新加的硬盘需要重启服务器fdisk -l才能看到
*下面操作要用root账户
大概是这样的,查看-分区-格式化-挂载-重启自动挂载
1、加硬盘后重启服务器查看
[root@test199 ~]# fdisk -l
Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd039
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 536 4096000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 536 10444 79584256 83 Linux
2、分区
fdisk可以用m命令来看fdisk命令的内部命令;
a:命令指定启动分区;
d:命令删除一个存在的分区;
l:命令显示分区ID号的列表;
m:查看fdisk命令帮助;
n:命令创建一个新分区;
p:命令显示分区列表;
t:命令修改分区的类型ID号;
w:命令是将对分区表的修改存盘让它发生作用。
[root@test199 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x515ae162.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended //输入e为创建扩展分区
p primary partition (1-4) //输入p为创建逻辑分区
p
Partition number (1-4): 1 //在这里输入l,就进入划分逻辑分区阶段了
First cylinder (1-26108, default 1): //注:这个就是分区的Start 值;这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费;
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): 我这直接回车了全部用上。注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;
Using default value 26108
Command (m for help): w //最后输入w回车保存。
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
保存后查看一下
[root@test199 ~]# fdisk -l
Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x515ae162
Device Boot Start End Blocks Id System
/dev/sdb1 1 26108 209712478+ 83 Linux
Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd039
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 536 4096000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 536 10444 79584256 83 Linux
3、格式化
[root@test199 ~]# mkfs.ext3 /dev/sdb1 //注:将/dev/sdb1格式化为ext3类型,确认好,我上面/dev/sdb1是新加的200GB硬盘,这一步直接回车就可以了,格式化完会自动跳出来
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428119 blocks
2621405 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
4、挂载
--先创建个目录、再挂载到目录上
[root@test199 ~]# mkdir /data
[root@test199 ~]# mount /dev/sdb1 /data
[root@test199 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 75G 21G 51G 29% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 194M 25M 160M 14% /boot
/dev/sdb1 197G 188M 187G 1% /data
5、重启开机自动挂载,要写到fstab里面(就是最后一行了),否则重启后找不到那个新家的硬盘了
[root@test199 ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 16 01:33:57 2013
#
# 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
#
UUID=f87d8e1f-9a62-4cb8-93a8-a4793465eb23 / ext4 defaults 1 1
UUID=cdb27acf-3bbb-4f03-b20c-cfbc9d8450b9 /boot ext4 defaults 1 2
UUID=63399012-86b0-43e7-8cee-a0ace153dd7e swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sdb1 /data ext3 defaults 0 0
至此OK!
Linux新加磁盘挂载和重启自动挂载的更多相关文章
- Linux新加磁盘并挂载到目录
步骤:1.分区 ----> 2.格式化 ----> 3.挂载 一.查看当前情况 1. 2. 二.磁盘分区 fdisk /dev/sdb 1.输入n,表示添加一个新的分区 2. e ex ...
- CentOS7 初始化硬盘分区、挂载、重启自动挂载
挂载硬盘设备到本地有一下步骤: 1.通过fdisk -l命令,查看硬盘信息 可以看到有两块磁盘/dev/vda和/dev/vdb vda是系统盘,vdb使我们新增的数据盘,在上图中其实已经挂载完成(设 ...
- 【Linux命令】磁盘分区,格式化,挂载命令,创建交换分区(fdisk,mkfs,mount,umount)
友情链接 磁盘分区,格式化,挂载,创建交换分区:https://www.cnblogs.com/HeiDi-BoKe/p/11936998.html RAID工作级别:https://www.cnbl ...
- 给虚拟机添加新硬盘并分区,fdisk查看分区,分区,重新读取分区表信息partprobe,格式化,挂载,查看分区挂载信息,自动挂载文件/etc/fstab,/etc/fstab文件错误导致重启崩溃后的修复
1.虚拟机关机断电 2.添加硬盘 2.开机 3.fdisk -l查看刚才新添加的硬盘 [root@localhost ~]# fdisk -l 磁盘 /dev/sda:21.5 GB, 2147483 ...
- Linux 磁盘分区,文件系统创建、挂载、开机自动挂载和卸载
创建分区 (fdisk): 第一步先在Linux的虚拟机上添加一块硬盘,添加完成后需要重启虚拟机才能够检测识别到新硬盘. 重启系统后可以使用 fdisk -l 命令查看当前所有磁盘分区情况,sdb为我 ...
- Linux阿里云挂载磁盘,并开机自动挂载
Linux下磁盘挂载 公司新订购阿里云ECS,需要挂载当前的磁盘.暂时没有运维,自己动手挂载磁盘. 具体步骤如下: 1.查看是否已经分配 [root@iZ2ze1tefvghtbgkdur3xfZ / ...
- Linux 硬盘挂载(服务器重启自动挂载)
1.先查看目前机器上有几块硬盘,及已挂载磁盘: fdisk -l 能够查看到当前主机上已连接上的磁盘,以及已经分割的磁盘分区.(下面以/dev/vdb磁盘进行分区.挂载为例,挂载点设置为/data) ...
- Centos7 使用LVM进行新加磁盘管理
centos7使用LVM管理一块新的磁盘 注意!文中凡是带#的都是命令标志. 一些重要概念: LV(Logical Volume)- 逻辑卷, VG(Volumne Group)- 卷组, P ...
- vmware新加磁盘fdisk看不到的处理
虚拟机硬盘空间不够了,做了lvm准备加块硬盘扩容,在vcenter控制台加了磁盘,结果操作系统里面fdisk -l看不到新加的硬盘,又不想重启怎么办,一条命令就可以搞定. # 注意中间有空格echo ...
随机推荐
- pycharm linux版快捷方式创建
****************************pycharm_linux安装and快捷方式创建******************1.下载好安装包之后解压: tar -xfz 压缩包名 ...
- 微信小程序函数调用监控
微信小程序之无埋点函数调用监控 有时候,面对一个bug,左思右想就是无法理解为什么. 我就有过这样的经历,耗时整个一个晚上,后来还是放弃了.不得不在所有可能的点都加上日志,部署等待再次报错,真的很让人 ...
- 2018-05-17-OAA-一种mermaid脚本驱动的软件项目模块图形化表述思路
layout: post title: 2018-05-17-OAA-一种mermaid脚本驱动的软件项目模块图形化表述思路 key: 20180517 tags: OAA flow chart se ...
- spring-security doc logout
18.5.3 Logging Out Adding CSRF will update the LogoutFilter to only use HTTP POST. This ensures that ...
- thinter中lable标签控件(二)
lable控件 对于tkinter来说,学起来很简单,只要设置好相应的参数即可出结果,所以不用刻意去记住这些参数.学习一遍后理解每个参数的作用是什么即可. 当下次用到的时候来笔记上看一下就行. 内容很 ...
- 使用jekyll和Github搭建个人博客
一.使用jekyll和Github三步搭建个人博客 在 Github 上建一个库,库的名字是xxx.github.com,其中的xxx是你的github的账号名(图中标注的不要勾选) 注:如果没有Gi ...
- bzoj 1592 dp
就是dp啊 f[i][j]表示到第i位,最后一位高度是j的最小花费 转移::f[i][j]=minn(f[i-1][k])+abs(a[i]-num[j]);(k<=j) #include< ...
- UOJ_274_[清华集训2016]温暖会指引我们前行_LCT
UOJ_274_[清华集训2016]温暖会指引我们前行_LCT 任务描述:http://uoj.ac/problem/274 本题中的字典序不同在于空串的字典序最大. 并且题中要求排序后字典序最大. ...
- BZOJ_4016_[FJOI2014]最短路径树问题_最短路+点分治
BZOJ_4016_[FJOI2014]最短路径树问题_最短路+点分治 Description 给一个包含n个点,m条边的无向连通图.从顶点1出发,往其余所有点分别走一次并返回. 往某一个点走时,选择 ...
- 二逼平衡树 Tyvj 1730 BZOJ3196 Loj#106
树状数组+主席树,模板题,不多说... #include <cstdio> #include <algorithm> #include <cmath> #inclu ...