当前位置:网站首页>迁移/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.
服务器在每次开机后能够自动挂载该分区

重启后查看分区情况

边栏推荐
- Exception com alibaba. fastjson. JSONException: not match : - =
- 基于OpenHarmony的智能金属探测器
- sql中查询最近一条记录
- Lesson 4 knowledge summary
- Use of set tag in SQL
- ES6 deep - ES6 class class
- Codasip adds verify safe startup function to risc-v processor series
- sql中set标签的使用
- 视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革
- Fundamentals of data communication - Principles of IP routing
猜你喜欢

ES6 drill down - Async functions and symbol types

list去重并统计个数

项目中批量update

项目sql中批量update的时候参数类型设置错误

写单元测试的时候犯的错

研发效能度量指标构成及效能度量方法论

How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you

Which keywords will conflict with the abstract keyword

Pits encountered in the use of boolean type in development
![[Netease Yunxin] research and practice of super-resolution technology in the field of real-time audio and video](/img/69/3aedcdafb2b4e83087dc1ce593dc38.png)
[Netease Yunxin] research and practice of super-resolution technology in the field of real-time audio and video
随机推荐
list去重并统计个数
Li Kou today's question -729 My schedule I
OceanBase社区版之OBD方式部署方式本地安装
21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动
The visual experience has been comprehensively upgraded, and Howell group and Intel Evo 3.0 have jointly accelerated the reform of the PC industry
服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】
20. [stm32] realize the function of intelligent garbage can by using ultrasonic module and steering gear
抽象类和接口的区别
ES6 deep - ES6 class class
Batch update in the project
异常com.alibaba.fastjson.JSONException: not match : - =
漫画:什么是分布式事务?
CODING DevSecOps 助力金融企业跑出数字加速度
项目sql中批量update的时候参数类型设置错误
践行自主可控3.0,真正开创中国人自己的开源事业
通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你
Data communication foundation - routing communication between VLANs
Subclasses and superclasses of abstract classes
List de duplication and count the number
verilog实现计算最大公约数和最小公倍数