[Storage] 替新硬碟建分區並掛載
發表於 : 2023-08-18, 10:46
https://phoenixnap.com/kb/linux-create-partition
Create The Partition
Option 1: Partition a Disk Using parted Command
Step 1: List Partitions
Step 2: Open Storage Disk
Step 3: Make a Partition Table
Step 4: Check Table
Step 5: Create Partition
Option 2: Partition a Disk Using fdisk Command
Step 1: List Existing Partitions
Step 2: Select Storage Disk
Step 3: Create a New Partition
1. Run the n command to create a new partition.
2. Select the partition number by typing the default number.
3. After that, you are asked for the starting and ending sector of your hard drive. It is best to type the default number in this section.
4. The last prompt is related to the size of the partition. You can choose to have several sectors or to set the size in megabytes or gigabytes.

Step 4: Write on Disk
Step 5: Verify that the partition is created
Format the Partition
Mount the Partition
Create The Partition
Option 1: Partition a Disk Using parted Command
Step 1: List Partitions
代碼: 選擇全部
sudo parted -l代碼: 選擇全部
sudo parted /dev/sdb代碼: 選擇全部
select /dev/sdb代碼: 選擇全部
mklabel gpt代碼: 選擇全部
print代碼: 選擇全部
mkpart primary ext4 1MB 1855MBStep 1: List Existing Partitions
代碼: 選擇全部
sudo fdisk -l代碼: 選擇全部
sudo fdisk /dev/sdb1. Run the n command to create a new partition.
2. Select the partition number by typing the default number.
3. After that, you are asked for the starting and ending sector of your hard drive. It is best to type the default number in this section.
4. The last prompt is related to the size of the partition. You can choose to have several sectors or to set the size in megabytes or gigabytes.
代碼: 選擇全部
Command (m for help): n
Step 4: Write on Disk
代碼: 選擇全部
Command (m for help): w代碼: 選擇全部
sudo fdisk -l代碼: 選擇全部
sudo mkfs -t ext4 /dev/sdb1代碼: 選擇全部
sudo mkdir -p /mt/sdb1
sudo mount -t auto /dev/sbd1 /mt/sdb1
df -hT