In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to expand the hard disk partition under the Linux system". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to expand the hard disk partition under the Linux system".
When the hard disk is almost full, add the hard disk to expand its capacity, regardless of whether it is an independent server or a newly purchased hard disk bought by Cloud Space.
First, mount the hard disk to the directory directly without using lvm
1. Check the partition of the hard disk
The code is as follows:
[root@iZ94zz3wqciZ ~] # df
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/xvda1 20641404 14778400 4814480 76%
Tmpfs 509300 0 509300 / dev/shm
[root@iZ94zz3wqciZ ~] # fdisk-l
Disk / dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00078f9c
Device Boot Start End Blocks Id System
/ dev/xvda1 * 1 2611 20970496 83 Linux / / id is 83, non-lvm
Disk / dev/xvdb: 23.6 GB, 23622320128 bytes / / newly purchased hard disk
255 heads, 56 sectors/track, 3230 cylinders
Units = cylinders of 14280 * 512 = 7311360 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x27cc1f5a
2. Partition the hard disk and check the partition situation
The code is as follows:
[root@iZ94zz3wqciZ] # fdisk-S 56 / dev/xvdb / / Partition
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
Switch off the mode (command 'c') and change display units to
Sectors (command'u').
Command (m for help): n / / enter n
Command action
E extended
P primary partition (1-4)
P / / primary partition
Partition number (1-4): 1 / / partition code 1
First cylinder (1-3230, default 1):
Using default value 1
Last cylinder, + cylinders or + size {KMagne Mpeng} (1-3230, default 3230):
Using default value 3230
Command (m for help): wq / / Save and exit
The partition table has been altered!
[root@iZ94zz3wqciZ ~] # fdisk-l
Disk / dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00078f9c
Device Boot Start End Blocks Id System
/ dev/xvda1 * 1 2611 20970496 83 Linux
Disk / dev/xvdb: 23.6 GB, 23622320128 bytes
255 heads, 56 sectors/track, 3230 cylinders
Units = cylinders of 14280 * 512 = 7311360 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x27cc1f5a
Device Boot Start End Blocks Id System
/ dev/xvdb1 1 3230 23062172 83 Linux / / after partition
3, format the new partition xvdb1
The code is as follows:
[root@iZ94zz3wqciZ ~] # mkfs.ext4 / dev/xvdb1 / / format partition
Mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1441792 inodes, 5765543 blocks
288277 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
176 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs-c or-i to override.
4. Create a directory and mount the partition
The code is as follows:
[root@iZ94zz3wqciZ ~] # mkdir / mnt/fastdfs / / Mount directory
[root@iZ94zz3wqciZ ~] # echo "/ dev/xvdb1 / mnt/fastdfs ext4 defaults 0" > > / etc/fstab / / restart will mount automatically
[root@iZ94zz3wqciZ ~] # mount-a / / Mount all directories
[root@iZ94zz3wqciZ ~] # df
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/xvda1 20641404 14778404 4814476 76%
Tmpfs 509300 0 509300 / dev/shm
/ dev/xvdb1 22694396 176064 21365516 1% / mnt/fastdfs / / New partition is mounted
At this point, a separate hard disk is added to the system. This expansion method is easy to operate, but not scalable, so it is not recommended.
Second, use lvm to expand the capacity of the hard disk (recommended)
1. Unmount the previous test and delete the partition
The code is as follows:
[root@iZ94zz3wqciZ ~] # umount-a / / Unmount
[root@iZ94zz3wqciZ ~] # fdisk / dev/xvdb / / partition
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
Switch off the mode (command 'c') and change display units to
Sectors (command'u').
Command (m for help): d / / delete partition
Selected partition 1
Command (m for help): wq / / Save
The partition table has been altered!
2, install lvm
The code is as follows:
[root@iZ94zz3wqciZ nginx] # uname-a / / View kernel information
Linux iZ94zz3wqciZ 2.6.32-431.23.3.el6.x86_64 # 1 SMP Thu Jul 31 17:20:51 UTC 2014 x86 "64 GNU/Linux
[root@iZ94zz3wqciZ ~] # yum install lvm2 device-mapper / / later versions of LVM2,2.6.9 do not need to install device-mapper
[root@iZ94zz3wqciZ nginx] # lsmod | grep dm_mod / / whether dm_mod is loaded
Dm_mod 84337 5 dm_mirror,dm_log
To install lvm, load the device-mapper module first. The device-mapper module has been included since linux kernel 2.6.9, so you just need to load it. Load the mapper module: modprobe dm_mod.
3, create a lvm partition
The code is as follows:
[root@iZ94zz3wqciZ ~] # fdisk / dev/xvdb / / partition
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
Switch off the mode (command 'c') and change display units to
Sectors (command'u').
Command (m for help): l
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So C1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: C6 DRDOS/sec (FAT-
4 FAT16
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.