Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of lossless expansion of linux

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

overview

Cloud platform customer servers may be insufficient disk space with the continuous growth of business volume, for example: the shared file server hard disk space is insufficient, at this time you need to increase disk space to meet the online business; or we use linux process, sometimes due to improper partition installation system caused by some partition space shortage, and some partition space surplus situation, you can use fdisk partition tool to dynamically adjust the partition size;

step

1. backup

Even if it is lossless expansion, it is inevitable that something will happen. Backup is essential. Generally, cloud platforms have backup function, which can directly make a full backup of disks.

2. Repartition with fdisk

The default partitions are as follows

root@i-abnawjwo:/# dfFilesystem 1K-blocks Used Available Use% Mounted onudev 497752 4 497748 1% /devtmpfs 101700 440 101260 1% /run/dev/sda1 20509308 1337636 18106816 7% /none 4 0 4 0% /sys/fs/cgroupnone 5120 0 5120 0% /run/locknone 508488 0 508488 0% /run/shmnone 102400 0 102400 0% /run/user/dev/sdc1 10190136 23032 9626432 1% /dataroot@i-abnawjwo:/data# cat hellotest1

Unmount the current partition umount /dev/sdc1

If uninstall does not drop, there may be a process reuse, you can use fuser or lsof view

fuser -m -v /datafuser -m -v -i -k /datalsof /data

After unloading fdisk, delete the original partition and repartition. Note that the initial cylinder number should be consistent with the original one (this is the key step to ensure that data is not lost).

root@i-abnawjwo:/# umount /dataroot@i-abnawjwo:/# fdisk /dev/sdcCommand (m for help): dSelected partition 1Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p):Using default response pPartition number (1-4, default 1):Using default value 1First sector (2048-104857599, default 2048):Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):Using default value 104857599Command (m for help): pDisk /dev/sdc: 53.7 GB, 53687091200 bytes64 heads, 32 sectors/track, 51200 cylinders, total 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x305cddae Device Boot Start End Blocks Id System/dev/sdc1 2048 104857599 52427776 83 LinuxCommand (m for help): wqThe partition table has been altered! Calling ioctl() to re-read partition table.Syncing disks.

restart the system

3. Detect partitions, extend partition size

root@i-abnawjwo:~# e2fsck -f /dev/sdb1e2fsck 1.42.9 (4-Feb-2014)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/sdb1: 12/655360 files (0.0% non-contiguous), 79664/2621440 blocksroot@i-abnawjwo:~# resize2fs -p /dev/sdb1resize2fs 1.42.9 (4-Feb-2014)Resizing the filesystem on /dev/sdb1 to 13106944 (4k) blocks.The filesystem on /dev/sdb1 is now 13106944 blocks long.

4. Mount again, check partition size, check data

root@i-abnawjwo:~# mount /dev/sdb1 /data/root@i-abnawjwo:/data# cat helloacasdcacsaroot@i-abnawjwo:/data# dfFilesystem 1K-blocks Used Available Use% Mounted onudev 497752 4 497748 1% /devtmpfs 101700 428 101272 1% /run/dev/sda1 20509308 1337768 18106684 7% /none 4 0 4 0% /sys/fs/cgroupnone 5120 0 5120 0% /run/locknone 508488 0 508488 0% /run/shmnone 102400 0 102400 0% /run/user/dev/sdb1 51474044 33100 48803172 1% /data

The above is all the content of this article, I hope to help everyone's study, but also hope that everyone a lot of support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report