Hướng dẫn thêm disk trên Linux

Để thêm disk và tạo partition trên Linux, ta có thể làm theo hướng dẫn bên dưới:

Bước 1: Dùng command fdisk -l để xác định disk vừa mới thêm vào.

Bước 2: Sau khi xác định được disk thêm vào, ta dùng command fdisk <new_disk> để tạo partition:

Vd:

[root]# fdisk /dev/sdb
Command (m for help): m     (Enter the letter “m” to get list of commands)
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition’s system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-9729, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-9729, default 9729):
Using default value 9729

Command (m for help): w    (Write and save partition table)

Bước 3: Sau khi tạo partition hoàn tất, ta sẽ tiến hành định dạng cho partition bằng command: mkfs.ext4 <new_partition>

Vd: mkfs.ext4 /dev/sdb1

Bước 4: Sau khi định dạng cho partition thành công, ta sẽ mount partition vào mount point bằng command: mount -t ext4 <new_partition> <mount_point>

Vd: mount -t ext4 /dev/sdb1 /home2

Bước 5: Để cho việc mount tự động, ta tiến hành cấu hình trong file /etc/fstab

Vd: /dev/sdb1 /home2 ext4 defaults 1 1

Chúc bạn thực hiện thành công.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top