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

重启后查看分区情况

边栏推荐
- ES6 drill down - ES6 generator function
- Pits encountered in the use of boolean type in development
- verilog实现计算最大公约数和最小公倍数
- go语言编程规范梳理总结
- Vulnhub-Moneybox
- ES6深入—async 函数 与 Symbol 类型
- 16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature
- [brief notes] solve the problem of IDE golang code red and error reporting
- vulnhub-Root_ this_ box
- MySQL overview
猜你喜欢
![21. [STM32] I don't understand the I2C protocol. Dig deep into the sequence diagram to help you write the underlying driver](/img/f4/2c935dd9933f5cd4324c29c41ab221.png)
21. [STM32] I don't understand the I2C protocol. Dig deep into the sequence diagram to help you write the underlying driver

效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了

【 note 】 résoudre l'erreur de code IDE golang
![[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

Example project: simple hexapod Walker

Data communication foundation - routing communication between VLANs

vulnhub-Root_ this_ box

vlunhub- BoredHackerBlog Moriarty Corp

Arduino控制微小的六足3D打印机器人

Appium automation test foundation - appium basic operation API (I)
随机推荐
list去重并统计个数
Relationship between objects and classes
漫画:什么是分布式事务?
Analytic hierarchy process of mathematical modeling (including Matlab code)
Coding devsecops helps financial enterprises run out of digital acceleration
Is it safe for Guotai Junan to open an account online
ES6深入—ES6 Class 类
Quick completion guide for manipulator (IX): forward kinematics analysis
Data communication foundation - Ethernet port mirroring and link aggregation
企业级备份软件Veritas NetBackup(NBU) 8.1.1服务端的安装部署
Data communication foundation - route republication
Modify PyUnit_ Time makes it support the time text of 'xx~xx months'
16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度
vant tabbar遮挡内容的解决方式
具有倍数关系的时钟切换
Obj resolves to a set
20. [stm32] realize the function of intelligent garbage can by using ultrasonic module and steering gear
【毕业季】作为一名大二计科在校生,我有话想说
一键安装脚本实现快速部署GrayLog Server 4.2.10单机版
Data communication foundation smart_ Link_&_ Monitor_ Link