دستهبندی نشده
اضافه کردن هارد جدید و پارتیشن بندی آن در سیستم عامل لینوکس

هدف از انتشار این مطلب، آموزش اضافه کردن هارد و پارتیشن بندی آن را در لینوکس است.
در این فرایند از ابزارهای fdisk و mkfs استفاده می کنیم و با دستور زیر مطمئن میشیم که نصب هستند و اگر نیستند ، نصب خواهند شد.
yum install mkfs fdisk -y
ابتدا یک هارد جدید به سرور اضافه می کنیم. (چه از مجازی ساز استفاده می کنید یا چه بصورت فیزیکی استفاده می کنید)
بعد از اضافه کردن هارد ، سرور را بصورت سخت افزاری reboot کنید.
بعد از ریبوت دستور زیر fdisk -l را بزنید و هارد جدید را مشاهده می کنید که هیچ پارتیشنی ندارد. (برای من نام هارد جدید vdb هست.)
[root@dpmail ~]# fdisk -l
Disk /dev/vda: 1073.7 GB, 1073741824000 bytes
۲۵۵ heads, 63 sectors/track, 130541 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b6106
Device Boot Start End Blocks Id System
/dev/vda1 1 130542 1048574976 83 Linux
Disk /dev/vdb: 1073.7 GB, 1073741824000 bytes
۱۶ heads, 63 sectors/track, 2080507 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
حالا با ابزار fdisk سعی می کنیم در دیسک جدید ، پارتیشن بسازیم.
[root@dpmail ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1756a178.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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
Command action
e extended
p primary partition (1-4)
۱
Invalid partition number for type `1′
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2080507, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2080507, default 2080507):
Using default value 2080507
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
به ترتیب کلید های زیر زده شد. n (اینتر) و ۱ (اینتر) و اینتر و اینتر و اینتر و w (اینتر) . تمام
حالا پارتیشن ساخته شده را با mkfs به فرمت ext4 تبدیل می کنیم.
[root@dpmail ~]# mkfs -t ext4 /dev/vdb1
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
۶۵۵۳۶۰۰۰ inodes, 262143874 blocks
۱۳۱۰۷۱۹۳ blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
۸۰۰۰ block groups
۳۲۷۶۸ blocks per group, 32768 fragments per group
۸۱۹۲ inodes per group
Superblock backups stored on blocks:
۳۲۷۶۸, ۹۸۳۰۴, ۱۶۳۸۴۰, ۲۲۹۳۷۶, ۲۹۴۹۱۲, ۸۱۹۲۰۰, ۸۸۴۷۳۶, ۱۶۰۵۶۳۲, ۲۶۵۴۲۰۸,
۴۰۹۶۰۰۰, ۷۹۶۲۶۲۴, ۱۱۲۳۹۴۲۴, ۲۰۴۸۰۰۰۰, ۲۳۸۸۷۸۷۲, ۷۱۶۶۳۶۱۶, ۷۸۶۷۵۹۶۸,
۱۰۲۴۰۰۰۰۰, ۲۱۴۹۹۰۸۴۸
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 38 mounts or
۱۸۰ days, whichever comes first. Use tune2fs -c or -i to override.
حالا مقادیر زیر را در فایل /etc/fstab میگذاریم. (دستور زیر کافیست)
echo “/dev/vdb1 /vdb ext4 defaults 0 0” >> /etc/fstab
حالا دیسک را مونت می کنیم.
mkdir -p /vdb
mount -t ext4 /dev/vdb1 /vdb
پارتیشن اضافه شده و اماده ی استفاده است 🙂
[root@dpmail ~]df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 985G 833G 102G 90% /
none 939M 0 939M 0% /dev/shm
tmpfs 512M 0 512M 0% /mnt/ramdisk
/dev/vdb1 985G 72M 935G 1% /vdb