#xfs_growfs
Explore tagged Tumblr posts
Text
【數位3C】Amazon Web Services - AWS EBS磁碟空間如何調整升級?
原本985g的空間不符所需 預計調整到5TB 先到aws的EBS磁碟區修改容量到需求空間 變更容量為5120G之後 還需要在操作系統內部擴展文件系統 Windows的話就到系統管理內調整 Linux的話則是要先進入該磁碟連接的機器中執行以下步驟 首先使用 lsblk 指令先確認容量是否顯示新的大小 再來確認磁碟格式是ext4還是xfs 使用df -T可以看到 若使用的是 ext4 文件系統,則執行以下 resize2fs /dev/nvme1n1 XFS 文件系統則執行: xfs_growfs /mount/point (看實際掛載位置) 最後再次使用 df -h 來確認文件系統已擴展到需要的新容量 以上~~收工!!
0 notes
Text
How is free space management implemented in Linux?
Free space management in Linux is a critical aspect of the filesystem's functionality, ensuring efficient utilization of disk space. Here’s how it’s typically implemented:
Space Management Strategy in Linux
Linux employs several strategies to manage free space within its filesystems. Each filesystem type, such as ext4, XFS, or Btrfs, has its own method for handling free space.
Block Allocation: Linux filesystems use block allocation techniques to manage free space. They keep track of free blocks (chunks of disk space) and allocate them to files as needed. When files are deleted or resized, the freed blocks are returned to the pool of available space.
Bitmaps and Lists: Many Linux filesystems use bitmaps or linked lists to track free blocks. For example, ext4 uses a combination of bitmaps and group descriptors to manage and allocate space.
Space Planning and Management: Advanced filesystems like XFS and Btrfs offer sophisticated space planning and management features. They include dynamic inode allocation, extent-based storage, and support for large files and filesystems.
Defragmentation: Linux filesystems periodically perform defragmentation to optimize space utilization. This process reorganizes fragmented files and free space to improve performance and reduce fragmentation.
Space Utilization Analytics: Tools like df, du, and lsblk provide insights into disk usage and free space. For more detailed analysis, software like ncdu or baobab can be used to visualize and manage disk space.
Space Management System and Software
Linux provides various space management systems and software solutions to handle disk space efficiently:
Filesystem Tools: Utilities like fsck, tune2fs, and xfs_growfs help manage filesystem integrity and space allocation.
Disk Usage Analyzers: Tools such as ncdu, baobab, and kdirstat offer graphical and command-line interfaces to analyze and manage disk space.
Role of Quantum Strides LLC
At Quantum Strides LLC, we understand the importance of effective space management for optimizing performance and storage efficiency. Our expertise in Space Management Software ensures that your systems are equipped with the latest tools and strategies for managing free space, enhancing overall Space Utilization Analytics, and ensuring robust Space Planning and Management.
For tailored solutions and advanced space management strategies, contact Quantum Strides LLC to leverage our expertise in optimizing your storage infrastructure.
Feel free to reach out if you need more detailed insights or specific recommendations on managing free space in Linux!
0 notes
Text
Google Cloud Resize
$ sudo growpart /dev/sda 1 $ sudo xfs_growfs /dev/sda1
0 notes
Text
CentOS7のrootのボリューム拡張とhomeのボリューム縮小
CentOSのインストール時にパーティションを自動で実行してしまったため、root50GBのhome150GBという分け方になってしまった。
今回はhome130GB→10GB root50GB→170GBにしたく勉強も兼ねていじってみました
流れ
事前準備
/home のバックアップ
/home の削除
/home の再作成
/home の復元
/root の拡張
1. 事前準備
HDD状況確認
$ df -hT ファイルシス タイプ サイズ 使用 残り 使用% マウント位置 /dev/mapper/centos-root xfs 50G 2.7G 48G 6% / devtmpfs devtmpfs 32G 0 32G 0% /dev tmpfs tmpfs 32G 0 32G 0% /dev/shm tmpfs tmpfs 32G 8.8M 32G 1% /run tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 145M 870M 15% /boot /dev/mapper/centos-home xfs 129G 141M 129G 1% /home tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/1000
普通のアカウントは/homeディレクトリを参照するので、/home以外にホームディレクトリを持つユーザーを用意する
$ sudo mkdir /work $ sudo useradd -d /work/resize -m -G wheel -p resize resize $ sudo cat /etc/passwd | grep resize resize:x:1002:1002::/work/resize:/bin/bash $ sudo passwd resize
念のためVMSphereでスナップショット作成
2. /home のバックアップ
/homeのダンプを撮るためにxfsdumpをインストール
$ sudo yum -y install xfsdump
fuserコマンドを使うためにpsmiscパッケージをインストール
$ sudo yum -y instlal psmisc
※/homeパーティションを利用しているプロセスを見つけるのに必要
作業用ユーザーでログインしなおし、xfsdumpで/homeのバックアップをとる
ダンプファイルは実行時のディレクトリに保存されるためcd /workする
$ cd /work $ sudo xfsdump -J -L home -M drive -f home.dump /home xfsdump: using file dump (drive_simple) strategy xfsdump: version 3.1.7 (dump format 3.0) - type ^C for status and control xfsdump: level 0 dump of localhost.localdomain:/home xfsdump: dump date: Tue Dec 25 10:32:29 2018 xfsdump: session id: f8a1cb38-321e-48c1-bf15-ccc9ba2cde90 xfsdump: session label: "home" xfsdump: ino map phase 1: constructing initial dump list xfsdump: ino map phase 2: skipping (no pruning necessary) xfsdump: ino map phase 3: skipping (only one dump stream) xfsdump: ino map construction complete xfsdump: estimated dump size: 113395648 bytes xfsdump: creating dump session media file 0 (media 0, file 0) xfsdump: dumping ino map xfsdump: dumping directories xfsdump: dumping non-directory files xfsdump: ending media file xfsdump: media file size 113382656 bytes xfsdump: dump size (non-dir files) : 113347760 bytes xfsdump: dump complete: 1 seconds elapsed xfsdump: Dump Summary: xfsdump: stream 0 /work/home.dump OK (success) xfsdump: Dump Status: SUCCESS
Dump Status: SUCCESS がでればOK
3. /home の削除
/homeのアンマウント
アンマウント先はdfコマンドで出てきたホストドメイン名を指定する
$ sudo umount /dev/mapper/centos-home $ df -hT ファイルシス タイプ サイズ 使用 残り 使用% マウント位置 /dev/mapper/centos-root xfs 50G 2.8G 48G 6% / devtmpfs devtmpfs 32G 0 32G 0% /dev tmpfs tmpfs 32G 0 32G 0% /dev/shm tmpfs tmpfs 32G 8.8M 32G 1% /run tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 145M 870M 15% /boot tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/1002
umountに成功するとdfで/homeの行が消える
論理ボリュームの削除
lvchange -anで非アクティブにし、lvremoveで削除
$ sudo lvchange -an /dev/mapper/centos-home $ sudo lvremove /dev/mapper/centos-home Logical volume "home" successfully removed
4. /home の再作成
/homeに必要な容量を事前に把握しておき、再作成を実施する(10GBあればいいかな?)
lvcreateで作成する
$ sudo lvcreate -L 10G -n home /dev/centos WARNING: xfs signature detected on /dev/centos/home at offset 0. Wipe it? [y/n]: y Wiping xfs signature on /dev/centos/home. Logical volume "home" created.
※ボリュームグループが分からない場合はlvdisplayで確認する
$ sudo lvdisplay
実際にlvcreateに成功すると、論理ボリュームが増えていることがわかる
$ sudo lvdisplay --- Logical volume --- LV Path /dev/centos/home LV Name home VG Name centos LV UUID 8OoMr2-QFyZ-Uh3e-tggd-GiSI-fpgD-IyAMdj LV Write Access read/write LV Creation host, time localhost.localdomain, 2018-12-25 10:49:58 +0900 LV Status available # open 0 LV Size 10.00 GiB Current LE 2560 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
論理ボリュームの割り当てからシステムファイルをつくる
$ sudo mkfs.xfs /dev/centos/home meta-data=/dev/centos/home isize=512 agcount=4, agsize=655360 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=2621440, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
作成された/homeをマウント
$ sudo mount /dev/centos/home
dfで確認
$ df -hT ファイルシス タイプ サイズ 使用 残り 使用% マウント位置 /dev/mapper/centos-root xfs 50G 2.8G 48G 6% / devtmpfs devtmpfs 32G 0 32G 0% /dev tmpfs tmpfs 32G 0 32G 0% /dev/shm tmpfs tmpfs 32G 8.8M 32G 1% /run tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 145M 870M 15% /boot tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/1002 /dev/mapper/centos-home xfs 10G 33M 10G 1% /home
10GBになっているのを確認
4. /home の復元
xfsrestoreでdumpファイルを復元する
$ cd /work $ sudo xfsrestore -J -L home -f home.dump /home xfsrestore: using file dump (drive_simple) strategy xfsrestore: version 3.1.7 (dump format 3.0) - type ^C for status and control xfsrestore: searching media for dump xfsrestore: examining media file 0 xfsrestore: found dump matching specified label: xfsrestore: hostname: localhost.localdomain xfsrestore: mount point: /home xfsrestore: volume: /dev/mapper/centos-home xfsrestore: session time: Tue Dec 25 10:32:29 2018 xfsrestore: level: 0 xfsrestore: session label: "home" xfsrestore: media label: "drive" xfsrestore: file system id: 82544f08-be46-4203-99b1-67895f606742 xfsrestore: session id: f8a1cb38-321e-48c1-bf15-ccc9ba2cde90 xfsrestore: media id: 9d312bad-2619-4d06-9d1c-56d66feabff8 xfsrestore: searching media for directory dump xfsrestore: reading directories xfsrestore: 5 directories and 18 entries processed xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: 0 seconds elapsed xfsrestore: Restore Summary: xfsrestore: stream 0 /work/home.dump OK (success) xfsrestore: Restore Status: SUCCESS
Restore Status: SUCCESS とでればOK
これで120GB弱の領域が残っていることになるので、/rootに割り当てる作業をする
5. /root の拡張
/root の拡張は論理ボリュームの拡張→ファイルシステムの拡張の手順となる
論理ボリュームの120GB弱を割り当てる
$ sudo lvextend -l +100%FREE /dev/mapper/centos-root Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to <169.00 GiB (43263 extents). Logical volume centos/root successfully resized.
システムファイルの拡張
$ sudo xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=13107200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=6400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 13107200 to 44301312
論理ボリュームの割り当てが使用になったかdfで確認
$ df -hT /dev/mapper/centos-root xfs 169G 2.8G 167G 2% / devtmpfs devtmpfs 32G 0 32G 0% /dev tmpfs tmpfs 32G 0 32G 0% /dev/shm tmpfs tmpfs 32G 8.8M 32G 1% /run tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 145M 870M 15% /boot tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/1002 /dev/mapper/centos-home xfs 10G 141M 9.9G 2% /home
★完了
参考サイト
CentOS7でhomeパーティションの容量を削減してrootに割り当てる
0 notes