雨林的Blog

Ubuntu 18.04使用GPT分区并挂载硬盘

进行sudo fdisk -l查看机器上都插了哪些安装盘,看到/dev/sda,并且没有进行分区。

这个时候是没有挂载的,运行如下命令:

root@XXX:~# sudo parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you
want to continue?
Yes/No? no
(parted) mkpart logical 0 -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? ingnore
parted: invalid token: ingnore
Ignore/Cancel? ignore
(parted) print
Model: Phi H1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  1000GB  1000GB               logical
(parted) quit

这个时候应该是默认进行分了一个/dev/sda1这个分区

root@XXX:~# sudo mkfs.ext4 -F /dev/sda1
mke2fs 1.44.1 (24-Mar-2018)
Suggestion: Use Linux kernel >= 3.18 for improved stability of the metadata and journal checksum features.
Creating filesystem with 244190397 4k blocks and 61054976 inodes
Filesystem UUID: d268738c-949e-45a3-9170-1390c49fcac1
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

设置挂载点

sudo mkdir /home/phd1 phd1为新文件名,文件名可自定义

执行 sudo nano /etc/fstab

在文件末尾添加

/dev/sda1 /home/phd1 ext4 defaults 0 0

使用sudo mount -a即可进行重新挂载

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »