博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux中磁盘分区、格式化、挂载等管理
阅读量:6674 次
发布时间:2019-06-25

本文共 4595 字,大约阅读时间需要 15 分钟。

 

1. 添加磁盘,查看磁盘状况

    

[root@db1 /]# fdisk -lDisk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *         151        1305     9277537+  83  Linux/dev/sda2               1         150     1204843+  82  linux swapPartition table entries are not in disk orderDisk /dev/sdb: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes   Device Boot      Start         End      Blocks   Id  System

从结果看出,多了一个/dev/sdb的盘

 

2. fdisk /dev/sdb 进行分区

 

[root@db1 /]# fdisk /dev/sdbCommand (m for help): nCommand action   e   extended   p   primary partition (1-4)pPartition number (1-4): 1First cylinder (1-652, default 1):Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-652, default 652):Using default value 652 Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table.Syncing disks.

 

 

再次查看分区情况,多出来一个/dev/sdb1 的区,这个1是我们在前面指定的,如果我们指定2,就变成 sdb2了。

[root@db1 /]# fdisk -l Disk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *         151        1305     9277537+  83  Linux/dev/sda2               1         150     1204843+  82  Linux swapPartition table entries are not in disk order Disk /dev/sdb: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes    Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1         652     5237158+  83  Linux[root@db1 /]#

 

 

 

如果创建完之后,/proc/partitions 查看不到对应的分区,使用parprobe 命令刷新一下就可以了:

[root@web1 ~]# cat /proc/partitions major minor  #blocks  name   8     0  175825944 sda   8     1    1020096 sda1   8     2   30716280 sda2   8     3    8193150 sda3[root@web1 ~]# partprobe /dev/sda[root@web1 ~]# cat /proc/partitions major minor  #blocks  name   8     0  175825944 sda   8     1    1020096 sda1   8     2   30716280 sda2   8     3    8193150 sda3   8     4  135893835 sda4[root@web1 ~]#

 

 

 

3. 格式化 /dev/sdb1 分区

 

[root@db1 /]# mkfs -t ext3 /dev/sdb1mke2fs 1.35 (28-Feb-2004)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)655360 inodes, 1309289 blocks65464 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=134217728040 block groups32768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock backups stored on blocks:        32768, 98304, 163840, 229376, 294912, 819200, 884736 Writing inode tables: doneCreating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 30 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

 

4. 创建目录 并将 /dev/sdb1 挂在到该目录下

 

[root@db1 /]# lsbackup  dev   initrd      media  opt   sbin     sys       usrbin     etc   lib         misc   proc  selinux  tftpboot  varboot    home  lost+found  mnt    root  srv      tmp[root@db1 /]# mkdir /u01[root@db1 /]# lsbackup  dev   initrd      media  opt   sbin     sys       u01bin     etc   lib         misc   proc  selinux  tftpboot  usrboot    home  lost+found  mnt    root  srv      tmp       var[root@db1 /]# mount /dev/sdb1 /u01

 

5. 验证挂载是否成功

[root@db1 /]# df -kFilesystem           1K-blocks      Used Available Use% Mounted on/dev/sda1              9131772   7066884   1601012  82% /none                    454256         0    454256   0% /dev/shm/dev/sdb1              5154852     43040   4849956   1% /backup

 

 

6. 设置开机自动挂载

 

[root@db1 /]# vi /etc/fstab# This file is edited by fstab-sync - see 'man fstab-sync' for detailsLABEL=/                 /                       ext3    defaults        1 1none                    /dev/pts                devpts  gid=5,mode=620  0 0none                    /dev/shm                tmpfs   defaults        0 0none                    /proc                   proc    defaults        0 0none                    /sys                    sysfs   defaults        0 0LABEL=SWAP-sda2         swap                    swap    defaults        0 0/dev/sdb1               /u01                 ext3    defaults        0 0/dev/hdc                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0/dev/fd0                /media/floppy           auto    pamconsole,exec,noauto,managed 0 0

 

 本文摘自:http://blog.csdn.net/tianlesoftware/article/details/5642883,感谢原作者分享。

你可能感兴趣的文章
如何配置JDK环境变量
查看>>
四则运算二项目计划总结
查看>>
CSS3实现Animation动画
查看>>
WORD神操作!第一个技巧你就傻眼了!
查看>>
js中数组连接concat()
查看>>
HDU 2159 FATE
查看>>
docker-compose 意见搭建Samba文件共享服务
查看>>
Keepalived+Nginx搭建主从高可用并带nginx检测
查看>>
VMware 中如何打开U盘弹出U盘或者移动硬盘的(两种方法)
查看>>
8.10模拟赛
查看>>
走进c++0x,体验不一样的c++
查看>>
tomcat启动报错
查看>>
【转】Centos yum 换源
查看>>
标准字符串函数及 字符串类--数据结构
查看>>
Hibernate内测总结
查看>>
matplotlib.pyplot如何绘制多张子图
查看>>
excel 常用设置
查看>>
[自制操作系统] BMP格式文件读取&图形界面系统框架/应用接口设计
查看>>
js !!条件判断或运算的作用
查看>>
记一次安装Nginx+php-fpm安装后无法解析.php文件,状态码200,但显示空白页
查看>>