当前位置:网站首页>迁移/home分区
迁移/home分区
2022-07-05 15:37:00 【51CTO】
实验坏境
公司原来安装的Centos服务器采用了自动分区的方案,随着使用服务器的系统用户数量不断增加,根分区经常面临磁盘空间耗尽情况,甚至有几次还导致系统无法启动,为了解决这些问题,现需要为服务器新增一块scsl硬盘,并将用户目录/home中的数据迁移到该硬盘中,要求迁移后不能影响原有用户账户的使用。
需求描述
在虚拟机中添加一块80GB的SCSI磁盘
在新硬盘中建立一个20GB的分区,用于存放所有普通用户宿主文件夹
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-167772159,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-167772159,默认为 167772159):+20G
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x47dca76d
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 41945087 20971520 83 Linux
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
分区后磁盘需要格式化
[[email protected] ~]# mkfs -t ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[[email protected] ~]#
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
新建的分区仍然挂载到/home目录下,需要导入系统中原有用户的数据
[[email protected] ~]# mkdir /zhang
[[email protected] ~]# mv /home/* -t /zhang/
[[email protected] ~]# ls /zhang/
bdqn kylin obama zhang
[[email protected] ~]# ls /home/
[[email protected] ~]# mount /dev/sdb1 /home/
[[email protected] ~]# df
文件系统 1K-块 已用 可用 已用% 挂载点
devtmpfs 481616 0 481616 0% /dev
tmpfs 497836 0 497836 0% /dev/shm
tmpfs 497836 8676 489160 2% /run
tmpfs 497836 0 497836 0% /sys/fs/cgroup
/dev/sda3 18873344 5782856 11349848 34% /
/dev/sda1 1038336 173828 864508 17% /boot
tmpfs 99568 24 99544 1% /run/user/0
/dev/sr0 4600876 4600876 0 100% /run/media/root/CentOS 7 x86_64
/dev/sdb1 20511312 45080 19401272 1% /home
[[email protected] ~]# ls -al /home/
总用量 20
drwxr-xr-x 3 root root 4096 7月 4 15:31 .
dr-xr-xr-x. 1 root root 230 7月 4 15:33 ..
drwx------ 2 root root 16384 7月 4 15:31 lost+found
[[email protected] ~]# mv /zhang/* -t /home/
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
服务器在每次开机后能够自动挂载该分区
重启后查看分区情况
边栏推荐
猜你喜欢
Background system sending verification code function
RLock锁的使用
抽象类中子类与父类
SQL injection sqllabs (basic challenges) 11-20
The difference between abstract classes and interfaces
Arduino controls a tiny hexapod 3D printing robot
CISP-PTE之PHP伪协议总结
Lesson 4 knowledge summary
Quick completion guide for manipulator (IX): forward kinematics analysis
16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature
随机推荐
超分辨率技术在实时音视频领域的研究与实践
21. [STM32] I don't understand the I2C protocol. Dig deep into the sequence diagram to help you write the underlying driver
Codasip为RISC-V处理器系列增加Veridify安全启动功能
[Netease Yunxin] research and practice of super-resolution technology in the field of real-time audio and video
对象和类的关系
开发中Boolean类型使用遇到的坑
Use of set tag in SQL
漫画:什么是分布式事务?
Go language programming specification combing summary
Information collection of penetration test
践行自主可控3.0,真正开创中国人自己的开源事业
Data communication foundation smart_ Link_&_ Monitor_ Link
Linear DP (basic questions have been updated)
移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
Noi / 1.5 37: mercenaries
RLock锁的使用
事务回滚异常
单商户 V4.4,初心未变,实力依旧!
一键安装脚本实现快速部署GrayLog Server 4.2.10单机版
vlunhub- BoredHackerBlog Moriarty Corp