oracle通过备份到通过iscsi连接挂载的NAS盘上。因为备份数据大了,经常出现空间满,于是扩展了nas盘空间,同时也就需要在linux系统中扩展分区空间,因为不是采用LVM,所以扩容麻烦多了。
1、查看磁盘文件格式
suse12sp3:~ # df -T
/dev/sdc1 ext4 /u01/nasbackup
原来的格式是ext4的,后面可以使用resize2fs
2.umount
直接umount,肯定是会遇到Device or resource busy 。
suse12sp3:~ # fuser -m -v /u01/nasbackup
USER PID ACCESS COMMAND
/u01/nasbackup: root kernel mount /u01
(unknown) 3024 f..e. tnslsnr
oracle 83163 F.ce. ora_pmon_ep
oracle 83165 F.ce. ora_clmn_ep
..........
好多oracle用户的用这个,虽然可以用fuser -m -v -i -k /u01/nasbackup 关掉这些,但担心关掉这些会有不良影响,于是强制umount.
umount -l /u01/nasbackup
3.磁盘删除分区重建
使用fdisk命令重新调整磁盘分区大小,因为就可以分区,所有就采用默认的,起点一样,都是2048。
suse12sp3:~ # fdisk /dev/sdb
Welcome to fdisk (util-linux 2.29.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: 1.5 TiB, 1610612736000 bytes, 3145728000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 2048 bytes / 2048 bytes
Disklabel type: dos
Disk identifier: 0x151dcec9
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2097151999 2097149952 1000G 83 Linux
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-3145727999, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-3145727999, default 3145727999):
Created a new partition 1 of type 'Linux' and of size 1.5 TiB.
Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N
Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
因为不能直接重启服务器,所有使用partx:
suse12sp3:~ # partx -a /dev/sdb1
partx: /dev/sdb: error adding partition 1
suse12sp3:~ # partx -l /dev/sdb
# 1: 2048-3145727999 (3145725952 sectors, 1610611 MB)
看样子是已经扩成功了。
挂载后查看一下
suse12sp3:~ # mount /dev/sdb1 /u01/nasbackup
suse12sp3:~ # df -h
/dev/sdb1 985G /u01/nasbackup
分区大小并没有变。
4、resize2fs错误
suse12sp3:~ # resize2fs /dev/sdb1
resize2fs 1.42.11 (09-Jul-2014)
resize2fs: Device or resource busy while trying to open /dev/sdb1
Couldn't find valid filesystem superblock.
suse12sp3:~# fuser -m -v /u01/nasbackup 仍然可以看到进程和用户,不能马上重启服务器,那就换个方案:卸载磁盘。
5、断开iscsi重新连接
yast2 断开iscsi连接,然后重新连接,这样就变成了新磁盘:Disk /dev/sdc
6.完成resize2fs
suse12sp3:~ # resize2fs /dev/sdc1
resize2fs 1.42.11 (09-Jul-2014)
Please run 'e2fsck -f /dev/sdc1' first.
suse12sp3:~ # e2fsck -f /dev/sdc1
e2fsck 1.42.11 (09-Jul-2014)
/dev/sdc1: recovering journal
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
Free blocks count wrong (155908360, counted=113552337).
Fix
Free inodes count wrong (65535836, counted=65535775).
Fix
/dev/sdc1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sdc1: 225/65536000 files (6.2% non-contiguous), 148591407/262143744 blocks
suse12sp3:~ # resize2fs /dev/sdc1
resize2fs 1.42.11 (09-Jul-2014)
Resizing the filesystem on /dev/sdc1 to 393215744 (4k) blocks.
The filesystem on /dev/sdc1 is now 393215744 blocks long.
7.mount
suse12sp3:~ # mount /dev/sdc1 /u01/nasbackup
suse12sp3:~ # df -h
/dev/sdc1 1.5T 552G 851G 40% /u01/nasbackup
文件也在,扩容成功。