1长踊、增加硬盤
2可以看到磁盤并沒(méi)有馬上認(rèn)出來(lái)
3功舀、由于不知道新增硬盤掛載的位置,可以先查看現(xiàn)有硬盤掛載的適配器身弊。
4辟汰、發(fā)現(xiàn)正在磁盤掛載到host0,可以嘗試使用下邊命令阱佛,重新掃描host0信息
echo "- - -" > /sys/class/scsi_host/host0/scan
5帖汞、再次有fdisk -l可以看到新的磁盤已經(jīng)掃出來(lái)了
以下開(kāi)始創(chuàng)建分區(qū)
格式化分區(qū)
掛載分區(qū)
擴(kuò)容:(需要關(guān)機(jī))
卸載分區(qū)
umount /dev/sdb1
刪除并重新建分區(qū)
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdb: 16.1 GB, 16106127360 bytes, 31457280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xead24600
Device Boot Start End Blocks Id System
/dev/sdb1 2048 20971519 10484736 83 Linux
Command (m for help): d
Selected partition 1
Partition 1 is deleted
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-31457279, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279):
Using default value 31457279
Partition 1 of type Linux and of size 15 GiB is set
Command (m for help): p
Disk /dev/sdb: 16.1 GB, 16106127360 bytes, 31457280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xead24600
Device Boot Start End Blocks Id System
/dev/sdb1 2048 31457279 15727616 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
檢查并變更文件系統(tǒng)大小
[root@localhost ~]# e2fsck -f /dev/sdb1
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 13/655360 files (0.0% non-contiguous), 79698/2621184 blocks
[root@localhost ~]# resize2fs /dev/sdb1
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/sdb1 to 3931904 (4k) blocks.
The filesystem on /dev/sdb1 is now 3931904 blocks long.
重新掛載
mount /dev/sdb1 /mydata
查看數(shù)據(jù)是否存在(可保留原數(shù)據(jù))
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 1.1G 16G 7% /
devtmpfs 476M 0 476M 0% /dev
tmpfs 488M 0 488M 0% /dev/shm
tmpfs 488M 7.7M 480M 2% /run
tmpfs 488M 0 488M 0% /sys/fs/cgroup
/dev/sda1 1014M 130M 885M 13% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/sdb1 15G 26M 14G 1% /mydata
[root@localhost ~]# cd /mydata/
[root@localhost mydata]# ll
total 24
drwx------. 2 root root 16384 Jun 11 04:19 lost+found
drwxr-xr-x. 2 root root 4096 Jun 11 04:26 test
-rw-r--r--. 1 root root 4 Jun 11 04:26 test.txt