Linux Hard Disk Format Command

本文详细介绍了在Linux操作系统中安装并分区新硬盘的过程,包括使用fdisk命令分区、mkfs.ext3命令格式化、mount命令挂载以及更新fstab文件等步骤。
Q. I've installed a new 250GB SATA hard disk on our office CentOS Linux server. How do I format a hard disk under Linux operating system from a shell prompt?
A.. There are total 4 steps involved for hard disk upgrade and installation procedure:

Step #1 : Partition the new disk using fdisk command

Following command will list all detected hard disks:
# fdisk -l | grep '^Disk'
Output:

Disk /dev/sda: 251.0 GB, 251000193024 bytes Disk /dev/sdb: 251.0 GB, 251000193024 bytes

A device name refers to the entire hard disk. For more information see Linux partition naming convention and IDE drive mappings.
To partition the disk - /dev/sdb, enter:
# fdisk /dev/sdb
The basic fdisk commands you need are:
  • m - print help
  • p - print the partition table
  • n - create a new partition
  • d - delete a partition
  • q - quit without saving changes
  • w - write the new partition table and exit

Step#2 : Format the new disk using mkfs.ext3 command

To format Linux partitions using ext2fs on the new disk:
# mkfs.ext3 /dev/sdb1

Step#3 : Mount the new disk using mount command

First create a mount point /disk1 and use mount command to mount /dev/sdb1, enter:
# mkdir /disk1
# mount /dev/sdb1 /disk1
# df -H

Step#4 : Update /etc/fstab file

Open /etc/fstab file, enter:
# vi /etc/fstab
Append as follows:

/dev/sdb1 /disk1 ext3 defaults 1 2

Save and close the file.

Task: Label the partition

You can label the partition using e2label. For example, if you want to label the new partition /backup, enter
# e2label /dev/sdb1 /backup
You can use label name insted of partition name to mount disk using /etc/fstab:
LABEL=/backup /disk1 ext3 defaults 1 2
### Linux EFI System Partition Configuration and Setup In modern operating systems, the GUID Partition Table (GPT) is widely supported as a standard for defining disk partitions[^1]. For Linux-based systems that require booting through UEFI firmware, an EFI System Partition (ESP) plays a critical role. The ESP serves as a dedicated partition formatted with a FAT32 file system where bootloader files are stored. #### Key Characteristics of EFI System Partitions The EFI System Partition must meet specific requirements to ensure proper functionality within a UEFI environment: - **File System**: It should be formatted using the FAT32 filesystem due to its compatibility across various platforms. - **Partition Type Identifier**: Its type identifier in GPT is `C12A7328-F81F-11D2-BA4B-00A0C93EC93B`, which uniquely identifies it as an ESP. When configuring a Linux installation intended to operate under UEFI mode, ensuring correct setup of this partition involves several steps: 1. **Creating the Partition**: Use tools such as `fdisk` or `parted` during the initial stages of setting up your hard drive layout. Ensure you specify the appropriate flags marking the new partition as 'bootable' and assign it the necessary UUID/GUID corresponding to an EFI System Partition. Example command snippet illustrating creation via parted utility: ```bash sudo parted /dev/sda mklabel gpt sudo parted /dev/sda mkpart primary fat32 1MiB 513MiB sudo parted /dev/sda set 1 esp on ``` 2. **Formatting the Created Partition**: After creating the partition, format it appropriately by applying the FAT32 file system structure. Command example: ```bash sudo mkfs.fat -F32 /dev/sda1 ``` 3. **Mount Point Assignment**: During both manual installations or automated processes like those facilitated by PXE servers utilizing DHCP, TFTP-SERVER configurations mentioned earlier[^2], assigning `/boot/efi` mount point ensures all relevant bootloader components reside correctly inside the designated area accessible at runtime post-boot process completion. By adhering strictly to these guidelines while preparing disks meant specifically towards supporting secure yet flexible multi-operating environments inclusive of contemporary LINUX variants alongside others leveraging advanced features provided exclusively through Unified Extensible Firmware Interface architectures becomes feasible without encountering significant hurdles along the way.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值