Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >linux下挂载新硬盘和分区的步骤 (50天)

linux下挂载新硬盘和分区的步骤 (50天)

作者头像
jeanron100
发布于 2018-03-13 10:39:26
发布于 2018-03-13 10:39:26
4.8K0
举报

今天和大家分享一下在linux下挂载新硬盘的步骤。 演示的环境基于centos [root@localhost etc]# uname -a Linux localhost.localdomain 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux [root@localhost etc]# cat system-release CentOS release 6.2 (Final) [root@localhost etc]# 先挂载了一个3G的硬盘查看磁盘空间的情况 [root@localhost etc]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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: 0x0004daae Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 4998 39832576 83 Linux /dev/sda3 4998 5222 1802240 82 Linux swap / Solaris Disk /dev/sdb: 3221 MB, 3221225472 bytes 255 heads, 63 sectors/track, 391 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 划分磁盘分区,分为4个主分区,最后写入磁盘。 [root@localhost etc]# fdisk /dev/sdb 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): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 4 First cylinder (1-391, default 1): 1 Last cylinder, +cylinders or +size{K,M,G} (1-391, default 391): 100 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (101-391, default 101): 101 Last cylinder, +cylinders or +size{K,M,G} (101-391, default 391): 200 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (201-391, default 201): 201 Last cylinder, +cylinders or +size{K,M,G} (201-391, default 391): 300 Command (m for help): n Command action e extended p primary partition (1-4) p Selected partition 1 First cylinder (301-391, default 301): 301 Last cylinder, +cylinders or +size{K,M,G} (301-391, default 391): 391 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@localhost etc]# fdisk -l 再次查看分区情况, Disk /dev/sdb: 3221 MB, 3221225472 bytes 255 heads, 63 sectors/track, 391 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: 0xe5f51a7b Device Boot Start End Blocks Id System /dev/sdb1 301 391 730957+ 83 Linux /dev/sdb2 101 200 803250 83 Linux /dev/sdb3 201 300 803250 83 Linux /dev/sdb4 1 100 803218+ 83 Linux Partition table entries are not in disk order 我就格式化第一个分区,采用文件系统ext3. [root@localhost etc]# mkfs -t ext3 /dev/sdb1 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 45696 inodes, 182739 blocks 9136 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=188743680 6 block groups 32768 blocks per group, 32768 fragments per group 7616 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 27 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 创建一个临时目录,然后把分区挂载到这个目录下。 [root@localhost /]# mkdir test [root@localhost /]# mount /dev/sdb1 /test 挂载后查看磁盘情况,就可以看到分区就在那了。 [root@localhost /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 38G 32G 4.3G 89% / tmpfs 980M 288K 980M 1% /dev/shm /dev/sda1 291M 32M 244M 12% /boot /dev/sdb1 703M 17M 651M 3% /test 配置开机启动项 vi /etc/fstab LABEL=SWAP-sda2 swap swap defaults 0 0 加入如下 /dev/sdb1 /test ext3 defaults 1 1 ~ 5. 第5列为dump选项,设置是否让备份程序dump备份文件系统,0为忽略,1为备份。 6. 第6列为fsck选项,告诉fsck程序以什么顺序检查文件系统,0为忽略。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2014-04-22,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 杨建荣的学习笔记 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Linux命令(38)——fdisk命令
fdisk命令用于创建和维护磁盘分区表。它采用传统的问答式界面,而非类似DOS fdisk的cfdisk互动式操作界面,因此在使用上较为不便,但功能却丝毫不打折扣。它兼容DOS类型的分区表、BSD或者SUN类型的磁盘列表。
恋喵大鲤鱼
2018/08/03
3.1K0
每天学一个 Linux 命令(78):fdisk
fdisk 命令用于查看磁盘使用情况和磁盘分区,它可用于创建,删除和修改磁盘分区。
民工哥
2021/03/30
1.2K0
将一个新硬盘能够挂载到linux 系统上(开机自动挂载)
sda ├─sda1 ext4 7cc94e03-8b1a-4845-97fb-49a2c39afd8c /boot ├─sda2 ext4 fe1d0eea-50ea-4d44-853b-1c39e5129021 / ├─sda3 ext4 df147f0a-efbd-4370-8e69-471b81a6ee7c /mnt/disk1 ├─sda4 ├─sda5 ext4 ea0d589d-a329-4bfc-a00b-11c00351765a /mnt/disk2 └─sda6 swap f306ece0-a790-41d7-b685-63585b8534e4 [SWAP]
用户4870038
2021/02/05
6K0
Linux系统基础之磁盘介绍
所有有系统都一样,都是一种软件被安装于某个硬件之上,这个硬件无外非是一种存储设备,通常操作系统都是安装磁盘中,所以Linux系统也一样,都是安装在磁盘当中,但是它不同与windows系统的安装,因为Linux都是需要创建文件系统的才可以使用,今天我们变来介绍下最基础的知识——磁盘
民工哥
2020/09/16
1.2K0
Linux系统基础之磁盘介绍
Linux R720挂载M.2固态硬盘
Disk /dev/nvme0n1: 500.1 GB, 500107862016 bytes
用户8664418
2021/07/13
2.8K0
你知道如何在Linux服务器上挂载新硬盘吗?冰河为你揭开这个秘密
#mkfs.ext3 /dev/sdb1 //注:将/dev/sdb1格式化为ext3类型
冰河
2020/10/29
1.8K0
你知道如何在Linux服务器上挂载新硬盘吗?冰河为你揭开这个秘密
linux 将现有分区转换为lvm2分区并扩展放大容量
此次主要进行了/dev/sdb从默认系统转换到lvm系统模式。期间备份恢复数据,不同磁盘下的不同分区创建pv加入同一vg组,放大lv容量,从vg中删除单个pv,通过实验验证lvm2突破了在lvm1版本时pe size大小限制vg大小的限制,自动挂载lv等。 期间经历重启由于fstab文件忘记修改导致无法开机,后进入单用户救援模式修改/etc/fstab后恢复,经过此番折腾更加深入了解了linux的磁盘文件系统模式。 1、查看现有系统信息。 [root@localhost ~]# df 文件系统 1K-块 已用 可用 已用% 挂载点 /dev/sda2 99190032 4077672 89992368 5% / /dev/sdb1 567161764 246748 537640172 1% /opt /dev/sda1 99098 12238 81743 14% /boot tmpfs 8196244 0 8196244 0% /dev/shm [root@localhost ~]# fdisk /dev/sdb The number of cylinders for this disk is set to 72891. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/sdb: 599.5 GB, 599550590976 bytes 255 heads, 63 sectors/track, 72891 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 * 1 72891 585496926 83 Linux 2、备份数据,将原先/opt下的文件复制到新建的mkdir /optbak下,已做备份。 [root@localhost ~]# ll /opt/ 总计 32 drwxr-xr-x 2 root root 4096 01-27 15:20 disk drwx------ 2 root root 16384 01-22 15:40 lost+found drwxr-xr-x 3 root root 4096 01-23 12:54 svn drwxrwxrwx 3 root root 4096 02-02 16:50 svntongbu drwxr-xr-x 5 root root 4096 01-30 14:43 wzcs 执行cp -r /opt /optbak后 [root@localhost ~]# ll /optbak/opt/ 总计 20 drwxr-xr-x 2 root root 4096 02-08 15:48 disk drwx------ 2 root root 4096 02-08 15:48 lost+found drwxr-xr-x 3 root root 4096 02-08 15:48 svn drwxr-xr-x 3 root root 4096 02-08 15:48 svntongbu drwxr-xr-x 5 root root 4096 02-08 15:48 wzcs 3、执行umount /opt 写在文件挂载,这时/opt 目录下的文件已经看不到了,因为它所挂载的硬盘已被从文件系统卸载了。但是/opt目录仍然存在,只是成空文件夹了。 [root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda2 95G 4.0G 86G 5% / /dev/sda1 97M 12M 80M 14% /boot tmpfs 7.9G 0 7.9G 0% /dev/shm 4、现在开始执行将原有磁盘系统转化为lvm,因为服务器原先有两块磁盘sda sdb,sda为系统盘 其中sda3已经设置为了lvm分区,sdb这块磁盘由于我只分了一个区现在我需要把它删了重建。 [root@localhost ~]# fdisk /dev/sdb T
葫芦
2019/05/09
4.7K0
Linux扩容分区操作过程
查看新增磁盘 在服务器上新加一块10G大小的磁盘 [root@centos002 ~]# fdisk -l ..............................................
民工哥
2020/09/16
1.6K0
Linux扩容分区操作过程
mysql 分区 扩充_mysql分区LVM扩容
场景:mysql的数据库目录为/data随着数据量的增加,该分区不够用了,准备添加一块ssd硬盘,扩容该分区!
全栈程序员站长
2022/09/06
3.4K0
Linux 磁盘分区、格式化、目录挂载
实验环境: Citrix虚拟化, RHEL6.4系统环境 本文目的: 熟悉Linux的基本磁盘分区、格式化、目录挂载。
Alfred Zhao
2019/05/24
5.4K0
制作属于自己的Linux系统
自制Linux首先得满足一定的条件,除了物理主机的配置外,我们还需要准备一块干净的磁盘。这里,为了更好更直观地体现实验效果,笔者使用VMWare做实验,并准备了1块名为"LinuxDIY"的虚拟磁盘,磁盘大小为10GB。关于VMware的使用及系统安装,可以参看这篇文章。
用户1456517
2019/03/05
3.5K0
制作属于自己的Linux系统
Linux新手入门:用fdisk命令轻松分区
  fdisk - Partition table manipulator for Linux ,译成中文的意思是磁盘分区表操作工具;本人译的不太好,也没有看中文文档;其实就是分区工具
会长君
2023/04/25
2.2K0
Linux系统磁盘
所有有系统都一样,都是一种软件被安装于某个硬件之上,这个硬件无外非是一种存储设备,通常操作系统都是安装在磁盘中,所以Linux系统也是一样,都是安装在磁盘中,但是它与Windows系统不一样,因为Linux都是需要创建文件系统才可以使用。
用户1173509
2022/05/09
6.3K0
Linux系统磁盘
Linux下使用fdisk扩展分区容量
硬盘空间为20G,使用vSphere Client增加磁盘大小,需要再增加10G空间;
用户5005176
2021/08/08
6.4K0
原 建立共享存储实验记录
共享存储配置     (1).添加一块1G硬盘     (2).为了能不重启虚机的情况下,特作以下操作 [root@node0 host2]# grep mpt /sys/class/scs
王果壳
2018/05/17
1.7K0
使用fdisk命令操作硬盘用法详解
fdisk 操作硬盘的命令格式如下:   [root@localhost beinan]# fdisk 设备   比如我们通过 fdisk -l 得知 /dev/hda 或者 /dev/sda设备;我们如果想再添加或者删除一些分区,可以用   [root@localhost beinan]# fdisk /dev/hda   或   [root@localhost beinan]# fdisk /dev/sda   注 在以后的例子中,我们要以 /dev/sda设备为例,来讲解如何用fdisk 来操作添加、删除分区等动作;   1、fdisk 的说明;   当我们通过 fdisk 设备,进入相应设备的操作时,会发现有如下的提示;以 fdisk /dev/sda 设备为例,以下同;
会长君
2023/04/25
1.5K0
搭建iscsi存储系统
SATA:容量大,500G, 750G, 1T, 2T, 3T, 4T 不支持热插拔,价格低。
胡齐
2019/10/03
4K0
磁盘多路径 存储工程师必学
Mar 10 19:18:28 | /etc/multipath.conf does not exist, blacklisting all devices.
用户8418197
2021/09/11
1.6K0
[Centos7]对硬盘进行分区及自动挂载
本文编写于 205 天前,最后修改于 205 天前,其中某些信息可能已经过时。 1.查看空闲的空间 [root@idc ~]# fdisk -l 2.使用fdisk开始分区 [root@idc ~]# fdisk /dev/sdb Command (m for help): p #查看当前磁盘信息 Disk /dev/sdb: 139.6 GB, 139586437120 bytes, 272629760 sectors Units = sectors of 1 * 512 = 512 bytes S
贰叁壹小窝
2020/07/22
1.2K0
华为S5500T在Redhat6.4上多路径映射问题
存储:华为S5500T    服务器:华为RH5885 V2    操作系统:linux RedHat6.4 64bit 
星哥玩云
2022/07/03
5960
相关推荐
Linux命令(38)——fdisk命令
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档