[英]How to change AWS EBS volume filesystem type
EBS volume was attached as ext4
on /opt/apps
. EBS卷作为ext4
附加在/opt/apps
。 There are currently no data on it. 当前没有任何数据。 How to change filesystem type to xfs
and assign a new mount point to /data
? 如何将文件系统类型更改为xfs
并为/data
分配新的安装点?
[centos@ip-10-24-xx-xxx ~]$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda1 xfs 8.0G 1.4G 6.7G 17% /
devtmpfs devtmpfs 7.3G 0 7.3G 0% /dev
tmpfs tmpfs 7.2G 0 7.2G 0% /dev/shm
tmpfs tmpfs 7.2G 17M 7.2G 1% /run
tmpfs tmpfs 7.2G 0 7.2G 0% /sys/fs/cgroup
/dev/xvdb ext4 99G 61M 94G 1% /opt/apps
tmpfs tmpfs 1.5G 0 1.5G 0% /run/user/1000
This is not specific to AWS EBS. 这并非特定于AWS EBS。 Amazon gives you a "disk" called EBS, attached to /dev/xvdb. Amazon为您提供了一个称为EBS的“磁盘”,该磁盘附加到/ dev / xvdb。 Then, feel free to mount it anywhere (/opt/apps, or /data) and format it with the filesystem you want. 然后,随时将其挂载到任何位置(/ opt / apps或/ data),并使用所需的文件系统对其进行格式化。
This page can help you http://ask.xmodulo.com/create-mount-xfs-file-system-linux.html 此页面可以帮助您http://ask.xmodulo.com/create-mount-xfs-file-system-linux.html
See you have two options to achieve your use case. 看到您有两种选择来实现用例。
You can either convert your root volume to XFS or create a second volume. 您可以将根卷转换为XFS或创建第二个卷。 Personally, I would favour the latter as it offers more flexibility. 就个人而言,我更喜欢后者,因为它提供了更大的灵活性。
Option 1: Convert Root Volume to XFS 选项1:将根卷转换为XFS
xfsprogs
if not already done) 将新的EBS卷格式化为XFS(如果尚未安装,请安装xfsprogs
) rsync -aHAXxSP /source /target
) 将所有数据从第一个卷复制到新的卷(例如,使用rsync -aHAXxSP /source /target
) The reason for attaching the root volume to another instance is to attain consistency, which would be difficult with the volume in use. 将根卷附加到另一个实例的原因是要获得一致性,而使用该卷将很难做到这一点。
Option 2: Move data to a second EBS volume 选项2:将数据移至第二个EBS卷
lsof | grep /path/to/dir
使用lsof | grep /path/to/dir
lsof | grep /path/to/dir
to check for remaining write locks lsof | grep /path/to/dir
检查剩余的写锁 mount -o bind /mnt/path/to/dir /orig/path/to/dir
) 安装将新目录绑定到其旧位置(即mount -o bind /mnt/path/to/dir /orig/path/to/dir
) /etc/fstab
file to make the mount points permanent; 编辑/etc/fstab
文件以使挂载点永久存在; eg: /mnt/path/to/dir /orig/path/to/dir bind defaults,noatime,bind 0 0
例如: /mnt/path/to/dir /orig/path/to/dir bind defaults,noatime,bind 0 0
Restart to ensure everything persists and functions as it should. 重新启动以确保所有内容都可以持续存在并正常运行。 You may also want to consider shrinking your root volume down a bit since, hopefully, it shouldn't be growing (or changing) much with all the data removed from it. 您可能还需要考虑将根卷减小一点,因为希望从中删除所有数据后,根卷不应该增加(或更改)太多。
(As a point of mention, it may be possible to freeze an ext4 file system using fsfreeze
, which is included in util-linux-ng
). (需要指出的是,有可能使用util-linux-ng
包含的fsfreeze
冻结ext4文件系统)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.