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

重启后查看分区情况

边栏推荐
猜你喜欢

Analytic hierarchy process of mathematical modeling (including Matlab code)

Subclasses and superclasses of abstract classes

项目中批量update

Use of RLOCK lock

降本40%!Redis多租户集群的容器化实践

服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】

List de duplication and count the number

Five common negotiation strategies of consulting companies and how to safeguard their own interests

Data communication foundation ACL access control list

SQL injection sqllabs (basic challenges) 1-10
随机推荐
国泰君安网上开户安全吗
19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)
开发中Boolean类型使用遇到的坑
【毕业季】作为一名大二计科在校生,我有话想说
The visual experience has been comprehensively upgraded, and Howell group and Intel Evo 3.0 have jointly accelerated the reform of the PC industry
一键安装脚本实现快速部署GrayLog Server 4.2.10单机版
Data communication foundation - Ethernet port mirroring and link aggregation
Noi / 1.4 07: collect bottle caps to win awards
The difference between abstract classes and interfaces
单商户 V4.4,初心未变,实力依旧!
[graduation season] as a sophomore majoring in planning, I have something to say
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
Information collection of penetration test
Data communication foundation - routing communication between VLANs
vulnhub-FirstBlood
漫画:什么是蓝绿部署?
MySQL overview
漫画:什么是八皇后问题?
The list set is summed up according to a certain attribute of the object, the maximum value, etc
【 note 】 résoudre l'erreur de code IDE golang