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,更灵活操作也很简单。

时间: 2024-08-12 02:29:10

Linux添加新盘扩容空间的相关文章

Linux 添加新分区

Linux系统由于数据累计增长.前期存储规划不合理等诸多因素,出现存储不够用的情况时,此时就需要扩展逻辑分区或添加新的逻辑分区.下面介绍一下通过使用fdsik添加新的逻辑分区. 首先使用df命令检查文件系统的磁盘空间占用情况 [[email protected]~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-sda3 30G 2.4G 26G 9% / /dev/sda1 99M 23M 71

Linux添加新硬盘自动挂载硬盘

Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 2.格式化硬盘 #mkfs -t ext4 /dev/sdb 3.挂载硬盘 #mount 硬盘地址 要挂载的地址 #mount /dev/sdb /media/imgs 4.实现系统重启后自动挂载该分区 #vi /etc/fstab 在最后一行添加 /dev/sdb /me

linux添加新LUN,无需重启

linux添加新LUN,无需重启 在给存储增加新的Lun时,在linux下一般是: A.重启操作系统B.重启HBA卡驱动 1. kudzu添加完新硬盘后,运行命令kudzu重新扫描新的硬件设备,类似aix的cfgmgr eg:[[email protected]]#  kudzu -p | more-class: OTHERbus: PCIdetached: 0driver: shpchpdesc: "VMware PCI Express Root Port"vendorId: 15a

linux添加新硬盘不需要重启识盘

 添加新物理硬盘 用ssh工具连接到服务器,执行:fdisk -l 查看磁盘,并没有新加的硬盘 fdisk -l查看硬盘及分区状态   查看主机总线号,命令:ls /sys/class/scsi_host/   重新扫描SCSI总线,以添加新设备: echo "- - -">/sys/class/scsi_host/host0/scan echo "- - -">/sys/class/scsi_host/host1/scan echo "- -

linux 添加新硬盘的方法

在服务器上把硬盘接好,启动linux,以root登陆. 比如我新加一块SCSI硬盘,需要将其分成三个区: #fdisk /dev/sdb 进入fdisk模式: Command (m for help):p  //查看新硬盘的分区 Command (m for help):n  //创建新分区 可以用m命令来看fdisk命令的内部命令:n命令创建一个新分区:d命令删除一个存在的分区:p命令显示分区列表:t命令修改分区的类型ID号:l命令显示分区ID号的列表:a命令指定启动分区:w命令是将对分区表的

Virtualbox中Linux添加新磁盘并创建分区

原文:https://www.linuxidc.com/Linux/2017-01/139616.htm ------------------------------------------------------------------ 引言:我们常常在使用系统的时候突然发现,哎呦~~~我们的磁盘空间不够用啦!我遇到常见的就是数据库数据暴增,预留的空间没有啦,只好新添加磁盘,在VB虚拟机上就可以实现,往往苦于没有图文并茂的好资料,下面我来为大家简单快捷的实操示范一下,做一名"实操族"

Linux 添加新用户账号并赋予root权限

除了root用户之外,通常需要为每个管理创建各自的用户账号,方便每个管理员登录使用, 步骤如下: 1.  添加新用户账号 useradd  mary.lee 2.  为新用户账号设置密码 passwd [email protected] 3. 为新用户账号赋予root权限 usermod -a -G root mary.lee 原文地址:https://www.cnblogs.com/yuzg/p/10774147.html

Linux 添加新磁盘,在线扩充空间

CentOS 7开发环境中的home 目录空间满了,需要增加空间 到虚拟机上执行"ls /sys/class/scsi_host",然后重新扫描SCSI总线来添加设备.如右图.然后执行"fdsik -l"来验证是否添加成功. 2.分区前准备yum -y install parted [[email protected] ~]# partprobe[[email protected] ~]# partprobe /dev/sda3 ps:使用fdisk工具只是将分区信

Linux添加新硬盘,fdisk新建分区

fdisk新建分区: [[email protected] ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/op