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

重启后查看分区情况

边栏推荐
- Data communication foundation smart_ Link_&_ Monitor_ Link
- 17. [stm32] use only three wires to drive LCD1602 LCD
- Temporary cramming before DFS examination
- Background system sending verification code function
- Noi / 1.4 07: collect bottle caps to win awards
- Data communication foundation - Ethernet port mirroring and link aggregation
- 16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度
- 漫画:什么是MapReduce?
- 18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度
- Why should we learn mathematical modeling?
猜你喜欢

list去重并统计个数

Which keywords will conflict with the abstract keyword

MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!

开发中Boolean类型使用遇到的坑

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

Data communication foundation NAT network address translation

verilog实现计算最大公约数和最小公倍数

示例项目:简单的六足步行者
![19.[STM32]HC_ SR04 ultrasonic ranging_ Timer mode (OLED display)](/img/fe/8f59db28823290da8e9280df06673d.jpg)
19.[STM32]HC_ SR04 ultrasonic ranging_ Timer mode (OLED display)

sql中set标签的使用
随机推荐
Dataarts studio data architecture - Introduction to data standards
【网易云信】超分辨率技术在实时音视频领域的研究与实践
降本40%!Redis多租户集群的容器化实践
abstract关键字和哪些关键字会发生冲突呢
Summary of the second lesson
ES6深入—ES6 Generator 函数
Batch update in the project
21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动
Obj resolves to a set
Memo 00
Convert obj set to entity set
wyt 。。
一文带你吃透js处理树状结构数据的增删改查
vant popup+其他组件的组合使用,及避坑指南
ES6深入—ES6 Class 类
Vulnhub-Moneybox
Information collection of penetration test
list使用Stream流进行根据元素某属性数量相加
Use of set tag in SQL
Cs231n notes (top) - applicable to 0 Foundation