Linux添加新盘扩容空间
添加磁盘扩容操作:
1、添加物理磁盘到服务器重启服务器,#fdisk -l查看识别磁盘(以/dev/sdb为例)
[ ~]# 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: 0x0006a7c5
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 287 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 287 5222 39640064 83 Linux
disk /dev/sdb: 21.5 gb, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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
2、添加分区
[ ~]# fdisk /dev/sdb
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‘) 1116.www.qixoo.qixoo.com 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)
#用"n"新建分区选择"p"主分区,在这里可以新建三个主分区剩下的可以建成扩展分区 选择“e”扩展分区
Command (m for help): n
Command action
e extended (扩展分区)
p primary partition (1-4) (主分区)
1
Invalid partition number for type `1‘
Command action
e extended
p primary partition (1-4)
p (p为新建主分区)
Partition number (1-4): 1 (主分区号)
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +2G (给主分区分配2G空间)
Command (m for help): p (打印出配置的分区信息)
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xbf76d5e8
Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux (已经分配好的分区)
一般是先建三个主分区再有需求在建剩下空间的扩展分区
新建三个主分区和两个扩展分区并且保存退出
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xbf76d5e8
Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb2 263 524 2104515 83 Linux
/dev/sdb3 525 786 2104515 83 Linux
/dev/sdb4 787 2610 14651280 5 Extended
/dev/sdb5 787 918 1060258+ 83 Linux
/dev/sdb6 919 1050 1060258+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3、使分区生效
[ ~]# partprobe (强制让内核重新找一次分区表)
4、查看新建分区
[ ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xbf76d5e8
Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb2 263 524 2104515 83 Linux
/dev/sdb3 525 786 2104515 83 Linux
/dev/sdb4 787 2610 14651280 5 Extended
/dev/sdb5 787 918 1060258+ 83 Linux
/dev/sdb6 919 1050 1060258+ 83 Linux
5、格式化分区
[ ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131648 inodes, 526120 blocks
26306 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[ ~]# mkfs.ext3 /dev/sdb2
[ ~]# mkfs.ext3 /dev/sdb3
[ ~]# mkfs.ext3 /dev/sdb5
[ ~]# mkfs.ext3 /dev/sdb6 (剩下的分区都格式化)
6、新建挂载目录并且挂载到系统上
[ ~]# mkdir -p /sdb/sdb1
[ ~]# mkdir -p /sdb/sdb2
[ ~]# mkdir -p /sdb/sdb3
[ ~]# mkdir -p /sdb/sdb5
[ ~]# mkdir -p /sdb/sdb6
[ ~]# ls /sdb
sdb1 sdb2 sdb3 sdb5 sdb6
[ ~]# mount /dev/sdb1 /sdb/sdb1
[ ~]# mount /dev/sdb2 /sdb/sdb2
[ ~]# mount /dev/sdb3 /sdb/sdb3
[ ~]# mount /dev/sdb5 /sdb/sdb5
[ ~]# mount /dev/sdb6 /sdb/sdb6
7、修改配置文件设置开机自动挂载
[ ~]# vi /etc/fstab
# /etc/fstab
# Created by anaconda on Fri Oct 14 22:27:19 2016
#
# 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=bd82cad1-2b0a-4984-9846-06e690b1fdad / ext3 defaults 1 1
UUID=6d8f8e24-7849-4ad9-af35-7e8fb71eb7ec /boot ext3 defaults 1 2
UUID=dc268ee4-ba91-471f-9acf-94d0a2658083 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 /sdb/sdb1 ext3 defaults 0 0 (新添加挂载选项)
/dev/sdb2 /sdb/sdb2 ext3 defaults 0 0 (defaults都是00)
/dev/sdb3 /sdb/sdb3 ext3 defaults 0 0
/dev/sdb5 /sdb/sdb5 ext3 defaults 0 0
/dev/sdb6 /sdb/sdb6 ext3 defaults 0 0
8、重启服务器生效,并查看分区结果
[ ~]# reboot
[ ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 ext3 38G 7.7G 28G 22% /
tmpfs tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 ext3 194M 30M 155M 17% /boot
/dev/sdb1 ext3 2.0G 68M 1.9G 4% /sdb/sdb1
/dev/sdb2 ext3 2.0G 68M 1.9G 4% /sdb/sdb2
/dev/sdb3 ext3 2.0G 68M 1.9G 4% /sdb/sdb3
/dev/sdb5 ext3 1020M 34M 935M 4% /sdb/sdb5
/dev/sdb6 ext3 1020M 34M 935M 4% /sdb/sdb6
扩容成功。
备注:1、这是在虚拟机上自己实验操作的,所以一块盘的空间20G在真正的工作环境中扩充的盘都是几百G甚至好几个T的;
2、Linux上还有一个伸缩性更好的为服务器扩容的方法即LVM,更灵活操作也很简单。
Linux添加新盘扩容空间的更多相关文章
- linux添加新LUN,无需重启
linux添加新LUN,无需重启 在给存储增加新的Lun时,在linux下一般是: A.重启操作系统B.重启HBA卡驱动 1. kudzu添加完新硬盘后,运行命令kudzu重新扫描新的硬件设备,类似a ...
- Linux添加新硬盘自动挂载硬盘
Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204 ...
- 给Linux添加新用户,新建用户,新建帐号
给Linux添加新用户,新建用户,新建帐号 添加用户组 sudo groupadd groupname 添加用户 sudo useradd username -m -s /sbin/nologin - ...
- linux添加新硬盘不需要重启识盘,及查看uuid
添加新物理硬盘 用ssh工具连接到服务器,执行:fdisk -l 查看磁盘,并没有新加的硬盘 fdisk -l查看硬盘及分区状态 查看主机总线号,命令:ls /sys/class/scsi_ ...
- linux 添加新硬盘的方法
在服务器上把硬盘接好,启动linux,以root登陆. 比如我新加一块SCSI硬盘,需要将其分成三个区: #fdisk /dev/sdb 进入fdisk模式: Command (m for help) ...
- Virtualbox中Linux添加新磁盘并创建分区
原文:https://www.linuxidc.com/Linux/2017-01/139616.htm ----------------------------------------------- ...
- Linux 添加新用户账号并赋予root权限
除了root用户之外,通常需要为每个管理创建各自的用户账号,方便每个管理员登录使用, 步骤如下: 1. 添加新用户账号 useradd mary.lee 2. 为新用户账号设置密码 passwd ...
- linux添加新硬盘
1.添加新磁盘 2.fdisk -l查看磁盘被识别的名称 3.如果输入fdisk -l命令没有找到新的磁盘,按下面步骤操作 1)进入到cd /sys/class/scsi_host/ 2)echo & ...
- LINUX添加新的用户账号并赋予root权限
一:添加新的用户账号使用 useradd 命令 语法: useradd 选项 用户名 示例: # 添加用户,设定登录目录:useradd -d /home/admin -m a ...
随机推荐
- 30行代码实现Javascript中的MVC
从09年左右开始,MVC逐渐在前端领域大放异彩,并终于在刚刚过去的2015年随着React Native的推出而迎来大爆发:AngularJS.EmberJS.Backbone.ReactJS.Rio ...
- sql server 字符串函数str()
语法: STR(nExpres[,nLength[,nDecimalPlaces]]) 参数: nExpression------STR要计算的数值表达式. nLength------------ST ...
- codevs 4543 treap 模板
type rec=record lc,rc,v,rnd,size,w,fa:longint; end; var n,root,tot,ans,opt,x,i,po:longint; tr:array[ ...
- ERROR: “System.Web.Mvc.Controller.File(string, string, string)”是一个“方法”
ERROR: “System.Web.Mvc.Controller.File(string, string, string)”是一个“方法”,这在给定的上下文中无效 这是一个与Controller.F ...
- 一个奇妙的java坑:Long 类型的比较
Long userId=127L; Long authorId=127L; System.out.println(userId==authorId);//true userId=128L; autho ...
- GDB的使用
#list #break <行号|函数名|条件表达式> #delete #run #continue #finish #quit #next #step #print #watch l ...
- 【BZOJ 1492】【NOI 2007】货币兑换Cash
这是道CDQ分治的例题: $O(n^2)$的DP: f [1]←S* Rate[1] / (A[1] * Rate[1] + B[1]) Ans←SFor i ← 2 to n For j ←1 to ...
- java和python细节总结和java中string 的+操作
//JAVA中对arrayList的初始化,能够分配空间,不能之间让一个ArrayList赋值给另外一个ArrayList,这样是引用赋值,当一个改变时候,另外一个也改变 List<String ...
- DOCTYPE是什么鬼?文档模式又是什么鬼?
!DOCTYPE !DOCTYPE是什么: 在所有 HTML 文档中规定 DOCTYPE 是非常重要的,这样浏览器就能了解预期的文档类型, 告诉浏览器要通过哪一种规范(文档类型定义 DTD)解析文档( ...
- spoj687 后缀数组重复次数最多的连续重复子串
REPEATS - Repeats no tags A string s is called an (k,l)-repeat if s is obtained by concatenating k& ...