Centos非LVM磁盘扩展
2021/7/29 7:08:31
本文主要是介绍Centos非LVM磁盘扩展,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 模拟环境搭建
1.1 识别磁盘设备
[16:29:25 root@centos8 ~]#for i in $(ls /sys/class/scsi_host/);do echo "- - -"> /sys/class/scsi_host/$i/scan;done
1.2 建分区
[16:30:05 root@centos8 ~]#fdisk /dev/sdc Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x6a0b14a0. 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-2097151, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151): Created a new partition 1 of type 'Linux' and of size 1023 MiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
1.3 格式化磁盘
[16:30:52 root@centos8 ~]#mkfs.xfs /dev/sdc1 meta-data=/dev/sdc1 isize=512 agcount=4, agsize=65472 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=261888, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=1566, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
1.4 挂载
[16:32:40 root@centos8 ~]#mkdir /data [16:32:44 root@centos8 ~]#mount /dev/sdc1 /data/
1.5 复制模拟数据
[16:33:36 root@centos8 ~]#\cp -a /etc/* /data/ [16:34:26 root@centos8 ~]#\cp /media/BaseOS/Packages/*.rpm /data/
此时磁盘不够了
通过df 命令可以看到/data 100%了.我们需要扩展这个非lvm的分区
[16:35:09 root@centos8 ~]#df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 956M 0 956M 0% /dev tmpfs 976M 0 976M 0% /dev/shm tmpfs 976M 8.8M 967M 1% /run tmpfs 976M 0 976M 0% /sys/fs/cgroup /dev/mapper/cl-root 66G 3.2G 62G 5% / /dev/mapper/cl-home 32G 260M 32G 1% /home /dev/sda1 1014M 180M 835M 18% /boot tmpfs 196M 0 196M 0% /run/user/0 /dev/sdc1 1017M 1017M 132K 100% /data /dev/sr0 9.3G 9.3G 0 100% /media
2 扩展分区
因为是workstation 所以要关下机
[16:35:57 root@centos8 ~]#shutdown -h now
2.1 硬盘扩展
2.2 重新对/dev/sdc分区
[16:39:09 root@centos8 ~]#lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 99G 0 part ├─cl-root 253:0 0 65.2G 0 lvm / ├─cl-swap 253:1 0 2G 0 lvm [SWAP] └─cl-home 253:2 0 31.8G 0 lvm /home sdc 8:16 0 4G 0 disk └─sdc1 8:17 0 1023M 0 part sr0 11:0 1 9.3G 0 rom [16:39:15 root@centos8 ~]#fdisk /dev/sdc Welcome to fdisk (util-linux 2.32.1). 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/sdc: 4 GiB, 4294967296 bytes, 8388608 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 Disklabel type: dos Disk identifier: 0x6a0b14a0 Device Boot Start End Sectors Size Id Type /dev/sdc1 2048 2097151 2095104 1023M 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): First sector (2048-8388607, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-8388607, default 8388607): Created a new partition 1 of type 'Linux' and of size 4 GiB. Partition #1 contains a xfs signature. Do you want to remove the signature? [Y]es/[N]o: y <--------------y就可以了 The signature will be removed by a write command. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
2.3 修复xfs分区
[16:42:14 root@centos8 ~]#xfs_repair /dev/sdc1 Phase 1 - find and verify superblock... bad primary superblock - bad magic number !!! attempting to find secondary superblock... .found candidate secondary superblock... verified secondary superblock... writing modified primary superblock sb realtime bitmap inode 18446744073709551615 (NULLFSINO) inconsistent with calculated value 129 resetting superblock realtime bitmap ino pointer to 129 sb realtime summary inode 18446744073709551615 (NULLFSINO) inconsistent with calculated value 130 resetting superblock realtime summary ino pointer to 130 Phase 2 - using internal log - zero log... - scan filesystem freespace and inode maps... sb_icount 0, counted 2560 sb_ifree 0, counted 122 sb_fdblocks 260298, counted 10075 - found root inode chunk Phase 3 - for each AG... - scan and clear agi unlinked lists... - process known inodes and perform inode discovery... - agno = 0 - agno = 1 - agno = 2 - agno = 3 - process newly discovered inodes... Phase 4 - check for duplicate blocks... - setting up duplicate extent list... - check for inodes claiming duplicate blocks... - agno = 0 - agno = 1 - agno = 2 - agno = 3 Phase 5 - rebuild AG headers and trees... - reset superblock... Phase 6 - check inode connectivity... - resetting contents of realtime bitmap and summary inodes - traversing filesystem ... - traversal finished ... - moving disconnected inodes to lost+found ... Phase 7 - verify and correct link counts... Note - stripe unit (0) and width (0) were copied from a backup superblock. Please reset with mount -o sunit=<value>,swidth=<value> if necessary done
2.4 挂载xfs分区
[16:47:25 root@centos8 ~]#mount /dev/sdc1 /data/ [16:47:22 root@centos8 ~]#df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 956M 0 956M 0% /dev tmpfs 976M 0 976M 0% /dev/shm tmpfs 976M 8.8M 967M 1% /run tmpfs 976M 0 976M 0% /sys/fs/cgroup /dev/mapper/cl-root 66G 3.2G 62G 5% / /dev/mapper/cl-home 32G 260M 32G 1% /home /dev/sda1 1014M 180M 835M 18% /boot tmpfs 196M 0 196M 0% /run/user/0 /dev/sdc1 1017M 1017M 132K 100% /data
2.5 测试
[16:47:25 root@centos8 ~]#ls /data/*.conf /data/asound.conf /data/kdump.conf /data/logrotate.conf /data/sestatus.conf /data/xattr.conf /data/chrony.conf /data/krb5.conf /data/man_db.conf /data/sudo.conf /data/yum.conf /data/dracut.conf /data/ld.so.conf /data/mke2fs.conf /data/sudo-ldap.conf /data/fuse.conf /data/libaudit.conf /data/nsswitch.conf /data/sysctl.conf /data/host.conf /data/libuser.conf /data/resolv.conf /data/tcsd.conf /data/idmapd.conf /data/locale.conf /data/rsyslog.conf /data/vconsole.conf [16:50:13 root@centos8 ~]#ls /data/*.rpm |head -3 /data/aajohan-comfortaa-fonts-3.001-2.el8.noarch.rpm /data/accel-config-2.8-1.el8.i686.rpm /data/accel-config-2.8-1.el8.x86_64.rpm
这篇关于Centos非LVM磁盘扩展的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-18uniapp 怎么定义对象属性?-icode9专业技术文章分享
- 2024-11-18克罗内克积是什么?-icode9专业技术文章分享
- 2024-11-18uniapp怎么实现点击防抖和节流功能?-icode9专业技术文章分享
- 2024-11-18uniapp实现全局的监听和接收有哪些方法?-icode9专业技术文章分享
- 2024-11-18TCPDF与mpdf的区别与优势是什么?-icode9专业技术文章分享
- 2024-11-17getExternalFilesDir这个方法哪些安卓版本可以使用?-icode9专业技术文章分享
- 2024-11-17app下载好后,安装包更新代码怎么写?-icode9专业技术文章分享
- 2024-11-17login-customer-id 如何获取?-icode9专业技术文章分享
- 2024-11-17使用 vite加载.env 文件环境变量无法加载是什么原因?-icode9专业技术文章分享
- 2024-11-17tp钱包是什么,有哪些功能?-icode9专业技术文章分享